Example #1
0
    def get(self):
        inp = self.input(dt='', l=0, r=0, f=0, depart=0)

        if inp.dt == 'line':
            sql = 'SELECT UNIQUE stelag FROM tovar_place WHERE stelag IS NOT NULL ORDER BY 1'
            self.write_XML(
                Executor.exec_cls(sql).as_combo('stelag', id='stelag'))

        elif inp.dt == 'row':
            sql = 'SELECT UNIQUE place FROM tovar_place WHERE place IS NOT NULL ORDER BY 1'
            self.write_XML(
                Executor.exec_cls(sql).as_combo('place', id='place'))

        elif inp.dt == 'floor':
            sql = 'SELECT UNIQUE polka FROM tovar_place WHERE polka IS NOT NULL ORDER BY 1'
            self.write_XML(
                Executor.exec_cls(sql).as_combo('polka', id='polka'))

        elif inp.dt == 'img':
            try:
                self.write(
                    cell(int(inp.l), int(inp.r), int(inp.f), int(inp.depart)))
                self.set_header("Content-Type", "image/svg+xml")
            except:
                pass
Example #2
0
    def get(self):
        inp = self.input(grid=0, alist=0)

        try:
            alist = int(inp.alist)
            grid = int(inp.grid)

            # left grid
            if grid == 1:
                sql = '''SELECT pl.id,pl.valume,pl.mesto,pl.weight,t.code,t.name 
FROM packlist pl 
JOIN tovar t ON pl.tovar=t.id and pl.sw_header_recordp= :alist'''
                self.write_XML(Executor.exec_cls(sql, alist=alist)
                               .as_grid('code', 'name', 'valume', 'mesto', 'weight', id='id'))



            # right grid
            elif grid == 2:
                sql = '''SELECT * FROM
( SELECT t.id,t.code,t.name,(SUM(ABS(r.valume))-NVL(SUM(p.valume),0)) valume
  FROM sw_header_recordp shr 
  JOIN recordp r  on shr.depart=r.depart 
  JOIN tovar t on t.id=r.tovar
  LEFT JOIN (SELECT tovar,SUM(valume) valume FROM packlist 
             WHERE sw_header_recordp= :alist
             GROUP BY tovar) p ON p.tovar=t.id 
  WHERE shr.id= :alist AND r.factura IN (SELECT id FROM factura WHERE header=shr.header) 
  GROUP BY t.id,t.code,t.name)
WHERE valume<>0'''
                self.write_XML(Executor.exec_cls(sql, alist=alist)
                               .as_grid('code', 'name', 'valume', id='id'))

        except:
            self.write_XML('<rows />')
Example #3
0
    def get(self, param):
        w, h = 200, 142
        
                 
        head  = self.get_argument("head", 0)
        fname = self.get_argument("fname", '')
       
        header_id = self.get_argument("id", default=None)
        
        
        if param == 'item':

            out = self.cursor.var(cx_Oracle.CURSOR)    
            res = self.proc("shiva.GetHeaderAssemblyList", [header_id, None, None, None, out])
                
            all_results = fetchone(res[-1])        
                
            self.write(all_results)
            return        
        
               

        if param == 'head':

            pFilter = self.get_argument("oper", None)
            
            sotrud = self.session.uid
            
            out = self.cursor.var(cx_Oracle.CURSOR)    
            
            res = self.proc("shiva.GetHeaderAssemblyList", [None, self.session.rc, pFilter, sotrud, out])
                
            all_results = fetchall(res[-1], count=0)
                
            self.write(all_results)
            return
                

        elif param == 'info':
         
            self.write(Header.get_item(head, rc=self.session.rc).as_json('prim', 'marsh_cls.name')[0])
            # self.write({'error': 'test' })
        
            
            
        elif param == 'messages':

            sql = "select t.code,t.name,f.valume from factura f left join tovar t on isclad.GetTovarFromModify(f.tovar)=t.id where f.header=:pHeader"

            self.write_XML(Executor.exec_cls(sql, pHeader=head)
                           .as_grid('code', 'name', 'valume'))
                        

        elif param == 'tovar':

            sql = "select t.code,t.name,f.valume from factura f left join tovar t on isclad.GetTovarFromModify(f.tovar)=t.id where f.header=:pHeader"

            self.write_XML(Executor.exec_cls(sql, pHeader=head)
                           .as_grid('code', 'name', 'valume'))
Example #4
0
    def get(self, param):
        w, h = 200, 142

        head = self.get_argument("head", 0)
        fname = self.get_argument("fname", '')

        header_id = self.get_argument("id", default=None)

        if param == 'item':

            out = self.cursor.var(cx_Oracle.CURSOR)
            res = self.proc("shiva.GetHeaderAssemblyList",
                            [header_id, None, None, None, out])

            all_results = fetchone(res[-1])

            self.write(all_results)
            return

        if param == 'head':

            pFilter = self.get_argument("oper", None)

            sotrud = self.session.uid

            out = self.cursor.var(cx_Oracle.CURSOR)

            res = self.proc("shiva.GetHeaderAssemblyList",
                            [None, self.session.rc, pFilter, sotrud, out])

            all_results = fetchall(res[-1], count=0)

            self.write(all_results)
            return

        elif param == 'info':

            self.write(
                Header.get_item(head, rc=self.session.rc).as_json(
                    'prim', 'marsh_cls.name')[0])
            # self.write({'error': 'test' })

        elif param == 'messages':

            sql = "select t.code,t.name,f.valume from factura f left join tovar t on isclad.GetTovarFromModify(f.tovar)=t.id where f.header=:pHeader"

            self.write_XML(
                Executor.exec_cls(sql, pHeader=head).as_grid(
                    'code', 'name', 'valume'))

        elif param == 'tovar':

            sql = "select t.code,t.name,f.valume from factura f left join tovar t on isclad.GetTovarFromModify(f.tovar)=t.id where f.header=:pHeader"

            self.write_XML(
                Executor.exec_cls(sql, pHeader=head).as_grid(
                    'code', 'name', 'valume'))
Example #5
0
File: system.py Project: uve/shiva
    def post(self, param):
        try:
            imen, imod = param.split('/')
            sql = '''UPDATE sw_module SET help = :hlp
                     WHERE name = :imod
                       AND sw_menu_id = (SELECT id FROM sw_menu WHERE name = :imen)'''
            Executor.exec_sql(sql, imen=imen, imod=imod, hlp=self.request.body)

            self.write({'info':'Информация сохранена'})
        except:
            self.write({'warning':'Ошибка записи'})
Example #6
0
File: openday.py Project: uve/shiva
    def post(self):
        try:
            period = int(self.input().period)

            sql = 'UPDATE sw_role_history SET role_end=SYSDATE WHERE role_end IS NULL AND period=:period '
            Executor.exec_sql(sql, period=period)

            sql = 'UPDATE period SET data_end=SYSDATE WHERE period=:period '
            Executor.exec_sql(sql, period=period)

            self.write({'info': 'Информация сохранена'})
        except:
            self.write({'warning': 'Ошибка записи'})
Example #7
0
File: openday.py Project: uve/shiva
    def post(self):
        try:
            period = int(self.input().period)

            sql = 'UPDATE sw_role_history SET role_end=SYSDATE WHERE role_end IS NULL AND period=:period '
            Executor.exec_sql(sql, period=period)

            sql = 'UPDATE period SET data_end=SYSDATE WHERE period=:period '
            Executor.exec_sql(sql, period=period)

            self.write({'info':'Информация сохранена'})
        except:
            self.write({'warning':'Ошибка записи'})
Example #8
0
File: chkbtk.py Project: uve/shiva
    def post(self, param):
        if param == 'party':
            inp = self.input(ids=0, dat='')

            try:
                ids = int(inp.ids)
                for i in [int(i) for i in inp.dat.split(',')]:
                    # Подтверждение партии на БТК
                    # (pHeader in integer, pParty in integer)
                    Executor.exec_sql('BEGIN shiva.OkPartyInput(:d1, :d2); END;', d1=ids, d2=i)

                # подтверждение всей фактуры 
                Executor.exec_sql('BEGIN tsclad.oksdelka(:d1, 0); END;', d1=ids)
                self.write({'info':'Информация сохранена'})
            except:
                self.write({'warning':'Ошибка записи'})
Example #9
0
File: openday.py Project: uve/shiva
    def get(self):

        
        depart = self.get_argument("depart", None)
        period = self.get_argument("period", 0)

        sql = '''SELECT s.ID, s.NAME,
                        CASE
                          WHEN s.role = 1 THEN rs.NAME
                          WHEN h.ROLE IS NOT NULL THEN rh.NAME
                          ELSE rs.NAME
                        END inrole,
                        CASE
                          WHEN h.ROLE_BEGIN IS NOT NULL AND h.ROLE_END IS NULL THEN 1
                          ELSE 0
                        END insmen
                 FROM sotrud s
                 LEFT JOIN sw_role_history h ON s.id = h.SOTRUD AND h.period = :period AND h.ROLE_END IS NULL
                 LEFT JOIN sw_roles rh ON h.role = rh.id
                 LEFT JOIN sw_roles rs ON s.role = rs.id
                 WHERE s.DEPART = :depart AND s.VISIBLE = 1
                 ORDER BY 4 DESC, 3, 1'''


        self.write_XML(Executor.exec_cls(sql, period=period, depart=depart)
                       .as_grid('name', 'inrole', 'insmen', id='id'))
Example #10
0
File: openday.py Project: uve/shiva
    def get(self):

        depart = self.get_argument("depart", None)
        period = self.get_argument("period", 0)

        sql = '''SELECT s.ID, s.NAME,
                        CASE
                          WHEN s.role = 1 THEN rs.NAME
                          WHEN h.ROLE IS NOT NULL THEN rh.NAME
                          ELSE rs.NAME
                        END inrole,
                        CASE
                          WHEN h.ROLE_BEGIN IS NOT NULL AND h.ROLE_END IS NULL THEN 1
                          ELSE 0
                        END insmen
                 FROM sotrud s
                 LEFT JOIN sw_role_history h ON s.id = h.SOTRUD AND h.period = :period AND h.ROLE_END IS NULL
                 LEFT JOIN sw_roles rh ON h.role = rh.id
                 LEFT JOIN sw_roles rs ON s.role = rs.id
                 WHERE s.DEPART = :depart AND s.VISIBLE = 1
                 ORDER BY 4 DESC, 3, 1'''

        self.write_XML(
            Executor.exec_cls(sql, period=period,
                              depart=depart).as_grid('name',
                                                     'inrole',
                                                     'insmen',
                                                     id='id'))
Example #11
0
File: boxass.py Project: uve/shiva
 def print_boxass(self, user=None, m_factura=None, m_start=None, m_end=None):
     # TODO: Аленина функция проверки необходимости печати
     
     
     isp = 1
     
     m_name = ""
     
     if user:
            
         
         result = self.func('shiva.GetNeedLabel', returnType=cx_Oracle.NUMBER, parameters=[user.id])                                               
         isp = int(result)
         
     
         sql = '''SELECT MIN(m_start) f, MAX(m_end) l, factura
                  FROM packlist 
                  WHERE sotrud=(SELECT sotrud FROM sotrud WHERE id = :sid)
                    AND dend IS NULL
                 GROUP BY factura'''
     
  
         x = Executor.exec_cls(sql, multi=False, sid=user.id)
         
         try:
             m_start = x.f
             m_end = x.l
             m_factura = x.factura 
             m_name = user.name
         except:
             pass
 
     
     if m_factura and isp == 1:
         return {'info':m_name,
                     'precmd':'self.InitContent();',
                     'def':['<div id="sw_mess" style="padding:10px;">Фактура: %s, места: %s..%s</div>' % (m_factura, m_start, m_end)],
                     'cmd':'''var urs=[%s,%s];
                         for(i=%s; i<=%s; i++)
                             urs.push("/group/boxass/data?factura=%s&position="+i +"&time="+new Date().getTime() );
                         self.PrintURL.apply(self, urs);   
                                             
                         setTimeout(function(){ self.Refresh() }, 3000);
                     ''' % (box_label_size[0], box_label_size[1], m_start, m_end, m_factura)}
             
 
 
     elif isp == 0:
         return {'info':m_name,
                     'precmd':'self.InitContent();',
                     'def':['<div id="sw_mess" style="padding:10px;"> Тип  оклейки  не покоробочный, печати отгрузочных этикеток не требуется</div>'],
                     'cmd':'setTimeout(function(){ self.Refresh() }, 2000);'}
                     
     else:
         return {'info':m_name,
                     'precmd':'self.InitContent();',
                     'def':['<div id="sw_mess" style="padding:10px;">Печать не нужна</div>'],
                     'cmd':'setTimeout(function(){ self.Refresh() }, 2000);'}
Example #12
0
File: rawsql.py Project: uve/shiva
 def post(self):
     try:
         self.write_XML(Executor.exec_cls(self.request.body, multi=True).as_grid(head=True))
         # self.write(['ERROR', 'Режим заблокирован администратором'])
         # self.write({'error': 'Режим заблокирован администратором' })
         
         pass 
     except Exception, e:
         self.set_status(404)
         self.write(str(e))
Example #13
0
    def post(self):
        inp = self.input(alist=0, idd=0, bar='', cnt=0, num=0, mas=0)

        try:idd = int(inp.idd)
        except:idd = 0

        try:
            if idd:
                # удаляем из упаковки
                Executor.exec_sql('DELETE FROM packlist WHERE id= :idd', idd=idd)
                self.write({'info':'Информация сохранена'})
            else:
                # добавляем в упаковку
                try:alist = int(inp.alist)
                except:alist = 0
                try:bar = inp.bar
                except:bar = ''
                try:cnt = float(inp.cnt)
                except:cnt = 0.0
                try:num = int(inp.num)
                except:num = 0
                try:mas = float(inp.mas)
                except:mas = 0.0

                ret = self.cursor.var(cx_Oracle.NUMBER)
                self.execute('begin shiva.AddPackList(:alist, :bar, :cnt, :num, :mas, 0, :ret); end;',
                                     alist=alist, bar=bar, cnt=cnt, num=num, mas=mas, ret=ret)

                r = ret.getvalue()
                if r == -0:
                    self.write({'info':'Информация сохранена'})
                elif r == -1:
                    self.write({'warning':'Товара не существует'})
                elif r == -3:
                    self.write({'warning':'В заказе нет такого продукта'})
                elif r == -4:
                    self.write({'warning':'Количество превышает заказ'})
                else:
                    self.write({'warning':'Чета не так - %s' % r})

        except:
            self.write({'warning':'Ошибка записи'})
Example #14
0
File: chkbtk.py Project: uve/shiva
    def post(self, param):
        if param == 'party':
            inp = self.input(ids=0, dat='')

            try:
                ids = int(inp.ids)
                for i in [int(i) for i in inp.dat.split(',')]:
                    # Подтверждение партии на БТК
                    # (pHeader in integer, pParty in integer)
                    Executor.exec_sql(
                        'BEGIN shiva.OkPartyInput(:d1, :d2); END;',
                        d1=ids,
                        d2=i)

                # подтверждение всей фактуры
                Executor.exec_sql('BEGIN tsclad.oksdelka(:d1, 0); END;',
                                  d1=ids)
                self.write({'info': 'Информация сохранена'})
            except:
                self.write({'warning': 'Ошибка записи'})
Example #15
0
    def get(self):
        inp = self.input(grid=0, alist=0)

        try:
            alist = int(inp.alist)
            grid = int(inp.grid)

            # left grid
            if grid == 1:
                sql = '''SELECT pl.id,pl.valume,pl.mesto,pl.weight,t.code,t.name 
FROM packlist pl 
JOIN tovar t ON pl.tovar=t.id and pl.sw_header_recordp= :alist'''
                self.write_XML(
                    Executor.exec_cls(sql, alist=alist).as_grid('code',
                                                                'name',
                                                                'valume',
                                                                'mesto',
                                                                'weight',
                                                                id='id'))

            # right grid
            elif grid == 2:
                sql = '''SELECT * FROM
( SELECT t.id,t.code,t.name,(SUM(ABS(r.valume))-NVL(SUM(p.valume),0)) valume
  FROM sw_header_recordp shr 
  JOIN recordp r  on shr.depart=r.depart 
  JOIN tovar t on t.id=r.tovar
  LEFT JOIN (SELECT tovar,SUM(valume) valume FROM packlist 
             WHERE sw_header_recordp= :alist
             GROUP BY tovar) p ON p.tovar=t.id 
  WHERE shr.id= :alist AND r.factura IN (SELECT id FROM factura WHERE header=shr.header) 
  GROUP BY t.id,t.code,t.name)
WHERE valume<>0'''
                self.write_XML(
                    Executor.exec_cls(sql, alist=alist).as_grid('code',
                                                                'name',
                                                                'valume',
                                                                id='id'))

        except:
            self.write_XML('<rows />')
Example #16
0
File: rolemod.py Project: uve/shiva
    def get(self):
        try:
            sql = '''SELECT m.id, s.caption menu, m.caption, m.description, r.role_id
                     FROM sw_module m
                     LEFT JOIN sw_role_module r ON m.id=r.module_id AND r.ROLE_ID=:role
                     JOIN sw_menu s ON m.sw_menu_id=s.id'''

            self.write_XML(Executor.exec_cls(sql, role=int(self.input().role))
                           .as_grid('menu', 'caption', 'description', 'role_id'))

        except:
            self.write_XML('<rows />')
Example #17
0
    def post(self):
        try:
            self.write_XML(
                Executor.exec_cls(self.request.body,
                                  multi=True).as_grid(head=True))
            # self.write(['ERROR', 'Режим заблокирован администратором'])
            # self.write({'error': 'Режим заблокирован администратором' })

            pass
        except Exception, e:
            self.set_status(404)
            self.write(str(e))
Example #18
0
File: prncell.py Project: uve/shiva
    def get(self):
        inp = self.input(dt='', l=0, r=0, f=0, depart=0)

        if inp.dt == 'line':
            sql = 'SELECT UNIQUE stelag FROM tovar_place WHERE stelag IS NOT NULL ORDER BY 1'
            self.write_XML(Executor.exec_cls(sql).as_combo('stelag', id='stelag'))

        elif inp.dt == 'row':
            sql = 'SELECT UNIQUE place FROM tovar_place WHERE place IS NOT NULL ORDER BY 1'
            self.write_XML(Executor.exec_cls(sql).as_combo('place', id='place'))

        elif inp.dt == 'floor':
            sql = 'SELECT UNIQUE polka FROM tovar_place WHERE polka IS NOT NULL ORDER BY 1'
            self.write_XML(Executor.exec_cls(sql).as_combo('polka', id='polka'))

        elif inp.dt == 'img':
            try:
                self.write(cell(int(inp.l), int(inp.r), int(inp.f), int(inp.depart)))
                self.set_header("Content-Type", "image/svg+xml")
            except:
                pass
Example #19
0
File: rolemod.py Project: uve/shiva
    def get(self):
        try:
            sql = '''SELECT m.id, s.caption menu, m.caption, m.description, r.role_id
                     FROM sw_module m
                     LEFT JOIN sw_role_module r ON m.id=r.module_id AND r.ROLE_ID=:role
                     JOIN sw_menu s ON m.sw_menu_id=s.id'''

            self.write_XML(
                Executor.exec_cls(sql, role=int(self.input().role)).as_grid(
                    'menu', 'caption', 'description', 'role_id'))

        except:
            self.write_XML('<rows />')
Example #20
0
File: system.py Project: uve/shiva
    def get(self, param):
        if not param:
            self.write('Введите штрих-код со своего бэйджика или свои логин и пароль, и нажмите кнопку "OK"')

        else:
            try:
                imen, imod = param.split('/')
                sql = '''SELECT help FROM sw_module
                         WHERE name = :imod
                           AND sw_menu_id = (SELECT id FROM sw_menu WHERE name = :imen)'''

                self.write(Executor.exec_sql(sql, multi=False, imen=imen, imod=imod)['data'][0].read())
            except:
                self.write('')
Example #21
0
File: openday.py Project: uve/shiva
    def get(self):
        period = int(self.input().period)

        sql = '''SELECT h.id, d.name dp, s.name, h.role_begin, h.role_end, r.name role
                 FROM sw_role_history h
                 JOIN sotrud s ON h.sotrud=s.id
                 JOIN sw_roles r ON h.role=r.id
                 LEFT JOIN depart d ON s.depart=d.depart
                 WHERE h.PERIOD=:period
                 ORDER BY 2,3,4'''

        self.write_XML(Executor.exec_cls(sql, period=period)
                       .as_grid('dp', 'name', 'role_begin', 'role_end', 'role', id='id',
                                show={'role_begin':lambda val: val.strftime("%d.%m.%Y %H:%M"),
                                      'role_end':lambda val: val.strftime("%d.%m.%Y %H:%M")}))
Example #22
0
File: chkbtk.py Project: uve/shiva
    def get(self, param):
        if param == 'head':
            try:
                oper = int(self.input(oper=0).oper)
            except:
                oper = 0
            self.write_XML(
                Header.select_BTK(oper, rc=self.session.rc).as_grid(
                    'id',
                    'num',
                    'date',
                    'client_from_cls.name',
                    'oper_cls.name',
                    show={'date': lambda val: val.strftime("%d.%m.%Y")}))

        elif param == 'tovar':
            try:
                head = int(self.input(head=0).head)
            except:
                head = 0

            sql = '''SELECT pa.party,  t.code, t.name, sum(r.valume) valume, pa.data, 1 sm
                     FROM recordp r, tovar t, party pa, factura f
                     WHERE r.factura=f.id 
                       AND pa.party=r.party
                       AND t.id = pa.tovar 
                       AND f.header=%s
                     GROUP BY pa.party, t.code, t.name, pa.data''' % head
            self.write_XML(
                Executor.exec_cls(sql).as_grid(
                    'party',
                    'code',
                    'name',
                    'valume',
                    'data',
                    'sm',
                    show={'data': lambda val: val.strftime("%d.%m.%Y")},
                    id='party'))
Example #23
0
File: openday.py Project: uve/shiva
    def get(self):
        period = int(self.input().period)

        sql = '''SELECT h.id, d.name dp, s.name, h.role_begin, h.role_end, r.name role
                 FROM sw_role_history h
                 JOIN sotrud s ON h.sotrud=s.id
                 JOIN sw_roles r ON h.role=r.id
                 LEFT JOIN depart d ON s.depart=d.depart
                 WHERE h.PERIOD=:period
                 ORDER BY 2,3,4'''

        self.write_XML(
            Executor.exec_cls(sql, period=period).as_grid(
                'dp',
                'name',
                'role_begin',
                'role_end',
                'role',
                id='id',
                show={
                    'role_begin': lambda val: val.strftime("%d.%m.%Y %H:%M"),
                    'role_end': lambda val: val.strftime("%d.%m.%Y %H:%M")
                }))
Example #24
0
File: chkbtk.py Project: uve/shiva
    def get(self, param):
        if param == 'head':
            try: oper = int(self.input(oper=0).oper)
            except: oper = 0
            self.write_XML(Header.select_BTK(oper, rc=self.session.rc)
                           .as_grid('id', 'num', 'date', 'client_from_cls.name', 'oper_cls.name',
                                    show={'date':lambda val: val.strftime("%d.%m.%Y")}))

        elif param == 'tovar':
            try: head = int(self.input(head=0).head)
            except: head = 0

            sql = '''SELECT pa.party,  t.code, t.name, sum(r.valume) valume, pa.data, 1 sm
                     FROM recordp r, tovar t, party pa, factura f
                     WHERE r.factura=f.id 
                       AND pa.party=r.party
                       AND t.id = pa.tovar 
                       AND f.header=%s
                     GROUP BY pa.party, t.code, t.name, pa.data''' % head
            self.write_XML(Executor.exec_cls(sql)
                           .as_grid('party', 'code', 'name', 'valume', 'data', 'sm',
                                    show={'data':lambda val: val.strftime("%d.%m.%Y")},
                                    id='party'))
Example #25
0
    def get(self, param):

        w, h = 200, 142
        inp = self.input(oper=0, head=0, fname='', mode='', d='', depart=0)

        try:
            head = int(inp.head)
        except:
            head = 0

        if param == 'head':
            try:
                oper = int(inp.oper)
            except:
                oper = 0

            try:
                ds = datetime.datetime.fromtimestamp(int(int(inp.d1) / 1000))
            except:
                ds = datetime.datetime.now()
            ds = ds.date()

            try:
                de = datetime.datetime.fromtimestamp(int(int(inp.d2) / 1000))
            except:
                de = datetime.datetime.now()
            de = de.date()

            self.write_XML(
                Header.select_passport(
                    oper, ds, de, rc=self.session.rc).as_grid(
                        'id',
                        'num',
                        'date',
                        'client_to_cls.name',
                        'oper_cls.name',
                        'status_cls.name',
                        show={'date': lambda val: val.strftime("%d.%m.%Y")}))

        elif param == 'print':
            try:
                mode = int(inp.mode)
            except:
                raise HTTPError(404)

            # Накладная
            if mode == 0:
                '''
                out = self.cursor.var(cx_Oracle.CURSOR)                           
                res = self.proc("shiva.header_info", [header_id, out])                  
                results = res[-].fetchone()
                
                результат 
                         id,  
                         num,          -- номер
                         data,          -- дата
                         client_from, -- от кого
                         client_to      -- кому
                 '''

                header_id = head  #self.get_argument("head",   None)
                out = self.cursor.var(cx_Oracle.STRING)

                results = self.proc("shiva_tehno.header_printing_form",
                                    [header_id, out])

                return self.write(results[1])

                #new_document = Document(self.request.arguments, rc=self.session.rc)
                #return self.write(new_document.as_print())

            # Сборочные
            elif mode == 4:
                new_document = AssemblyList(self.request.arguments,
                                            rc=self.session.rc)
                return self.write(new_document.as_print())
                # self.write({'cmd':'''self.Incunable(function(doc){ doc.write('%s') })''' % AssemblyList(head).dump()})

            # Упаковочный лист
            elif mode == 3:
                # self.write({'info':'В разработке'})
                new_document = Package(self.request.arguments,
                                       rc=self.session.rc)
                return self.write(new_document.as_print())

            # Паспорта качества
            elif mode == 10:
                sql = '''SELECT distinct p.num, t.name, v.category,
                                tsclad.getpartysertfile(p.party, :rc) sertfile,
                                SUBSTR(isclad.GetTovarCodeFromModify(t.id), 1, 25) code
                         FROM factura f
                         JOIN tovar t ON f.tovar = t.id
                         LEFT JOIN recordp r on f.id = r.factura
                         JOIN party p on r.party=p.party
                         LEFT JOIN type_tovar v ON t.typet=v.id
                         WHERE f.header = :head AND v.CATEGORY<>5
                         ORDER BY category, name'''

                good = []
                errn = []

                ret = {}
                for i in Executor.exec_cls(sql, rc=self.session.rc, head=head):
                    try:
                        fname = i.sertfile.decode('utf8')
                        if not fname: raise Exception()

                        if fname not in self.application.passport_cash:
                            Image.open(os.path.join(SHIVA_PASSPORT, fname))
                            self.application.passport_cash[fname] = None

                        if fname not in good: good.append(fname)
                    except:
                        errn.append(
                            "'%s','%s','%s','%s'" %
                            (i.num, i.code, i.name,
                             '-' if i.sertfile is None else i.sertfile))
                        continue

                if errn:
                    ret['warning'] = [
                        "Не найден паспорт<br/>%s" % i for i in errn
                    ]

                goods = u','.join("'%s'" % i for i in good)
                errns = u','.join(u"[%s]" % i.decode('utf8') for i in errn)

                cmd = u'''var fn=[%s]; var er=[%s];
    
                    self.Incunable(function(doc){                
                        for(var i in fn){
                            doc.write('<img width="%s" height="%s" src="/warehouse/printpassport/data/image?mode=1&fname='+fn[i]+'">');
                        }
                        
                        if(!!(fn.length %% 2)){
                            doc.write('<div style="height:600px;"><br/></div>');
                        }                    
                        
                        if(er.length){
                            doc.write('<br/><br/><div>Не найдены паспорта качества:</div><table style="border:1 solid #000;">');
                            
                            var hd=['N','Партия','Код','Товар','Паспорт'];
                            doc.write('<tr>');
                            for(var i in hd)
                                doc.write('<td style="border-bottom:1 solid #888; border-right:1 solid #000;">'+hd[i]+'</td>');
                            doc.write('</tr>');
                                                
                            for(var i in er){
                                doc.write('<tr>');
                                doc.write('<td style="padding:3px; border-bottom:1 solid #888; border-right:1 solid #000;">'+(1+parseInt(i))+'</td>');
                                for(var j in er[i])
                                    doc.write('<td style="border-bottom:1 solid #888; border-right:1 solid #000;">'+er[i][j]+'</td>');
                                doc.write('</tr>');
                            }                        
                            doc.write('</table>');                        
                        }               
                    });''' % (goods, errns, int(3.47 * w), int(3.47 * h))

                ret['cmd'] = cmd.encode('utf8')
                self.write(ret)

                return
            # Паспорта качества
            elif mode == 1:

                sql = '''SELECT distinct p.num, t.name, v.category,
                                tsclad.getpartysertfile(p.party, %s) sertfile,
                                SUBSTR(isclad.GetTovarCodeFromModify(t.id), 1, 25) code
                         FROM factura f
                         JOIN tovar t ON f.tovar = t.id
                         LEFT JOIN recordp r on f.id = r.factura
                         JOIN party p on r.party=p.party
                         LEFT JOIN type_tovar v ON t.typet=v.id
                         WHERE f.header = %s AND v.CATEGORY<>5
                         ORDER BY category, name''' % (self.session.rc, head)

                res = self.execute(sql)
                good = fetchall_by_name(res)

                all_passports = []

                index = 1

                for item in good:
                    name = item["sertfile"]
                    if not name: continue

                    new_passport = Passport()

                    new_passport.index = index

                    new_passport.category = item["category"]
                    new_passport.code = item["code"]
                    new_passport.num = item["num"]

                    new_passport.name = name
                    new_passport.value = urllib.quote(
                        name.decode('utf-8').encode('koi8-r'))

                    new_passport.exist = self.is_exists(new_passport.value)

                    if not new_passport.exist:
                        index = index + 1

                    all_passports.append(new_passport)

                loader = template.Loader(TEMPLATE_DIR)

                #all_passports[-1].exist = False    #just for testing..

                RC_IP = '192.168.0.1'
                if self.request.remote_ip in [
                        "80.89.129.114", "127.0.0.1", "::1"
                ]:
                    RC_IP = IMAGES_SERVER_IP

                results = loader.load("printpassport.html").generate(
                    remote_ip=self.request.remote_ip,
                    RC_IP=RC_IP,
                    all_passports=all_passports,
                    width=str(int(3.47 * w)),
                    uniq=random.random())

                self.write(results)
                return

            # Отгрузочные этикетки
            elif mode == 2:

                d = []

                try:
                    d = [int(i) for i in inp.d.split(',') if not i is None]
                    d.sort()
                except:
                    pass

                if len(d):
                    # self.write( print_boxass(user=None, m_factura=head, m_start=m_start, m_end=m_end) )

                    self.write({'error': 'Печать отключена'})
                    return
                    # self.write({'info':'В разработке'})
                else:
                    self.write({'error': 'Неверные параметры'})

        elif param == 'image':
            try:
                mode = int(inp.mode)
            except:
                raise HTTPError(404)

            logging.info('Printing image')

            # Накладная
            if mode == 0:
                self.write({'info': 'В разработке'})

            # Паспорта качества
            elif mode == 1:

                self.write({'info': 'В разработке'})
                '''
                try:
                    imgdata = cStringIO.StringIO()

                    logging.info("Before: %s", inp.fname)
                    fname = os.path.join(SHIVA_PASSPORT, urlparse.unquote(inp.fname).decode('utf8'))
                    im = Image.open(fname).rotate(270).resize(mm2pix((w, h,)), Image.ANTIALIAS).filter(ImageFilter.SHARPEN)


                    im.save(imgdata, format='jpeg')
                    imgdata.seek(0)
                    self.write(imgdata.read())

                    self.set_header("Content-Type", "image/jpeg")
                except Exception, e:
                    logging.error(e)
                    raise HTTPError(404)
                '''

                return

            # Отгрузочные этикетки
            elif mode == 2:
                self.write({'info': 'В разработке'})

            # Упаковочный лист
            elif mode == 3:
                self.write({'info': 'В разработке'})

            # Сборочные
            elif mode == 4:
                try:
                    depart = int(inp.depart)
                except:
                    depart = 0

                try:
                    self.write(
                        assembly_bar_label(
                            ListAssembly.get(depart=depart, header=head).id))
                    self.set_header("Content-Type", "image/svg+xml")
                except:
                    raise HTTPError(404)
Example #26
0
    def get(self, param):
        
        
        w, h = 200, 142
        inp = self.input(oper=0, head=0, fname='', mode='', d='', depart=0)

        try:head = int(inp.head)
        except:head = 0

        if param == 'head':
            try: oper = int(inp.oper)
            except: oper = 0

            try: ds = datetime.datetime.fromtimestamp(int(int(inp.d1) / 1000))
            except: ds = datetime.datetime.now()
            ds = ds.date()

            try: de = datetime.datetime.fromtimestamp(int(int(inp.d2) / 1000))
            except: de = datetime.datetime.now()
            de = de.date()

            self.write_XML(Header.select_passport(oper, ds, de, rc=self.session.rc)
                           .as_grid('id', 'num', 'date', 'client_to_cls.name', 'oper_cls.name', 'status_cls.name',
                                    show={'date':lambda val: val.strftime("%d.%m.%Y")}))
            
        elif param == 'print':
            try: mode = int(inp.mode)
            except: raise HTTPError(404)

            

            # Накладная
            if mode == 0:                
                
                '''
                out = self.cursor.var(cx_Oracle.CURSOR)                           
                res = self.proc("shiva.header_info", [header_id, out])                  
                results = res[-].fetchone()
                
                результат 
                         id,  
                         num,          -- номер
                         data,          -- дата
                         client_from, -- от кого
                         client_to      -- кому
                 '''

                header_id   = head#self.get_argument("head",   None)
                out = self.cursor.var(cx_Oracle.STRING)

                results = self.proc("shiva_tehno.header_printing_form", [header_id, out])


                return self.write(results[1])


                #new_document = Document(self.request.arguments, rc=self.session.rc)
                #return self.write(new_document.as_print())
                                                          

            # Сборочные
            elif mode == 4:
                new_document = AssemblyList(self.request.arguments, rc=self.session.rc)                
                return self.write(new_document.as_print())                 
                # self.write({'cmd':'''self.Incunable(function(doc){ doc.write('%s') })''' % AssemblyList(head).dump()})
                
            # Упаковочный лист
            elif mode == 3:
                # self.write({'info':'В разработке'})
                new_document = Package(self.request.arguments, rc=self.session.rc)                
                return self.write(new_document.as_print())                      
                
            # Паспорта качества
            elif mode == 10:
                sql = '''SELECT distinct p.num, t.name, v.category,
                                tsclad.getpartysertfile(p.party, :rc) sertfile,
                                SUBSTR(isclad.GetTovarCodeFromModify(t.id), 1, 25) code
                         FROM factura f
                         JOIN tovar t ON f.tovar = t.id
                         LEFT JOIN recordp r on f.id = r.factura
                         JOIN party p on r.party=p.party
                         LEFT JOIN type_tovar v ON t.typet=v.id
                         WHERE f.header = :head AND v.CATEGORY<>5
                         ORDER BY category, name'''

                good = []
                errn = []

          
                                     
                ret = {}
                for i in Executor.exec_cls(sql, rc=self.session.rc, head=head):
                    try:
                        fname = i.sertfile.decode('utf8')
                        if not fname: raise Exception()

                        if fname not in self.application.passport_cash:
                            Image.open(os.path.join(SHIVA_PASSPORT, fname))
                            self.application.passport_cash[fname] = None

                        if fname not in good: good.append(fname)
                    except:
                        errn.append("'%s','%s','%s','%s'" % (i.num, i.code, i.name, '-' if i.sertfile is None else i.sertfile))
                        continue

                if errn: ret['warning'] = ["Не найден паспорт<br/>%s" % i for i in errn]


                goods = u','.join("'%s'" % i for i in good)
                errns = u','.join(u"[%s]" % i.decode('utf8') for i in errn)

                cmd = u'''var fn=[%s]; var er=[%s];
    
                    self.Incunable(function(doc){                
                        for(var i in fn){
                            doc.write('<img width="%s" height="%s" src="/warehouse/printpassport/data/image?mode=1&fname='+fn[i]+'">');
                        }
                        
                        if(!!(fn.length %% 2)){
                            doc.write('<div style="height:600px;"><br/></div>');
                        }                    
                        
                        if(er.length){
                            doc.write('<br/><br/><div>Не найдены паспорта качества:</div><table style="border:1 solid #000;">');
                            
                            var hd=['N','Партия','Код','Товар','Паспорт'];
                            doc.write('<tr>');
                            for(var i in hd)
                                doc.write('<td style="border-bottom:1 solid #888; border-right:1 solid #000;">'+hd[i]+'</td>');
                            doc.write('</tr>');
                                                
                            for(var i in er){
                                doc.write('<tr>');
                                doc.write('<td style="padding:3px; border-bottom:1 solid #888; border-right:1 solid #000;">'+(1+parseInt(i))+'</td>');
                                for(var j in er[i])
                                    doc.write('<td style="border-bottom:1 solid #888; border-right:1 solid #000;">'+er[i][j]+'</td>');
                                doc.write('</tr>');
                            }                        
                            doc.write('</table>');                        
                        }               
                    });''' % (goods, errns, int(3.47 * w), int(3.47 * h))

                ret['cmd'] = cmd.encode('utf8')
                self.write(ret)

                return 
            # Паспорта качества
            elif mode == 1:
                
                sql = '''SELECT distinct p.num, t.name, v.category,
                                tsclad.getpartysertfile(p.party, %s) sertfile,
                                SUBSTR(isclad.GetTovarCodeFromModify(t.id), 1, 25) code
                         FROM factura f
                         JOIN tovar t ON f.tovar = t.id
                         LEFT JOIN recordp r on f.id = r.factura
                         JOIN party p on r.party=p.party
                         LEFT JOIN type_tovar v ON t.typet=v.id
                         WHERE f.header = %s AND v.CATEGORY<>5
                         ORDER BY category, name''' % (self.session.rc, head)

                res = self.execute(sql)
                good = fetchall_by_name(res)

          
                
                all_passports = []

                index = 1

                for item in good:
                    name = item["sertfile"]
                    if not name: continue
                    
                    new_passport = Passport()

                    new_passport.index = index

                    new_passport.category = item["category"]
                    new_passport.code     = item["code"]
                    new_passport.num      = item["num"]
                    
                    new_passport.name  = name
                    new_passport.value = urllib.quote(name.decode('utf-8').encode('koi8-r'))


                    new_passport.exist = self.is_exists(new_passport.value)

                    if not new_passport.exist:
                        index = index + 1

                    all_passports.append(new_passport)

                                                    
                
                loader = template.Loader(TEMPLATE_DIR)

                #all_passports[-1].exist = False    #just for testing..


                RC_IP = '192.168.0.1'
                if self.request.remote_ip in ["80.89.129.114", "127.0.0.1", "::1"]:
                    RC_IP = IMAGES_SERVER_IP

                results = loader.load("printpassport.html").generate(remote_ip=self.request.remote_ip, RC_IP=RC_IP, all_passports=all_passports, width=str(int(3.47 * w)), uniq=random.random())

                self.write(results)
                return

                
            # Отгрузочные этикетки
            elif mode == 2:
                
                d = []
                
                try:
                    d = [int(i) for i in inp.d.split(',') if not i is None]
                    d.sort()
                except:
                    pass

                if len(d):
                    # self.write( print_boxass(user=None, m_factura=head, m_start=m_start, m_end=m_end) )
                    
                    self.write({'error':'Печать отключена'})
                    return
                    # self.write({'info':'В разработке'})
                else:
                    self.write({'error':'Неверные параметры'})


        elif param == 'image':
            try: mode = int(inp.mode)
            except: raise HTTPError(404)

            logging.info('Printing image')
            
            
            # Накладная
            if mode == 0:
                self.write({'info':'В разработке'})
                

             # Паспорта качества
            elif mode == 1:

                self.write({'info':'В разработке'})

                '''
                try:
                    imgdata = cStringIO.StringIO()

                    logging.info("Before: %s", inp.fname)
                    fname = os.path.join(SHIVA_PASSPORT, urlparse.unquote(inp.fname).decode('utf8'))
                    im = Image.open(fname).rotate(270).resize(mm2pix((w, h,)), Image.ANTIALIAS).filter(ImageFilter.SHARPEN)


                    im.save(imgdata, format='jpeg')
                    imgdata.seek(0)
                    self.write(imgdata.read())

                    self.set_header("Content-Type", "image/jpeg")
                except Exception, e:
                    logging.error(e)
                    raise HTTPError(404)
                '''

                return                

            # Отгрузочные этикетки
            elif mode == 2:
                self.write({'info':'В разработке'})

            # Упаковочный лист
            elif mode == 3:
                self.write({'info':'В разработке'})

            # Сборочные
            elif mode == 4:
                try:depart = int(inp.depart)
                except:depart = 0

                try:
                    self.write(assembly_bar_label(ListAssembly.get(depart=depart, header=head).id))
                    self.set_header("Content-Type", "image/svg+xml")
                except:
                    raise HTTPError(404)
Example #27
0
File: openday.py Project: uve/shiva
    def post(self):
        # TODO: добавить оповещение о смене роли ->
        # msg = {'TYPE':'W', 'TEXT': 'Роль измененена. Повторите процедуру входа'}
        # self.application.sessions.add_message(uid, True, msg)
        # self.application.sessions.add_message(uid, False, msg)

        inp = self.input(period=0, tsmen=0)

        try:
            period = int(inp.period)
            del inp['period']
            tsmena = int(inp.tsmen)
            del inp['tsmen']

            if not period:
                p = Period()
                p.tsmena = tsmena
                p.save()
                period = p.id

                x = RoleHistory()
                x.sotrud = self.session.sid
                x.period = period
                x.role = 5
                x.save()
            else:
                p = Period.get(id=period)
                if p.tsmena <> tsmena:
                    p.tsmena = tsmena
                    p.save()

            # явно подключаем начальника смены.
            # защита от роли Администратор и случайного удаления Начальника смены
            sql = 'SELECT count(*) cn FROM sw_role_history WHERE role=5 AND period = :period'
            if not Executor.exec_cls(sql, multi=False, period=p.id).cn:
                inp[str(self.session.uid)] = '5'

            nir = []  # юзеры не в смене
            for user_id, role_id in inp.items():

                try:
                    user_id = int(user_id)
                except ValueError:
                    continue

                try:
                    role_id = int(role_id)
                except ValueError:
                    try:
                        role_id = User.get(id=user_id).current_role_cls.id
                    except:
                        continue

                if not role_id:
                    nir.append(user_id)
                else:
                    # завершаем текущую роль в смене
                    sql = '''UPDATE sw_role_history
                             SET role_end = SYSDATE
                             WHERE role_end IS NULL
                               AND period=:period 
                               AND sotrud=:sotrud
                               AND role<>:role'''
                    Executor.exec_sql(sql,
                                      period=period,
                                      sotrud=user_id,
                                      role=role_id)

                    # добавляем юзера в смену (если еще нету там)
                    sql = '''MERGE INTO sw_role_history
                             USING DUAL ON (sotrud=:sotrud AND 
                                            period=:period AND 
                                            role_end is NULL AND 
                                            role=:role)
                             WHEN NOT matched THEN INSERT(sotrud,  period,  role_begin, role)
                                                   VALUES(:sotrud, :period, SYSDATE,   :role)'''
                    Executor.exec_sql(sql,
                                      period=period,
                                      sotrud=user_id,
                                      role=role_id)

            # выкидываем юзеров из смены
            if nir:
                sql = '''UPDATE sw_role_history
                         SET role_end = SYSDATE
                         WHERE role_end IS NULL AND sotrud IN (%s)''' % (
                    ','.join(str(i) for i in nir))
                Executor.exec_sql(sql)

            self.write({'info': 'Информация сохранена'})
        except:
            self.write({'warning': 'Ошибка записи'})
Example #28
0
    def post(self):
        inp = self.input(alist=0, idd=0, bar='', cnt=0, num=0, mas=0)

        try:
            idd = int(inp.idd)
        except:
            idd = 0

        try:
            if idd:
                # удаляем из упаковки
                Executor.exec_sql('DELETE FROM packlist WHERE id= :idd',
                                  idd=idd)
                self.write({'info': 'Информация сохранена'})
            else:
                # добавляем в упаковку
                try:
                    alist = int(inp.alist)
                except:
                    alist = 0
                try:
                    bar = inp.bar
                except:
                    bar = ''
                try:
                    cnt = float(inp.cnt)
                except:
                    cnt = 0.0
                try:
                    num = int(inp.num)
                except:
                    num = 0
                try:
                    mas = float(inp.mas)
                except:
                    mas = 0.0

                ret = self.cursor.var(cx_Oracle.NUMBER)
                self.execute(
                    'begin shiva.AddPackList(:alist, :bar, :cnt, :num, :mas, 0, :ret); end;',
                    alist=alist,
                    bar=bar,
                    cnt=cnt,
                    num=num,
                    mas=mas,
                    ret=ret)

                r = ret.getvalue()
                if r == -0:
                    self.write({'info': 'Информация сохранена'})
                elif r == -1:
                    self.write({'warning': 'Товара не существует'})
                elif r == -3:
                    self.write({'warning': 'В заказе нет такого продукта'})
                elif r == -4:
                    self.write({'warning': 'Количество превышает заказ'})
                else:
                    self.write({'warning': 'Чета не так - %s' % r})

        except:
            self.write({'warning': 'Ошибка записи'})
Example #29
0
 def post(self):
     try:
         Executor.kill(self.input(id='').id)
         self.write({'info':'OK'})
     except:
         self.write({'warning':'Ошибка записи'})
Example #30
0
File: openday.py Project: uve/shiva
    def post(self):
        # TODO: добавить оповещение о смене роли ->
        # msg = {'TYPE':'W', 'TEXT': 'Роль измененена. Повторите процедуру входа'}
        # self.application.sessions.add_message(uid, True, msg)
        # self.application.sessions.add_message(uid, False, msg)

        inp = self.input(period=0, tsmen=0)

        try:
            period = int(inp.period)
            del inp['period']
            tsmena = int(inp.tsmen)
            del inp['tsmen']

            if not period:
                p = Period()
                p.tsmena = tsmena
                p.save()
                period = p.id

                x = RoleHistory()
                x.sotrud = self.session.sid
                x.period = period
                x.role = 5
                x.save()
            else:
                p = Period.get(id=period)
                if p.tsmena <> tsmena:
                    p.tsmena = tsmena
                    p.save()

            # явно подключаем начальника смены.
            # защита от роли Администратор и случайного удаления Начальника смены
            sql = 'SELECT count(*) cn FROM sw_role_history WHERE role=5 AND period = :period'
            if not Executor.exec_cls(sql, multi=False, period=p.id).cn:
                inp[str(self.session.uid)] = '5'

            nir = []  # юзеры не в смене
            for user_id, role_id in inp.items():                
                
                try: user_id = int(user_id)
                except ValueError: continue                

                try: role_id = int(role_id)
                except ValueError:
                    try:
                        role_id = User.get(id=user_id).current_role_cls.id
                    except:
                        continue

                if not role_id:
                    nir.append(user_id)
                else:
                    # завершаем текущую роль в смене
                    sql = '''UPDATE sw_role_history
                             SET role_end = SYSDATE
                             WHERE role_end IS NULL
                               AND period=:period 
                               AND sotrud=:sotrud
                               AND role<>:role'''
                    Executor.exec_sql(sql, period=period, sotrud=user_id, role=role_id)

                    # добавляем юзера в смену (если еще нету там)
                    sql = '''MERGE INTO sw_role_history
                             USING DUAL ON (sotrud=:sotrud AND 
                                            period=:period AND 
                                            role_end is NULL AND 
                                            role=:role)
                             WHEN NOT matched THEN INSERT(sotrud,  period,  role_begin, role)
                                                   VALUES(:sotrud, :period, SYSDATE,   :role)'''
                    Executor.exec_sql(sql, period=period, sotrud=user_id, role=role_id)

            # выкидываем юзеров из смены
            if nir:
                sql = '''UPDATE sw_role_history
                         SET role_end = SYSDATE
                         WHERE role_end IS NULL AND sotrud IN (%s)''' % (','.join(str(i) for i in nir))
                Executor.exec_sql(sql)

            self.write({'info':'Информация сохранена'})
        except:
            self.write({'warning':'Ошибка записи'})
Example #31
0
 def post(self):
     try:
         Executor.kill(self.input(id='').id)
         self.write({'info': 'OK'})
     except:
         self.write({'warning': 'Ошибка записи'})
Example #32
0
File: boxass.py Project: uve/shiva
    def print_boxass(self,
                     user=None,
                     m_factura=None,
                     m_start=None,
                     m_end=None):
        # TODO: Аленина функция проверки необходимости печати

        isp = 1

        m_name = ""

        if user:

            result = self.func('shiva.GetNeedLabel',
                               returnType=cx_Oracle.NUMBER,
                               parameters=[user.id])
            isp = int(result)

            sql = '''SELECT MIN(m_start) f, MAX(m_end) l, factura
                     FROM packlist 
                     WHERE sotrud=(SELECT sotrud FROM sotrud WHERE id = :sid)
                       AND dend IS NULL
                    GROUP BY factura'''

            x = Executor.exec_cls(sql, multi=False, sid=user.id)

            try:
                m_start = x.f
                m_end = x.l
                m_factura = x.factura
                m_name = user.name
            except:
                pass

        if m_factura and isp == 1:
            return {
                'info':
                m_name,
                'precmd':
                'self.InitContent();',
                'def': [
                    '<div id="sw_mess" style="padding:10px;">Фактура: %s, места: %s..%s</div>'
                    % (m_factura, m_start, m_end)
                ],
                'cmd':
                '''var urs=[%s,%s];
                            for(i=%s; i<=%s; i++)
                                urs.push("/group/boxass/data?factura=%s&position="+i +"&time="+new Date().getTime() );
                            self.PrintURL.apply(self, urs);   
                                                
                            setTimeout(function(){ self.Refresh() }, 3000);
                        ''' % (box_label_size[0], box_label_size[1], m_start,
                               m_end, m_factura)
            }

        elif isp == 0:
            return {
                'info':
                m_name,
                'precmd':
                'self.InitContent();',
                'def': [
                    '<div id="sw_mess" style="padding:10px;"> Тип  оклейки  не покоробочный, печати отгрузочных этикеток не требуется</div>'
                ],
                'cmd':
                'setTimeout(function(){ self.Refresh() }, 2000);'
            }

        else:
            return {
                'info':
                m_name,
                'precmd':
                'self.InitContent();',
                'def': [
                    '<div id="sw_mess" style="padding:10px;">Печать не нужна</div>'
                ],
                'cmd':
                'setTimeout(function(){ self.Refresh() }, 2000);'
            }