Exemplo n.º 1
0
def add_to_downloadpopup(request):
	print "inside add_to_downloadpopup ^^^^^^^^^^^^^^^^^"

	dajax = Dajax()

	if isinstance(request.user,Reseller) and request.user.user_type == 'R':

		dajax.assign('#download-items', 'innerHTML', '')

		if 'download' in request.session:

			print "inside the Add to Popup"

			download_list = request.session['download']

			print "Download List###########",download_list

			if download_list:
				dajax.assign('#download-count', 'innerHTML',
						 '''<span class="download_count download_delay_hover circle">{0}</span>'''.format(len(download_list)))
				
				for download_item in download_list:

					product = Product.objects.get(id=int(download_item['id']))

					dajax.append('#download-items','innerHTML', '''
						<tr id="downid_{5}" class="downloadItemsRow" >
							<td class="downloaded_pro_name">
								<div class="downloaded_thumb"><a href="/product-detail/{2}"><img src="{0}"
								alt="{1}" class=""></a></div>
							</td>

							<td class="downloaded_pro_name">
								<a href="javascript:;" alt="download"><span>{1}</span></a>
								<label class="item_upc_code"><a href="/product-detail/{2}" alt="item_upc_code"><span>{3}</span></a><label>
							</td>

							<td class="downloaded_pro_name">
								<a href="javascript:;" alt="download"><span>{4}</span></a>
							</td>
							<td class="downloaded_pro_name">
								<span style="cursor:pointer" onclick="RemoveDownload_Item({5})" title="Remove"><i class="fa fa-remove"> Remove</i></span>
							</td>
						</tr>'''.format(product.prod_f_photo()[0], product.name, product.slug, product.upc, format(product.network_price,'.2f'),product.id))
			else:
				dajax.assign('#download-count', 'innerHTML',
						 '''<span class="download_count download_delay_hover circle">{0}</span>'''.format(len(download_list)))
				dajax.assign(
					'#download-items', 'innerHTML', '''<tr class="" >
							<td class="downloaded_pro_name">
								<a href="" alt="download"><span>Currently no items for downloading..!</span></a>
							</td> </tr>''')

		return dajax.json()
Exemplo n.º 2
0
def get_discount(request,product):
	dajax = Dajax()

	product = get_object_or_404(Product, id=int(product))

	dajax.assign('#discount_rows', 'innerHTML', '')

	discounts = product.discount.all().order_by('-id')

	if discounts:
		for counter,discount in enumerate(discounts):

			if discount.is_active():
				dajax.append('#discount_rows', 'innerHTML','''
					<tr id="dis{5}">
						<td>{0}</td>
						<td>{1}</td>
						<td>{2}%</td>
						<td>{3}</td>

						<td>{4}</td>

						<td><a class="btn btn-success btn-icon btn-circle"><i class="fa fa-check"></i></a></td>

						<td>
							<button type="button" onclick="DeleteDiscount({5});" class="btn btn-sm btn-warning"><i class="fa fa-trash"></i> Delete</button>
						</td>
					</tr>

					'''.format(counter+1,discount.name,discount.discount,discount.effe_date.strftime("%d %b %Y"),discount.expi_date.strftime("%d %b %Y"),discount.id))
			else:
				dajax.append('#discount_rows', 'innerHTML','''
					<tr id="dis{5}">
						<td>{0}</td>
						<td>{1}</td>
						<td>{2}%</td>
						<td>{3}</td>

						<td>{4}</td>

						<td><a class="btn btn-danger btn-icon btn-circle"><i class="fa fa-times"></i></a></td>

						<td>
							<button type="button" onclick="DeleteDiscount({5});" class="btn btn-sm btn-warning"><i class="fa fa-trash"></i> Delete</button>
						</td>
					</tr>

					'''.format(counter+1,discount.name,discount.discount,discount.effe_date.strftime("%d %b %Y"),discount.expi_date.strftime("%d %b %Y"),discount.id))

		dajax.script('ShowDiscountTable();')

	return dajax.json()
Exemplo n.º 3
0
def viewz_customer(request, cid=None):

    dajax = Dajax()
    print "inside tha ajax........"

    customer = Customer.objects.get(id=int(cid))

    dajax.assign("#man_id", "value", "")
    dajax.assign("#birth_day_id", "value", "")
    dajax.assign("#added_day", "value", "")
    dajax.assign("#download_link", "innerHTML", "")
    dajax.assign("#phone_numbers", "innerHTML", "")
    dajax.assign("#custmor_name", "innerHTML", "")

    dajax.assign("#man_id", "value", "{0}".format(customer.name))
    dajax.assign("#birth_day", "value", "{0}".format(customer.birth_date))
    dajax.assign("#added_day", "value", "{0}".format(customer.date))
    dajax.append(
        "#download_link",
        "innerHTML",
        """<label>Download link</label><a href="{0}" download>click here</a>""".format(customer.policy),
    )
    dajax.append("#custmor_name", "innerHTML", """<span>{0}</span>""".format(customer.name))
    count = 0
    for phone in customer.phone.all():
        count += 1
        dajax.append(
            "#phone_numbers",
            "innerHTML",
            """<label>Phone Number {1}</label><input type="text" class="form-control" value="{0}" id="phone_numbers">""".format(
                phone.phone_no, count
            ),
        )

    dajax.script("viewcutomer_modal();")

    return dajax.json()