Пример #1
0
def upload_document(request):

    if request.method == 'POST':
        form = DocumentUploadForm(request.POST,request.FILES)
        if form.is_valid():
            doc = form.save(commit=False)
            doc.file = request.FILES['file']
            doc.upload_user = request.user
            doc.upload_date = datetime.datetime.now()
            doc.save()
            return redirect('/dms/list_documents/')
        else:
            return render_response(request, 'dms/upload_document.html',{'form':form})
    else:
        return render_response(request, 'dms/upload_document.html',{'form':DocumentUploadForm()})
Пример #2
0
def list_documents(request):
    return render_response(request, 'dms/list_documents.html',
            {
                'docList':Document.objects.order_by('-upload_date'),
                'statusList':DocumentStatus.TYPE,
                'typeList':DocumentType.objects.all().order_by('order')
            })
Пример #3
0
def list_shipment(request):
    shipmentList = Shipment.objects.all().order_by("-create_date")
    return render_response(request, 'sms/list_shipment.html',
            {
            'shipmentList':shipmentList,
            'totalShipmentItemCount':getTotalShipmentItemCount(request),
            })
Пример #4
0
def home_order_management(request):
    dict = {
        'statusList':rts_status.TYPE,
        'reasonList':ReturnReason.objects.all().order_by("order"),
        'status':request.POST.get('statusFilter',rts_status.RETURNED)
    }

    start_date = datetime.now() - timedelta(days = 3)
    start_date = datetime.combine(start_date, time.min)

    end_date = datetime.now()
    if "dateStart" in request.POST:
        start_date = datetime.strptime(request.POST['dateStart'], "%m/%d/%Y")
    if "dateEnd" in request.POST:
        end_date = datetime.strptime(request.POST['dateEnd'], "%m/%d/%Y")
        end_date = datetime.combine(end_date, time.max)

    dict.update({ 'start_date':start_date})
    dict.update({ 'end_date':end_date,})

    oibfr_list = OrderItemBaseForReturns.objects.filter(returneditemdetails__status=rts_status.RETURNED,returneditemdetails__create_date__range = [start_date, end_date])
    dict.update({'oibfr_list':oibfr_list})

    if request.method == 'POST':
        status = request.POST.get('statusFilter','')
        try:
            dict.update({'oibfr_list': OrderItemBaseForReturns.objects.filter(returneditemdetails__status=int(status),returneditemdetails__create_date__range = [start_date, end_date])})
        except:
            dict.update({'oibfr_list': OrderItemBaseForReturns.objects.filter(returneditemdetails__create_date__range = [start_date, end_date])})

    return render_response(request, 'rts/home_order_management.html',dict)
Пример #5
0
def document_action(request):

    docList = request.POST.getlist('docChecked')
    if not len(docList) or "buttonSource" not in request.POST:
        return redirect('/dms/list_documents/')

    action = request.POST['buttonSource']
    if action == "update":
        for did in docList:
            s = request.POST.get("statusUpdate",None)
            if s is not None:
                d = Document.objects.get(pk=did)
                d.update_date = datetime.datetime.now()
                d.update_user = request.user
                d.status = int(s)
                d.save()
    elif action == "delete":
        for did in docList:
            d = Document.objects.get(pk=did)
            #fname = d.file.name
            d.delete()
            #os.unlink(MEDIA_ROOT+fname)
            
    return render_response(request, 'dms/list_documents.html',
            {
                'docList':Document.objects.order_by('-upload_date'),
                'statusList':DocumentStatus.TYPE
            })
Пример #6
0
def list_invoice(request):

    start_date = datetime.datetime.now() - datetime.timedelta(days = 7)
    start_date = datetime.datetime.combine(start_date, datetime.time.min)

    end_date = datetime.datetime.now()

    try:
        transactionID = request.GET["transaction"]
        transaction = Transactions.objects.get(pk = int(transactionID))
        invoiceList = InvoiceInfoForTransactions.objects.all().filter(trans = transaction)
    except:
        if "dateStart" in request.POST:
            start_date = datetime.datetime.strptime(request.POST['dateStart'], "%m/%d/%Y")
        if "dateEnd" in request.POST:
            end_date = datetime.datetime.strptime(request.POST['dateEnd'], "%m/%d/%Y")
            end_date = datetime.datetime.combine(end_date, datetime.time.max)

        invoiceList = InvoiceInfoForTransactions.objects.order_by('-create_date')
        invoiceList = invoiceList.filter(create_date__range = [start_date, end_date])

    return render_response(request, 'cross_order/list_invoice.html',
            {
            'invoiceList':invoiceList,
            'start_date':start_date,
            'end_date':end_date,
            'invoiceTypeList':InvoiceType.objects.all().order_by("order"),
            'invoiceCurrencyList':InvoiceCurrency.objects.all().order_by("order"),
            })
Пример #7
0
def view_basket(request):
    shipment = request.session.get("shipment",None)
    siList = request.session.get("siList",[])
    return render_response(request, 'sms/view_basket.html',
            {
            'shipment':shipment,
            'siList':siList,
            'shipmentTypeList':ShipmentType.objects.all().order_by("order"),
            'totalShipmentItemCount':getTotalShipmentItemCount(request)
        })
Пример #8
0
def list_catalog_simple(request):
    if request.method == 'POST' and request.POST["sid"]!= '-1':
        sup = None
        csList = CatalogSimple.objects.all()
        if "sid" in request.POST and CatalogSupplier.objects.filter(pk=request.POST["sid"]).count():
            sup = CatalogSupplier.objects.get(pk=request.POST["sid"])
            csList = CatalogSimple.objects.filter(supplier=sup,status_simple = SimpleStatus.ACTIVE, status_config = SimpleStatus.ACTIVE, id_shipment_type = SimpleShipmentTypeID.ON_WAREHOUSE, brand__status = BrandStatus.ACTIVE)

        return render_response(request, 'sms/list_catalog_simple.html',
                {
                'supplier':sup,
                'csList':csList,
                'supList':CatalogSupplier.objects.filter( status = SupplierStatus.ACTIVE).order_by('name'),
                'totalShipmentItemCount':getTotalShipmentItemCount(request)
            })
    else:

        return render_response(request, 'sms/list_catalog_simple.html',
                {
                'supList':CatalogSupplier.objects.filter( status = SupplierStatus.ACTIVE).order_by('name'),
                'totalShipmentItemCount':getTotalShipmentItemCount(request)
            })
Пример #9
0
def home_warehouse(request):
    suborder_nr = request.GET.get('suborder_nr','')

    dict = {
        'actionList':ActionType.objects.all().order_by("order"),
        'reasonList':ReturnReason.objects.all().order_by("order"),
        'suborder_nr':suborder_nr
    }

    if request.method == 'GET' and suborder_nr != '':
        dict.update({'oibfr_list': OrderItemBaseForReturns.objects.filter(suborder_number__icontains=suborder_nr)})
        
    return render_response(request, 'rts/home_warehouse.html',dict)
Пример #10
0
def home(request):
    err_message = ""
    err_module = request.GET.get("err_module",None)
    if err_module is not None:
        if err_module == "Cross":
            err_message = "Cross Order Management: "
        elif err_module == "RtsWarehouse" or err_module == "RtsCustomer" :
            err_message = "Returned Item Tracking System: "
        elif err_module == "dms":
            err_message = "Document Management System: "

        err_message += str(_("dont_have_permission_for_module"))

    return render_response(request, 'home.html',{'err_message':err_message})
Пример #11
0
def list_supplier(request):

    start_date = datetime.datetime.now() - datetime.timedelta(days = 15)
    start_date = datetime.datetime.combine(start_date, datetime.time.min)

    end_date = datetime.datetime.now()
    if "dateStart" in request.POST:
        start_date = datetime.datetime.strptime(request.POST['dateStart'], "%m/%d/%Y")
    if "dateEnd" in request.POST:
        end_date = datetime.datetime.strptime(request.POST['dateEnd'], "%m/%d/%Y")
        end_date = datetime.datetime.combine(end_date, datetime.time.max)

    oa = None
    cs = CrossStatus.objects.all().order_by("order")[0]
    supList = []

    try:
        oa = OrderAttributeSet.objects.get(pk = int(request.POST['attributeFilter']))
        for s in Supplier.objects.all().order_by("name"):
            if s.order_set.filter(order_date__range=[start_date, end_date],ordercrossdetails__order_attribute = oa.attributeCode).count() >0:
                s.unprocessedCount = s.order_set.filter(ordercrossdetails__cross_status=cs,ordercrossdetails__order_attribute = oa.attributeCode,order_date__range=[start_date, end_date]).count()
                s.totalCount = s.order_set.filter(ordercrossdetails__order_attribute = oa.attributeCode,order_date__range=[start_date, end_date]).count()
                supList.append(s)
    except:
        for s in Supplier.objects.all().order_by("name"):
            if s.order_set.filter(order_date__range=[start_date, end_date]).count() >0:
               s.unprocessedCount = s.order_set.filter(ordercrossdetails__cross_status=cs,order_date__range=[start_date, end_date]).count()
               s.totalCount = s.order_set.filter(order_date__range=[start_date, end_date]).count()
               supList.append(s)

#   below is the older version of filtering suppliers
#    for s in Supplier.objects.all().order_by("name"):
#        if s.order_set.filter(order_date__range=[start_date, end_date]).count() >0:
#            s.unprocessedCount = s.order_set.filter(ordercrossdetails__cross_status=cs,order_date__range=[start_date, end_date]).count()
#            s.totalCount = s.order_set.filter(order_date__range=[start_date, end_date]).count()
#            supList.append(s)


    return render_response(request, 'cross_order/list_supplier.html',
            {
                'supList':supList,
                'start_date':start_date,
                'end_date':end_date,
                'attributeList':OrderAttributeSet.objects.all().order_by("order"),
                'oattribute':oa
            })
Пример #12
0
def list_order(request):

    if "sid" not in request.GET or Supplier.objects.filter(pk=request.GET["sid"]).count() == 0 :
        return redirect('/cross_order/list_supplier/')

    cs = None
    oa = None
    try:
        cs = CrossStatus.objects.get(pk = int(request.GET['cstatus']))
    except:
        pass

    try:
        oa = OrderAttributeSet.objects.get(pk = int(request.GET['oattributeid']))
    except:
        pass

    sup = Supplier.objects.get(pk=request.GET["sid"])
    start_date = datetime.datetime.now()
    end_date = datetime.datetime.now()
    if "dateStart" in request.GET:
        start_date = datetime.datetime.strptime(request.GET['dateStart'], "%m/%d/%Y")
    if "dateEnd" in request.GET:
        end_date = datetime.datetime.strptime(request.GET['dateEnd'], "%m/%d/%Y")
        end_date = datetime.datetime.combine(end_date, datetime.time.max)


    current_url = '/cross_order/list_order/?sid='+request.GET["sid"]+"&dateStart="+request.GET['dateStart']+"&dateEnd="+request.GET['dateEnd']+'&cstatus='
    orderList = sup.order_set.filter(order_date__range=(start_date,end_date))
    if cs is not None:
        orderList = orderList.filter(ordercrossdetails__cross_status=cs)
    if oa is not None:
        orderList = orderList.filter(ordercrossdetails__order_attribute = oa.attributeCode)

    return render_response(request, 'cross_order/list_order.html',
            {
                'supplier':sup,
                'start_date':start_date,
                'end_date':end_date,
                'orderList':orderList,
                'crossStatusList':CrossStatus.objects.all().order_by("order"),
                'current_url':current_url,
                'cstatus':cs,
                'oattribute':oa,
            })
Пример #13
0
def transaction_details(request,code):
    cs = None
    try:
        cs = CrossStatus.objects.get(pk = int(request.GET['cstatus']))
    except:
        pass

    orderList = OrderTransaction.objects.filter(trans__code=code)
    if cs is not None:
        orderList = orderList.filter(order__ordercrossdetails__cross_status=cs)

    return render_response(request, 'cross_order/list_transaction_details.html',
            {
                'orderTransactionList': orderList,
                'crossStatusList':CrossStatus.objects.all().order_by("order"),
                'code':code,
                'cstatus':cs,
                'trans':Transactions.objects.get(code=code)
            })
Пример #14
0
def cancel_item(request):
    oii = request.GET.get('order_item_id','')   #order item id

    dict = {
        'reasonList':CancelReason.objects.all().order_by("order"),
        'suborder_nr':oii
    }

    if request.method == 'GET' and oii != '':
        cri = request.GET.get('cancelReason','')
        oib = OrderItemBaseForCancellation.objects.get(id_sales_order_item = int(oii) )
        cr = CancelReason.objects.get(pk = int(cri) )
        cid = CancelItemDetails()
        cid.order_item = oib
        cid.cancel_reason = cr
        cid.create_user = request.user
        cid.create_date = datetime.now()
        cid.save()

    return render_response(request, 'cts/home_cancellation.html',dict)
Пример #15
0
def view_shipment(request):
    sid = request.GET.get("sid",None)
    if sid is  None or Shipment.objects.filter(pk=sid).count() == 0:
        return redirect("/sms/list_shipment/")

    shipment = Shipment.objects.get(pk=sid)
    siList = ShipmentItem.objects.filter(shipment=shipment)

    date = shipment.proposed_shipment_date
    shipments = Shipment.objects.filter(Q(proposed_shipment_date = date) & Q(status = 1) )
    total_item = 0
    for s in shipments:
        total_item = total_item + s.totalShipmentItemCount

    return render_response(request, 'sms/view_shipment.html',
            {
            'shipment':shipment,
            'siList':siList,
            'totalShipmentItemCount':getTotalShipmentItemCount(request),
            'cancelTypeList' :CancellationReason.objects.all().order_by("order"),
            'total' : total_item,
            })
Пример #16
0
def cancel_mass(request):

    dict = {
        'reasonList':CancelReason.objects.all().order_by("order")
    }

    if request.method == 'POST':
         order_item = request.POST['order_item']
         order_item_list = order_item.split("\r\n")

         for oi in order_item_list:
             oi = oi.lstrip().rstrip()
             cri = request.POST.get('cancelReason')
             oib = OrderItemBaseForCancellation.objects.get(id_sales_order_item = int(oi) )
             cr = CancelReason.objects.get(pk = int(cri) )
             cid = CancelItemDetails()
             cid.order_item = oib
             cid.cancel_reason = cr
             cid.create_user = request.user
             cid.create_date = datetime.now()
             cid.save()

    return render_response(request, 'cts/mass_cancel.html',dict)
Пример #17
0
def transaction_list(request):

    status = None
    status_id = 0
    start_date = datetime.datetime.now() - datetime.timedelta(days = 14)
    start_date = datetime.datetime.combine(start_date, datetime.time.min)

    end_date = datetime.datetime.now()
    if "dateStart" in request.POST:
        start_date = datetime.datetime.strptime(request.POST['dateStart'], "%m/%d/%Y")
    if "dateEnd" in request.POST:
        end_date = datetime.datetime.strptime(request.POST['dateEnd'], "%m/%d/%Y")
        end_date = datetime.datetime.combine(end_date, datetime.time.max)
    if "statusFilter" in request.POST:
        status_id = request.POST.get('statusFilter','')
        if status_id != 'all':
            status = TransactionStatus.objects.get(pk = status_id)
        else:
            status_id = 0
            status = None

    tList = Transactions.objects.order_by('-create_date')
    if status is not None:
        tList = tList.filter(status = status,create_date__range = [start_date, end_date])
    else:
        tList = tList.filter(create_date__range = [start_date, end_date])

    return render_response(request, 'cross_order/list_transaction.html',
            {
                'transList':tList,
                'statusList':TransactionStatus.objects.all().order_by("order"),
                'status':status_id,
                'start_date':start_date,
                'end_date':end_date,
                'invoiceTypeList':InvoiceType.objects.all().order_by("order"),
                'invoiceCurrencyList':InvoiceCurrency.objects.all().order_by("order"),
            })
Пример #18
0
def import_mass(request):
    if request.method == 'POST':
        sku_simple = request.POST['sku_simple']
        sku_quantity = request.POST['sku_simple_quantity']
        sup = None
        if "sid" in request.POST and CatalogSupplier.objects.filter(pk=request.POST["sid"]).count():
            sup = CatalogSupplier.objects.get(pk=request.POST["sid"])

        shipment = Shipment()
        siList = []
        exceptionList = []

        sku_simple_list = sku_simple.split("\r\n")
        quantity_list = sku_quantity.split("\r\n")
        index = 0
        for sku in sku_simple_list:
            sku = sku.lstrip().rstrip()
            if sku == "":
                continue
            if not CatalogSimple.objects.filter(sku=sku).count():
                exception = [sku,1]
                exceptionList.append(exception)
            elif not CatalogSimple.objects.filter(sku=sku,supplier = sup).count():
                exception = [sku,2]
                exceptionList.append(exception)
            elif not CatalogSimple.objects.filter(sku=sku,supplier = sup,status_simple = SimpleStatus.ACTIVE).count():
                exception = [sku,3]
                exceptionList.append(exception)
            elif not CatalogSimple.objects.filter(sku=sku,supplier = sup,status_simple = SimpleStatus.ACTIVE,status_config = SimpleStatus.ACTIVE).count():
                exception = [sku,4]
                exceptionList.append(exception)
            elif not CatalogSimple.objects.filter(sku=sku,supplier = sup,status_simple = SimpleStatus.ACTIVE,status_config = SimpleStatus.ACTIVE,id_shipment_type = SimpleShipmentTypeID.ON_WAREHOUSE).count():
                exception = [sku,5]
                exceptionList.append(exception)
            elif not quantity_list[index].isdigit():
                exception = [sku,6]
                exceptionList.append(exception)
            elif not CatalogSimple.objects.filter(sku=sku,
                                            supplier = sup,
                                            status_simple = SimpleStatus.ACTIVE,
                                            status_config = SimpleStatus.ACTIVE,
                                            id_shipment_type = SimpleShipmentTypeID.ON_WAREHOUSE,
                                            brand__status = BrandStatus.ACTIVE).count() > 0:
                exception = [sku,7]
                exceptionList.append(exception)
            else:
                cs = CatalogSimple.objects.get(sku=sku)
                si= ShipmentItem()
                si.catalog_simple = cs
                si.quantity_ordered = int(quantity_list[index])
                si.shipment = shipment
                siList.append(si)

            index +=1

        if not exceptionList:
            request.session["shipment"] = shipment
            request.session["siList"] = siList
            return redirect('/sms/view_basket/')
        else:
            return render_response(request, 'sms/import_mass.html',
                {
                    'supList':CatalogSupplier.objects.filter( status = SupplierStatus.ACTIVE).order_by('name'),
                    'exceptionList': exceptionList ,
                    'exceptionListLength':len(exceptionList),
                    'sku_simple':request.POST['sku_simple'],
                    'sku_quantity':request.POST['sku_simple_quantity'],
                    'supplier':sup,
                    'totalShipmentItemCount':getTotalShipmentItemCount(request)
                })
    else:
        return render_response(request, 'sms/import_mass.html',
                {
                    'supList':CatalogSupplier.objects.filter( status = SupplierStatus.ACTIVE).order_by('name'),
                    'exceptionList' : [],
                    'totalShipmentItemCount':getTotalShipmentItemCount(request)
                })
Пример #19
0
def order_search(request):
    form = OrderSearchForm()
    return render_response(request, 'cross_order/order_search.html',{'form':form,'crossList':CrossStatus.objects.all(),'attributeList':OrderAttributeSet.objects.all()})
Пример #20
0
def report_list(request):
    return render_response(request, 'cross_order/report_list.html',{'report_list':ReportSql2Excel.objects.filter(isActive=True).order_by('order')})