$this->amountpaid=$totalprice;
}
// print(4);
+ $db->mkLog(array("orderid"=>$this->orderid,"orderpaid"=>$this->amountpaid,"orderdue"=>$totalprice),tr("create order"));
//end
$db->commitTransaction();
return true;
$db->update("voucher",array("price"=>0,"value"=>0,"isused"=>0),"orderid=".$db->escapeInt($this->orderid));
//set order to cancelled
$db->update("order",array("status"=>ORDER_CANCELLED,"senttime"=>time()),"orderid=".$db->escapeInt($this->orderid));
+ $db->mkLog(array("orderid"=>$this->orderid,"orderdue"=>0,"orderpaid"=>$this->amountpaid),tr("order cancelled"));
$db->commitTransaction();
return true;
}
return false;
}
//set new status
- $set=array("status"=>$mode);
+ $due=$this->totalPrice();
+ $set=array("status"=>$mode,"amountpaid"=>0);
if($mode==ORDER_SOLD)
- $set["amountpaid"]=$this->totalPrice();
+ $set["amountpaid"]=$due;
$db->update("order",$set,"orderid=".$db->escapeInt($this->orderid));
+ $db->mkLog(array("orderid"=>$this->orderid,"orderpaid"=>$set["amountpaid"],"orderdue"=>$due),tr("reservation to order"));
$db->commitTransaction();
return true;
}
global $db;
$xml=new DomDocument;
$doc=$xml->createElement("OrderList");
- $res=$db->select("order","orderid,customerid,status,amountpaid,shippingtype,shippingcosts",$where);
+ $res=$db->select("order","orderid,customerid,status,amountpaid,shippingtype,shippingcosts",$where,"ORDER BY orderid DESC");
foreach($res as $ord){
$price=0;
//check shipping
//correct DB
$amt2=$res[0]["amountpaid"]+($amt*$factor);
$db->update("order",array("amountpaid"=>$amt2),"orderid=".$db->escapeInt($oid));
+ $db->mkLog(array("orderid"=>$oid,"orderpaid"=>$amt2,"moved"=>$amt),$factor>0?tr("payment"):tr("refund"));
$db->commitTransaction();
//output
header("X-MagicSmoke-Status: Ok");
$db->commitTransaction();
//dump order object
$ord=new Order($oid);
+ $db->mkLog(array("orderid"=>$oid,"orderpaid"=>$ord->amountPaid(),"orderdue"=>$ord->totalPrice()),tr("shipping changed"));
header("X-MagicSmoke-Status: Ok");
$ord->dumpXml();
}
}
//overwrite
$db->update("voucher",array("price"=>0,"value"=>0,"isused"=>0),"voucherid=".$db->escapeString($this->voucherid));
+ $db->mkLog(array("voucherid"=>$this->voucherid, "vouchervalue"=>0),tr("cancel voucher"));
$db->commitTransaction();
return true;
}
//now do the deed
global $db;
$db->update("voucher",array("value"=>0,"isused"=>1),"voucherid=".$db->escapeString($this->voucherid));
+ $db->mkLog(array("voucherid"=>$this->voucherid, "vouchervalue"=>0),tr("empty voucher"));
}
/**create the voucher in the database; returns false on failue*/
$db->rollbackTransaction();
return false;
}
+ $db->mkLog(array("voucherid"=>$vid, "vouchervalue"=>value, "orderid"=>$orderid),tr("create voucher"));
$db->commitTransaction();
$this->voucherid=$vid;
- $this->orderid=$oroderid;
+ $this->orderid=$orderid;
$this->price=$price+0;
$this->value=$value+0;
$this->isused=false;
$db->rollbackTransaction();
return false;
}
+ $db->mkLog(array("voucherid"=>$this->voucherid,"orderid"=>$orderid,"orderdue"=>$adue,"orderpaid"=>$a,"vouchervalue"=>$this->value,"moved"=>$pay),tr("pay with voucher"));
//whoo. got it!
$db->commitTransaction();
return true;
fclose($fd);
$this->unlockDB();
}
+
+
+ /**creates a log entry, the array must supply values for the moneylog table; time, username are generated automatically, the log entry is delivered via the second argument*/
+ public function mkLog(array $vals,$logtext)
+ {
+ global $session;
+ $vals["logtime"]=time();
+ $vals["uname"]=$session->getUser();
+ $vals["log"]=$logtext;
+ $this->insert("moneylog",$vals);
+ }
};
?>
\ No newline at end of file
);
$this->backup[]="voucher";
+ //money transaction log
+ $this->scheme["moneylog"]=array(
+ "logid" => array("seq64","primarykey"),
+ "logtime" => array("int64","notnull"),
+ "uname" => array("string:64","foreignkey:users:uname","null"),
+ "orderid" => array("int32","foreignkey:order:orderid","null"),
+ "voucherid" => array("string:32","foreignkey:voucher:voucherid","null"),
+ "moved" => array("int32","notnull"),
+ "orderpaid" => array("int32","null"),
+ "orderdue" => array("int32","null"),
+ "vouchervalue" => array("int32","null"),
+ "log" => array("string","notnull")
+ );
+ $this->backup[]="moneylog";
+
// /////////////////////////
// Web-Interface Stuff