Esempio n. 1
0
 def updateNonStaticFields(self):
     reqmes='Поле не должно быть пустым'
     maxmes='Значение выше допустимого'
     minmes='Значение ниже допустимого'
     nummes='Это поле заполнено неверно'
     datmes='ММ/ЧЧ/ГГГГ или ММ/ЧЧ/ГГ'
     
     # adding Form with customers
     query = "SELECT customer_id,name FROM customers ORDER BY name asc;"
     info=util.fetchall_from_sql(query)
     info_ok= [(0,'Выберите клиента'),]
     for el in info:
         info_ok.append((el[0],el[1]),)
     self.fields['customer_id'] = forms.ChoiceField(label='Клиент',choices=info_ok)
     
     # adding Form with delpoint_id-es
     query = "SELECT delpoint_id,del_address FROM delpoints ORDER BY del_address asc;"
     info=util.fetchall_from_sql(query)
     info_ok= [(0,'Выберите пункт доставки'),]
     for el in info:
         info_ok.append((el[0],el[1]),)
     self.fields['delpoint_id'] = forms.ChoiceField(label='Пункт доставки',choices=info_ok)
     
     # adding Output 1
     query = "SELECT output_id,output_name FROM outputs ORDER BY output_name asc;"
     outputs=util.fetchall_from_sql(query)
     outputs_ok = [(0,'Выберите товар'),]
     for el in outputs:
         outputs_ok.append((el[0],el[1]),)
     #ch=[('M','Male'),('F','Female')]
     self.fields['output_id1'] = forms.ChoiceField(label='Товар',choices=outputs_ok)
Esempio n. 2
0
def notdelivered (request): 
    infoheader=['Номер','План. дата','Заказ','Ответственный','Транспортное средство','Агент']
    query = "select a.order_id, b.plan_date,(select string_agg(y.output_name||' - '||x.quantity||'шт.',',  ') as output "
    query+=" from orders_outputs x inner join outputs y on x.output_id=y.output_id where x.order_id=a.order_id "
    query+=" group by x.order_id), a.responsible, b.vehicle, b.agent from orders a "
    query+=" inner join delivery_diagrams b on a.diagram_id=b.diagram_id and b.status=false "
    query+=" order by b.plan_date asc;"
    info=util.fetchall_from_sql(query)
    return render_to_response('notdelivered.html',locals())
Esempio n. 3
0
 def updateNonStaticForm(self):
     
     # adding orders to delivering_order Form
     query = "select a.order_id,b.plan_date "
     query+= "from orders a inner join delivery_diagrams b "
     query+= "on (a.diagram_id=b.diagram_id and b.status=false);"
     outputs=util.fetchall_from_sql(query)
     ord_ok = [(0,'Выберите заказ'),]
     for el in outputs:
         ord_ok.append((el[0],"№"+str(el[0])+", план - "+str(el[1])),)
     self.fields['delivering_order'] = forms.ChoiceField(label='Заказ',choices=ord_ok)
Esempio n. 4
0
def customers(request):
    data=False
    if request.method == 'GET':
        data=True
        form = CustomersForm(request.GET)
        if form.is_valid():
            cd = form.cleaned_data
            type  = str(cd['type'])
            address  = cd['address']
            phone  = cd['phone']
            fax  = cd['fax']
            email  = cd['email']
            bank  = cd['bank']
            account  = cd['account']
            bik  = cd['bik']
            inn  = cd['inn']
            okonh  = cd['okonh']
            okpo  = cd['okpo']
            if type=='0' or type=='2': # if 'all' have chosen
                query = "SELECT customer_id, name, "
                infoheader=['Номер','Имя']
                if address: query+="address, ";infoheader.append('Адрес')
                if phone: query+="phone, ";infoheader.append('Телефон')
                if fax: query+="fax, ";infoheader.append('Факс')
                if email: query+="email, ";infoheader.append('Email')
                query = query[:-2]
                if type=='0':
                    query+= " FROM customers;"
                elif type=='2':
                    query+= " FROM customers WHERE type=TRUE;"
            elif type=='1':
                query = "SELECT customers.customer_id, customers.name, "
                infoheader=['Номер','Имя']
                if address: query+="customers.address, ";infoheader.append('Адрес')
                if phone: query+="customers.phone, ";infoheader.append('Телефон')
                if fax: query+="customers.fax, ";infoheader.append('Факс')
                if email: query+="customers.email, ";infoheader.append('Email')
                if bank: query+="customers_lp.bank, ";infoheader.append('Банк')
                if account: query+="customers_lp.account, ";infoheader.append('Счёт')
                if bik: query+="customers_lp.bik, ";infoheader.append('БИК')
                if inn: query+="customers_lp.inn, ";infoheader.append('ИНН')
                if okonh: query+="customers_lp.okonh, ";infoheader.append('ОКОНХ')
                if okpo: query+="customers_lp.okpo, ";infoheader.append('ОКПО')
                query = query[:-2]
                query+= " FROM customers RIGHT JOIN customers_lp "
                query+= " on(customers.customer_id=customers_lp.customer_id);"
            if type in ('0','1','2'):
                info=util.fetchall_from_sql(query)
            return render_to_response('customers.html',locals())
        return render_to_response('customers.html',locals())
    else:
        form = CustomersForm()
        return render_to_response('customers.html',locals())
Esempio n. 5
0
def outputs(request):
    data = False
    if 'ctype' in request.GET:
        data = True
        infoheader=['id','Name','Price']
        query = "SELECT output_id, output_name, output_price FROM outputs"
        ct=request.GET['ctype']
        if ct=='0':
            query += " ORDER BY output_id"
        elif ct=='1':
            query += " ORDER BY output_name"
        elif ct=='2':
            query += " ORDER BY output_price"
        ot=request.GET['ordertype']
        if ot=='0':
            query += " desc;"
        elif ot == '1':
            query += " asc;"
        info=util.fetchall_from_sql(query)
    return render_to_response('outputs.html',locals())
Esempio n. 6
0
def customers_old(request):
    data = False
    if 'ctype' in request.GET: # equals if request was
        data = True
        ct=request.GET['ctype'] # what is chosen?
        if ct=='0' or ct=='2': # if 'all' have chosen
            query = "SELECT customer_id, name, "
            infoheader=['id','Name']
            if 'showopt' in request.GET: #if any checkbox is selected
                so=request.GET.getlist('showopt')
                for h in so: # for each selected checkbox
                    str_h=str(h)
                    if str_h not in('bank','account','bik','inn','okonh','okpo'):
                        query+=str_h+", "
                        infoheader.append(str(h).capitalize())
            query = query[:-2]
            if ct=='0':
                query+= " FROM customers;"
            elif ct=='2':
                query+= " FROM customers WHERE type=TRUE;"
            
        elif ct=='1':
            query = "SELECT customers.customer_id, customers.name, "
            infoheader=['id','Name']
            if 'showopt' in request.GET: #if any checkbox is selected
                so=request.GET.getlist('showopt')
                for h in so: # for each selected checkbox
                    str_h=str(h)
                    infoheader.append(str(h).capitalize())
                    if str_h not in('bank','account','bik','inn','okonh','okpo'):
                        query+="customers."+str_h+", "
                    else:
                        query+="customers_lp."+str_h+", "
            query = query[:-2]
            query+= " FROM customers RIGHT JOIN customers_lp "
            query+= " on(customers.customer_id=customers_lp.customer_id);"
            
        info=util.fetchall_from_sql(query)
    return render_to_response('customers.html',locals())
Esempio n. 7
0
def orders(request):
    infoheader=['Заказ','Клиент','Ответственный','Дата заказа','Сумма','Итого (со скидкой)']
    query = "select order_id,customer_id,responsible,order_date,order_amount,order_total "
    query+= "from orders;"
    info=util.fetchall_from_sql(query)
    return render_to_response('orders.html',locals())