Ukjente endringer i nettbutikken. Lagt til medlemskap 2010?
This commit is contained in:
1 parent
04a2cd9bbf
commit
08cc6c9c65
4 files changed
+96
-75
No files matched your search
+58
-41
@@ -19,7 +19,7 @@ class Order {
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
@@ -40,7 +40,7 @@ class Order {
|
||||
$this->order_status_id = $data['order_status_id'];
|
||||
$this->order_status_value = $data['order_status_value'];
|
||||
$this->comment = $data['comment'];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
//Common initializations
|
||||
@@ -50,10 +50,10 @@ class Order {
|
||||
function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_order");
|
||||
$sql = sprintf("INSERT INTO din_order
|
||||
$sql = sprintf("INSERT INTO din_order
|
||||
(id, user_id, timestamp, comment)
|
||||
VALUES
|
||||
(%s, %s, NOW(), %s)",
|
||||
VALUES
|
||||
(%s, %s, NOW(), %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->user_id),
|
||||
$this->conn->quoteSmart($this->comment)
|
||||
@@ -63,41 +63,58 @@ class Order {
|
||||
//notify("Ny ordre lagret.");
|
||||
}else {
|
||||
error("New order: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function setStatus($value) {
|
||||
$sql = "UPDATE din_order SET
|
||||
order_status_id = $value
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set status - order: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
function addOrderItem($data) {
|
||||
$data['order_id'] = $this->id;
|
||||
$data['discount'] = 0;
|
||||
$data['order_id'] = $this->id;
|
||||
$data['discount'] = 0;
|
||||
|
||||
$added = false;
|
||||
|
||||
// fetch items in order and check if item allready is in order
|
||||
$items = $this->getItems();
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
if ($item->product_id == $data['product_id']) {
|
||||
// item already exists in order, update quantity
|
||||
$item->setQuantity($item->quantity + $data[quantity]);
|
||||
$added = true;
|
||||
}
|
||||
}
|
||||
|
||||
// new product id for this order, add order item
|
||||
if (!$added) {
|
||||
$item = new OrderItem(NULL, $data);
|
||||
$item->store();
|
||||
return true;
|
||||
//$this->_updateTotalPrice();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function _updateTotalPrice(){
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
|
||||
public
|
||||
function _retrieveData(){
|
||||
$sql = "SELECT o.*, os.value AS order_status_value
|
||||
FROM din_order o, din_order_status os
|
||||
@@ -115,21 +132,21 @@ class Order {
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
/*static*/
|
||||
function delete($id){
|
||||
$order = new Order($id);
|
||||
$order->setStatus(5);
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function getItems() {
|
||||
$sql = "SELECT oi.id " .
|
||||
"FROM din_order_item oi " .
|
||||
"WHERE oi.order_id = $this->id";
|
||||
$result =& $this->conn->query($sql);
|
||||
$result =& $this->conn->query($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function calculateTotalAmount() {
|
||||
$items = $this->getItems();
|
||||
@@ -142,8 +159,8 @@ class Order {
|
||||
}
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public
|
||||
|
||||
public
|
||||
function display(){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
@@ -152,19 +169,19 @@ class Order {
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
if ($items->numRows() > 0){?>
|
||||
|
||||
|
||||
<form action="index.php?page=display-cart" method="post" id="update-order-<?php print $this->id; ?>">
|
||||
<div><input type="hidden" name="action" value="update-cart" /></div>
|
||||
|
||||
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
}else {
|
||||
print("Ingen varer er registrert.");
|
||||
print("Ingen varer er registrert.");
|
||||
}
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
@@ -192,11 +209,11 @@ class Order {
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function displayShortList($edit = false){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
@@ -204,14 +221,14 @@ class Order {
|
||||
<h3>Handlekurv #<?php print $this->id; ?></h3>
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
?>
|
||||
?>
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
$item->displayShortList();
|
||||
@@ -227,17 +244,17 @@ class Order {
|
||||
<p>
|
||||
<a class="button" href="index.php?page=display-cart&order_id=<?php print $this->id; ?>">rediger ordre</a>
|
||||
<a class="button" href="index.php?page=display-carts&action=delete-order&order_id=<?php print $this->id; ?>">slett ordre</a>
|
||||
<a class="button" href="index.php?action=cart-checkout&order_id=<?php print $this->id; ?>&transaction_id_string=<?php print createTransactionId(); ?>">gå til betaling</a>
|
||||
<a class="button" href="index.php?action=cart-checkout&order_id=<?php print $this->id; ?>&transaction_id_string=<?php print createTransactionId(); ?>">gå til betaling</a>
|
||||
</p>
|
||||
<?php }
|
||||
}else {
|
||||
error("Items: " . $result->toString());
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
public
|
||||
function getConfirmationText() {
|
||||
$items = $this->getItems();
|
||||
@@ -248,24 +265,24 @@ class Order {
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public
|
||||
|
||||
public
|
||||
function displayConfirmation(){
|
||||
$items = $this->getItems();
|
||||
?>
|
||||
<?php
|
||||
if (DB::isError($items) != true){
|
||||
if ($items->numRows() > 0){?>
|
||||
|
||||
|
||||
<table class="sortable" id="cartcontent">
|
||||
<tr>
|
||||
<th>vare</th>
|
||||
<th>pris</th>
|
||||
<th>antall</th>
|
||||
</tr>
|
||||
<?php
|
||||
<?php
|
||||
}else {
|
||||
print("Ingen varer er registrert.");
|
||||
print("Ingen varer er registrert.");
|
||||
}
|
||||
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
@@ -283,12 +300,12 @@ class Order {
|
||||
error("Items: " . $result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function performOperations() {
|
||||
$items = $this->getItems();
|
||||
while ($row =& $items->fetchRow(DB_FETCHMODE_ASSOC)){
|
||||
$item = new OrderItem($row['id']);
|
||||
|
||||
|
||||
if ($item->product_id == 1) {
|
||||
// new membership
|
||||
$user = new User($this->user_id);
|
||||
@@ -300,7 +317,7 @@ class Order {
|
||||
} else {
|
||||
if(!$user->renewMembershipPayex()){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif ($item->product_id == 12) {
|
||||
// send new membercard
|
||||
|
||||
+38
-34
@@ -19,7 +19,7 @@ class OrderItem {
|
||||
$this->__construct($id, $data);
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function __construct($id = NULL, $data = NULL){
|
||||
$this->conn = db_connect();
|
||||
|
||||
@@ -34,21 +34,25 @@ class OrderItem {
|
||||
$data = $this->_retrieveData();
|
||||
}
|
||||
}
|
||||
|
||||
//Common initializations
|
||||
$this->product_id = $data['product_id'];
|
||||
$this->quantity = $data['quantity'];
|
||||
$this->order_id = $data['order_id'];
|
||||
$this->discount = $data['discount'];
|
||||
$this->comment = isset($data['comment']) ? $data['comment'] : '';
|
||||
$this->product_id = $data['product_id'];
|
||||
$this->quantity = $data['quantity'];
|
||||
$this->order_id = $data['order_id'];
|
||||
$this->discount = $data['discount'];
|
||||
$this->comment = isset($data['comment']) ? $data['comment'] : '';
|
||||
|
||||
// only allow purchase of one membership
|
||||
if ($this->product_id == 1) $this->quantity = 1;
|
||||
}
|
||||
|
||||
public function store(){
|
||||
if ($this->id == NULL){
|
||||
$this->id = getNextId("din_order_item");
|
||||
$sql = sprintf("INSERT INTO din_order_item
|
||||
$sql = sprintf("INSERT INTO din_order_item
|
||||
(id, product_id, quantity, order_id, discount, comment)
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s)",
|
||||
VALUES
|
||||
(%s, %s, %s, %s, %s, %s)",
|
||||
$this->conn->quoteSmart($this->id),
|
||||
$this->conn->quoteSmart($this->product_id),
|
||||
$this->conn->quoteSmart($this->quantity),
|
||||
@@ -61,11 +65,11 @@ class OrderItem {
|
||||
//notify("Nytt ordreelement lagret.");
|
||||
}else {
|
||||
error("New order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function _retrieveData(){
|
||||
$sql = "SELECT *
|
||||
FROM din_order_item t
|
||||
@@ -83,17 +87,17 @@ class OrderItem {
|
||||
|
||||
public
|
||||
function setQuantity($value) {
|
||||
$sql = "UPDATE din_order_item SET
|
||||
quantity = $value
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
// only allow purchase of one membership
|
||||
if ($this->product_id == 1) $value = 1;
|
||||
|
||||
$sql = "UPDATE din_order_item SET quantity = " . $value . " WHERE id = " . $this->id;
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set quantity - order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
@@ -102,34 +106,34 @@ class OrderItem {
|
||||
comment = '$value'
|
||||
WHERE " .
|
||||
" id = $this->id";
|
||||
|
||||
|
||||
$result = $this->conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
//notify("Orderstatus oppdatert ($value)");
|
||||
}else {
|
||||
error("Set comment - order_item: " . $result->toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
/*static*/
|
||||
/*static*/
|
||||
function delete($id){
|
||||
$conn = db_connect();
|
||||
$sql = "DELETE FROM din_order_item
|
||||
WHERE id = $id
|
||||
$sql = "DELETE FROM din_order_item
|
||||
WHERE id = $id
|
||||
LIMIT 1";
|
||||
$result = $conn->query($sql);
|
||||
if (DB::isError($result) != true){
|
||||
if ($conn->affectedRows() > 0){
|
||||
//notify("Varen er slettet fra handlekurven.");
|
||||
}else {
|
||||
//notify("Ugyldig order_itemid, ingen handling utført.");
|
||||
//notify("Ugyldig order_itemid, ingen handling utført.");
|
||||
}
|
||||
}else {
|
||||
error($result->toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function display(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
@@ -146,17 +150,17 @@ class OrderItem {
|
||||
<td><strong><?php print $product->title; ?></strong><br /><?php print $product->description; ?></td><td><?php print formatPrice($this->price); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<p>Du vil få tilsendt medlemskort i posten i løpet av 6-12 dager.</p>
|
||||
<p>Om du allerede har medlemskort vil du kun få tilsendt nytt oblat for inneværende år.</p>
|
||||
<p>For spørsmål vedrørende medlemskapet eller transaksjonen kan du kontakte <a href="mailto:support@studentersamfundet.no">support@studentersamfundet.no</a>.</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function displayList(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
@@ -172,9 +176,9 @@ class OrderItem {
|
||||
<td><input type="text" name="orderitem<?php print $this->id; ?>" size="2" value="<?php print $this->quantity; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
public
|
||||
public
|
||||
function displayShortList(){
|
||||
$product = new Product($this->product_id);
|
||||
?>
|
||||
@@ -184,13 +188,13 @@ class OrderItem {
|
||||
<td><?php print $this->quantity; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public
|
||||
function getConfirmationText() {
|
||||
$product = new Product($this->product_id);
|
||||
$text = $this->quantity . " " . $product->title . " á " . formatPrice($product->price) . "\n";
|
||||
return $text;
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
Reference in new issue
Block a user