Commit a96c8281 authored by Malcolm Blaney's avatar Malcolm Blaney

Cart module can now be used on multiple pages, with different items

and ordering shown on each page. Also added search match updates to
Simple module history table.
parent 20cb2649
This diff is collapsed.
......@@ -28,7 +28,7 @@ if(!this.dobrado.cart){dobrado.cart={};}
(function(){'use strict';var cart={};var settings=null;var editor=null;var itemIndex=0;var shippingIndex=0;var browserTarget="";$(function(){if(dobrado.localStorage()){if(localStorage.cart){cart=JSON.parse(localStorage.cart);cartMiniTotal();}}
if($(".cart").length===0){return;}
checkDownloads();$(".cart-item .item-add").button().click(cartAdd);$(".cart-item .item-quantity").val("0");$(".cart-item .item-quantity").spinner({min:0,spin:cartQuantity,change:cartQuantity});$("#cart-checkout").button({disabled:true}).click(checkout);$("#customer-detail-submit").button().click(customerDetail);$(".cart-item .item-name a").click(cartItem);if($(".cart-payment-message").html()!==""){$(".cart-payment-message button").button().click(paymentDone);$(".cart-payment-message").dialog({modal:true,position:{my:"top",at:"top+50",of:"body"},title:"Payment",width:400,height:200,close:paymentDone});}
$("#cart-checkout-dialog").dialog({autoOpen:false,modal:true,position:{my:"top",at:"top+50",of:"body"},title:"Checkout",width:500,height:500});$("#cart-editor").dialog({autoOpen:false,close:close,position:{my:"top",at:"top+50",of:"body"},title:"Cart Editor",width:760,height:500});$("#cart-item-dialog").dialog({autoOpen:false,position:{my:"top",at:"top+50",of:"body"},title:"Cart Item",width:700,height:500});$("#cart-edit-button").button({icons:{primary:"ui-icon-pencil"},text:false}).click(cartEditor);$("#cart-total").html(cartTotal());$.each(cart,function(name,item){var id=item.id;if(id){var count=id.match(/([0-9]+)$/);if(item.selected&&count&&count.length===2){$("#"+id+" .item-add").button({label:"Remove from cart"});$("#item-quantity-"+count).spinner("value",item.quantity);}}});});function checkDownloads(){$(".cart-download-list li").each(function(i){var file=$(this).html();setTimeout(function(){location.href="/php/download.php?file="+file;},i*10000);});}
$("#cart-checkout-dialog").dialog({autoOpen:false,modal:true,position:{my:"top",at:"top+50",of:"body"},title:"Checkout",width:500,height:500});$("#cart-editor").dialog({autoOpen:false,close:close,position:{my:"top",at:"top+50",of:"body"},title:"Cart Editor",width:760,height:500});$("#cart-item-dialog").dialog({autoOpen:false,position:{my:"top",at:"top+50",of:"body"},title:"Cart Item",width:700,height:500});$("#cart-edit-button").button({icons:{primary:"ui-icon-pencil"},text:false}).click(cartEditor);$("#cart-total").html(cartTotal());$.each(cart,function(name,item){var id=item.id;if(id){var name=id.match(/^cart-item-id-(.+)$/);if(item.selected&&name&&name.length===2){$("#"+id+" .item-add").button({label:"Remove from cart"});$("#item-quantity-"+name[1]).spinner("value",item.quantity);}}});});function checkDownloads(){$(".cart-download-list li").each(function(i){var file=$(this).html();setTimeout(function(){location.href="/php/download.php?file="+file;},i*10000);});}
function cartPrice(item){var price=0;var checkMinimum=false;if(item.attr("id")){price=item.val();checkMinimum=true;}
else{price=item.html();}
var fields=price.match(/([0-9.]+)$/);if(fields&&fields.length===2){price=parseFloat(fields[1]);}
......
......@@ -113,10 +113,10 @@ if (!this.dobrado.cart) {
$.each(cart, function(name, item) {
var id = item.id;
if (id) {
var count = id.match(/([0-9]+)$/);
if (item.selected && count && count.length === 2) {
var name = id.match(/^cart-item-id-(.+)$/);
if (item.selected && name && name.length === 2) {
$("#" + id + " .item-add").button({ label: "Remove from cart" });
$("#item-quantity-" + count).spinner("value", item.quantity);
$("#item-quantity-" + name[1]).spinner("value", item.quantity);
}
}
});
......
......@@ -238,11 +238,21 @@ class Simple extends Base {
public function UpdateMatches($old, $new, $group) {
$mysqli = connect_db();
// Add the new content to history first, so that it can be matched against
// the existing content.
$query = 'INSERT INTO simple_module_history (user, box_id, content, '.
'timestamp, modified_by) SELECT simple_module.user, box_id, "'.$new.'", '.
time().', "'.$this->user->name.'" FROM simple_module LEFT JOIN users ON '.
'simple_module.user = users.user WHERE content = "'.$old.'" AND '.
'users.system_group = "'.$group.'"';
if (!$mysqli->query($query)) {
$this->Log("Simple->UpdateMatches 1: ".$mysqli->error);
}
$query = 'UPDATE simple_module LEFT JOIN users ON '.
'simple_module.user = users.user SET content = "'.$new.'" WHERE '.
'content = "'.$old.'" AND users.system_group = "'.$group.'"';
if (!$mysqli->query($query)) {
$this->Log("Simple->UpdateMatches: ".$mysqli->error);
$this->Log("Simple->UpdateMatches 2: ".$mysqli->error);
}
$mysqli->close();
return array("done" => true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment