1
0

Initial commit of modified Basket module

Additions: order status, customer object, e-mails for order status
changes, additional order view, webshop configuration options
This commit is contained in:
Jeroen ten kate 2012-12-27 20:51:16 +01:00
parent 959c710775
commit 8eec645c40
46 changed files with 4772 additions and 0 deletions

View File

@ -0,0 +1,163 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Configure_Controller extends Controller
{
/**
* the index page of the user homes admin
*/
public function index()
{
$form = basket::get_configure_form();
if (request::method() == "post") {
access::verify_csrf();
if ($form->validate()) {
basket::extractForm($form);
message::success(t("Basket Module Configured!"));
}
}
else
{
basket::populateForm($form);
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_configure.html");
$view->content->form = $form;
print $view;
}
/**
* the index page of the user homes admin
*/
public function templates()
{
$form = basket::get_template_form();
if (request::method() == "post") {
access::verify_csrf();
if ($form->validate()) {
basket::extractTemplateForm($form);
message::success(t("Basket Module Configured!"));
}
}
else
{
basket::populateTemplateForm($form);
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_templates.html");
$view->content->form = $form;
print $view;
}
public function paypal_encrypt_wizard_step1()
{
$view = new Admin_View("admin.html");
$view->content = new View("pew1.html");
$view->content->form = self::keyGenerationForm();
print $view;
}
public function paypal_encrypt_wizard_step2()
{
access::verify_csrf();
$form = self::keyGenerationForm();
if (!$form->validate()) {
self::paypal_encrypt_wizard_step1();
return;
}
$ssldir = str_replace('\\','/',VARPATH.'certificate');
$ssldir= rtrim($ssldir, '/').'/';
if ( ! is_dir($ssldir))
{
// Create the upload directory
mkdir($ssldir, 0777, TRUE);
}
$prkeyfile = $ssldir . "myprvkey.pem";
$pubcertfile = $ssldir . "mypubcert.pem";
$certreqfile = $ssldir . "mycertreq.pem";
$dn = array("countryName" => $form->encrypt->countryName->value,
"stateOrProvinceName" => $form->encrypt->stateOrProvinceName->value,
"localityName" => $form->encrypt->localityName->value,
"organizationName" => $form->encrypt->organizationName->value,
"organizationalUnitName" => $form->encrypt->organizationalUnitName->value,
"commonName" => $form->encrypt->commonName->value,
"emailAddress" => $form->encrypt->emailAddress->value);
$privkeypass = $form->encrypt->privKeyPass->value;
$numberofdays = 365;
$config = array(
"private_key_bits" => 1024
);
$privkey = openssl_pkey_new($config);
$csr = openssl_csr_new($dn, $privkey);
$sscert = openssl_csr_sign($csr, null, $privkey, $numberofdays);
openssl_x509_export($sscert, $publickey);
openssl_pkey_export($privkey, $privatekey, $privkeypass);
openssl_csr_export($csr, $csrStr);
openssl_x509_export_to_file($sscert, $pubcertfile);
openssl_pkey_export_to_file ($privkey, $prkeyfile, $privkeypass);
openssl_csr_export_to_file($csr, $certreqfile);
//echo "Your Public Certificate has been saved to " . $pubcertfile . "<br><br>";
//echo "Your Private Key has been saved to " . $prkeyfile . "<br><br>";
//echo "Your Certificate Request has been saved to " . $certreqfile . "<br><br>";
//echo $privatekey; // Will hold the exported PriKey
//echo $publickey; // Will hold the exported PubKey
//echo $csrStr; // Will hold the exported Certificate
}
private function keyGenerationForm()
{
$form = new Forge("admin/configure/paypal_encrypt_wizard_step2", "", "post", array("id" => "generateKeys", "name" =>"generateKeys"));
$group = $form->group("encrypt")->label(t("Key Generation Details"));
$group->input("countryName")->label(t("Country Name"))->id("countryName");
$group->input("stateOrProvinceName")->label(t("State or Province Name"))->id("stateOrProvinceName");
$group->input("localityName")->label(t("Locality Name"))->id("localityName");
$group->input("organizationName")->label(t("Organization Name"))->id("organizationName");
$group->input("organizationalUnitName")->label(t("Organizational Unit Name"))->id("organizationalUnitName");
$group->input("commonName")->label(t("Common Name"))->id("commonName");
$group->input("emailAddress")->label(t("E-Mail Address"))->id("emailAddress");
$group->input("privKeyPass")->label(t("Private Key Pass"))->id("privkeypass");
return $form;
}
}

View File

@ -0,0 +1,147 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Postage_Bands_Controller extends Controller
{
/**
* the index page of the user homes admin
*/
public function index()
{
$view = new Admin_View("admin.html");
$view->content = new View("admin_postage_bands.html");
$view->content->postage_bands = ORM::factory("postage_band")->order_by("name")->find_all();
print $view;
}
public function add_postage_band_form() {
print postage_band::get_add_form_admin();
}
public function add_postage_band() {
access::verify_csrf();
$form = postage_band::get_add_form_admin();
$valid = $form->validate();
$name = $form->add_postage->inputs["name"]->value;
$postage = ORM::factory("postage_band")->where("name","=", $name)->find();
if ($postage->loaded()) {
$form->add_postage->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
if ($valid) {
$postage = postage_band::create(
$name,
$form->add_postage->flat_rate->value,
$form->add_postage->per_item->value
);
$postage->save();
message::success(t("Created postage band %postage_name", array(
"postage_name" => html::clean($postage->name))));
print json::reply(array("result" => "success"));
} else {
print $form;
}
}
public function delete_postage_band_form($id) {
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded()) {
kohana::show_404();
}
print postage_band::get_delete_form_admin($postage);
}
public function delete_postage_band($id) {
access::verify_csrf();
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded()) {
kohana::show_404();
}
$form = postage_band::get_delete_form_admin($postage);
if($form->validate()) {
$name = $postage->name;
$postage->delete();
} else {
print $form;
}
$message = t("Deleted user %postage_band", array("postage_band" => html::clean($name)));
log::success("user", $message);
message::success($message);
print json::reply(array("result" => "success"));
}
public function edit_postage_band($id) {
access::verify_csrf();
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded()) {
kohana::show_404();
}
$form = postage_band::get_edit_form_admin($postage);
$valid = $form->validate();
if ($valid) {
$new_name = $form->edit_postage->inputs["name"]->value;
if ($new_name != $postage->name &&
ORM::factory("postage_band")
->where("name", "=", $new_name)
->where("id","!=", $postage->id)
->find()
->loaded()) {
$form->edit_postage->inputs["name"]->add_error("in_use", 1);
$valid = false;
} else {
$postage->name = $new_name;
}
}
if ($valid) {
$postage->flat_rate = $form->edit_postage->flat_rate->value;
$postage->per_item = $form->edit_postage->per_item->value;
$postage->save();
message::success(t("Changed postage band %postage_name",
array("postage_name" => html::clean($postage->name))));
print json::reply(array("result" => "success"));
} else {
print $form;
}
}
public function edit_postage_band_form($id) {
$postage = ORM::factory("postage_band", $id);
if (!$postage->loaded()) {
kohana::show_404();
}
$form = postage_band::get_edit_form_admin($postage);
print $form;
}
}

View File

@ -0,0 +1,149 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Product_Lines_Controller extends Controller
{
/**
* the index page of the user homes admin
*/
public function index()
{
$view = new Admin_View("admin.html");
$view->content = new View("admin_product_lines.html");
$view->content->products = ORM::factory("product")->order_by("name")->find_all();
print $view;
}
public function add_product_form() {
print product::get_add_form_admin();
}
public function add_product() {
access::verify_csrf();
$form = product::get_add_form_admin();
$valid = $form->validate();
$name = $form->add_product->inputs["name"]->value;
$product = ORM::factory("product")->where("name", "=", $name)->find();
if ($product->loaded()) {
$form->add_product->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
if ($valid) {
$product = product::create(
$name,
$form->add_product->cost->value,
$form->add_product->description->value,
$form->add_product->postage_band->value
);
$product->save();
message::success(t("Created product %product_name", array(
"product_name" => html::clean($product->name))));
print json::reply(array("result" => "success"));
} else {
print $form;
}
}
public function delete_product_form($id) {
$product = ORM::factory("product", $id);
if (!$product->loaded()) {
kohana::show_404();
}
print product::get_delete_form_admin($product);
}
public function delete_product($id) {
access::verify_csrf();
$product = ORM::factory("product", $id);
if (!$product->loaded()) {
kohana::show_404();
}
$form = product::get_delete_form_admin($product);
if($form->validate()) {
$name = $product->name;
$product->delete();
} else {
print $form;
}
$message = t("Deleted user %product_name", array("product_name" => html::clean($name)));
log::success("user", $message);
message::success($message);
print json::reply(array("result" => "success"));
}
public function edit_product($id) {
access::verify_csrf();
$product = ORM::factory("product", $id);
if (!$product->loaded()) {
kohana::show_404();
}
$form = product::get_edit_form_admin($product);
$valid = $form->validate();
if ($valid) {
$new_name = $form->edit_product->inputs["name"]->value;
if ($new_name != $product->name &&
ORM::factory("product")
->where("name", "=", $new_name)
->where("id","!=", $product->id)
->find()
->loaded()) {
$form->edit_product->inputs["name"]->add_error("in_use", 1);
$valid = false;
} else {
$product->name = $new_name;
}
}
if ($valid) {
$product->cost = $form->edit_product->cost->value;
$product->description = $form->edit_product->description->value;
$product->postage_band_id = $form->edit_product->postage_band->value;
$product->save();
message::success(t("Changed product %product_name",
array("product_name" => html::clean($product->name))));
print json::reply(array("result" => "success"));
} else {
print $form;
}
}
public function edit_product_form($id) {
$product = ORM::factory("product", $id);
if (!$product->loaded()) {
kohana::show_404();
}
$form = product::get_edit_form_admin($product);
print $form;
}
}

View File

@ -0,0 +1,598 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* 2011-05-01 Added function view_all_orders()
*/
class Basket_Controller extends Controller {
public function view_basket($pp="") {
$template = new Theme_View("page.html", "basket");
$basket = Session_Basket::get();
if (isset($pp)){
if ($pp=="nopp"){
$basket->disablepp();
}
elseif ($pp=="ppon"){
$basket->enablepp();
}
}
$view = new View("view_basket.html");
$view->basket = $basket;
$template->content = $view;
print $template;
}
public function preview($id) {
$item = ORM::factory("item", $id);
print "<img src='".$item->resize_url()."'></img>";
}
public function view_orders() {
//get all incomplete orders and show them in a view
self::check_view_orders();
$template = new Theme_View("page.html", "basket");
$incomplete_orders = ORM::factory("order")->where('status',"<",20)->find_all();
$view = new View("view_orders.html");
$view->orders = $incomplete_orders;
$template->content = $view;
print $template;
}
public function view_all_orders() {
//get all orders and show them in a view
self::check_view_orders();
$template = new Theme_View("page.html", "basket");
$all_orders = ORM::factory("order")->find_all();
$view = new View("view_orders.html");
$view->orders = $all_orders;
$template->content = $view;
print $template;
}
public function view_ipn($orderid){
self::check_view_orders();
$template = new Theme_View("page.html", "basket");
$order = ORM::factory("order")->where("id","=",$orderid)->find();
$ipn_messages = ORM::factory("ipn_message")->where("key","=",$orderid)->find_all();
//$ipn_messages = ORM::factory("ipn_message")->find_all();
$view = new View("view_ipn.html");
$view->order = $order;
$view->ipn_messages = $ipn_messages;
$template->content = $view;
print $template;
}
public function check_view_orders() {
if (!basket::can_view_orders()){
die("Invalid access.");
}
}
public function print_order($id){
access::verify_csrf();
self::check_view_orders();
$prefix = basket::getOrderPrefix();
$length = strlen($prefix);
if (strlen($id)>$length ){
if ($prefix === strtolower(substr($id,0,$length ))){
$id = substr($id,$length);
}
}
$order = ORM::factory("order", $id);
$view = new View("print_order.html");
if ($order->loaded()){
$view->order = str_replace(array("\r\n", "\n", "\r"),"<br/>",$order->text);
}else{
$view->order = "Order ".$id." not found.";
}
print $view;
}
public function show_order($id){
access::verify_csrf();
self::check_view_orders();
$prefix = basket::getOrderPrefix();
$length = strlen($prefix);
if (strlen($id)>$length ){
if ($prefix === strtolower(substr($id,0,$length ))){
$id = substr($id,$length);
}
}
$order = ORM::factory("order", $id);
if ($order->loaded()){
$view = new View("view_order.html");
$view->order = $order;
print $view;
}else{
print "Order ".$id." not found.";
}
}
public function show_order_logs($id){
//get all order logs of order $id and show them in a simple view
self::check_view_orders();
$order_log = ORM::factory("order_log")->where('id',"=",$id)->find_all();
$view = new View("view_order_logs.html");
$view->order_logs = $order_log;
print $view;
print $template;
}
public function show_ipn($id){
access::verify_csrf();
self::check_view_orders();
$ipn_message = ORM::factory("ipn_message", $id);
if ($ipn_message->loaded()){
print $ipn_message->text;
}else{
print "IPN Message ".$id." not found.";
}
}
public function send_order_copy($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
//Send order copy
basket::send_invoice_copy($order);
order_log::log($order,order_log::COPY_SENT);
}
url::redirect("basket/view_orders");
}
public function confirm_order_payment($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
if ($order->status == 1)
{
$order->status = 2;
order_log::log($order,order_log::PAID);
}
elseif ($order->status == 10)
{
$order->status = 20;
order_log::log($order,order_log::PAID);
}
$order->save();
//Send payment confirmation
basket::send_payment_confirmation($order);
}
url::redirect("basket/view_orders");
}
public function remind_order_payment($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
if ($order->status == 1)
{
//Send payment reminder
order_log::log($order,order_log::LATE_PAYMENT);
basket::send_payment_reminder($order);
}
}
url::redirect("basket/view_orders");
}
public function confirm_order_delivery($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
if ($order->status == 2)
{
$order->status = 20;
order_log::log($order,order_log::DELIVERED);
}
if ($order->status == 1)
{
$order->status = 10;
order_log::log($order,order_log::DELIVERED_NOTPAID);
}
// Send delivery confirmation
basket::send_delivery_confirmation($order);
$order->save();
}
url::redirect("basket/view_orders");
}
public function confirm_order_delivery_not_paid($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
}
url::redirect("basket/view_orders");
}
public function confirm_order_cancelled($id){
access::verify_csrf();
self::check_view_orders();
$order = ORM::factory("order", $id);
if ($order->loaded()){
$order->status = 99;
order_log::log($order,order_log::CANCELLED);
// Send cancellation confirmation
basket::send_cancellation_confirmation($order);
$order->save();
}
url::redirect("basket/view_orders");
}
private function getCheckoutForm(){
$basket = Session_Basket::get();
$ppon = $basket->ispp();
$postage = $basket->postage_cost();
//labels for fields
$input1_lbl=t("Title");
$input2_lbl=t("Initials/First name")."*";
$input3_lbl=t("Insertion");
$input4_lbl=t("Name")."*";
$input5_lbl=t("Street");
$input6_lbl=t("House Number / Name");
$input7_lbl=t("Suburb");
$input8_lbl=t("Postcode");
$input9_lbl=t("Town or City");
$input10_lbl=t("E-mail Address")."*";
$input11_lbl=t("Telephone Number")."*";
$input12_lbl=t("Child's Name");
$input13_lbl=t("Child's Group");
$input14_lbl=t("Additional comments");
$input15_lbl=t("I agree with the General Terms")."*";
//labels for mandatory fields with p&p
if (($ppon) && ($postage > 0)){
$input5_lbl=$input5_lbl."*";
$input6_lbl=$input6_lbl."*";
$input8_lbl=$input8_lbl."*";
$input9_lbl=$input9_lbl."*";
}
//labels for mandatory fields with pickup
elseif ($postage > 0){
$input12_lbl=$input12_lbl."*";
$input13_lbl=$input13_lbl."*";
}
$form = new Forge("basket/confirm", "", "post", array("id" => "checkout", "name" =>"checkout"));
$group = $form->group("contact")->label(t("Contact Details"));
$group->input("title")->label($input1_lbl)->id("title");
$group->input("initials")->label($input2_lbl)->id("initials");
$group->input("insertion")->label($input3_lbl)->id("insertion");
$group->input("fullname")->label($input4_lbl)->id("fullname");
$group->input("street")->label($input5_lbl)->id("street");
$group->input("house")->label($input6_lbl)->id("house");
$group->hidden("suburb")->label($input7_lbl)->id("suburb");
$group->input("postcode")->label($input8_lbl)->id("postcode");
$group->input("town")->label($input9_lbl)->id("town");
$group->input("email")->label($input10_lbl)->id("email");
$group->input("phone")->label($input11_lbl)->id("phone");
//show child fields only with pickup DISABLED
if ((!$ppon) && ($postage > 1000)){
$group->input("childname")->label($input12_lbl)->id("childname");
$group->input("childgroup")->label($input13_lbl)->id("childgroup");
}
else{
$group->hidden("childname")->label($input12_lbl)->id("childname");
$group->hidden("childgroup")->label($input13_lbl)->id("childgroup");
}
$group->input("comments")->label($input14_lbl)->id("comments");
$group->checkbox("agreeterms")->label($input15_lbl)->id("agreeterms");
$group->hidden("paypal")->id("paypal");
return $form;
}
public function checkout () {
$template = new Theme_View("page.html", "basket");
$view = new View("checkout.html");
$basket = Session_Basket::get();
/* changed order for nl_NL */
$form = self::getCheckoutForm();
$form->contact->title->value($basket->title);
$form->contact->initials->value($basket->initials);
$form->contact->insertion->value($basket->insertion);
$form->contact->fullname->value($basket->name);
$form->contact->street->value($basket->street);
$form->contact->house->value($basket->house);
$form->contact->postcode->value($basket->postcode);
$form->contact->town->value($basket->town);
$form->contact->suburb->value($basket->suburb);
$form->contact->email->value($basket->email);
$form->contact->phone->value($basket->phone);
$form->contact->childname->value($basket->childname);
$form->contact->childgroup->value($basket->childgroup);
$form->contact->comments->value($basket->comments);
$form->contact->agreeterms->value($basket->agreeterms);
$view->form = $form;
$template->content = $view;
print $template;
}
public function confirm () {
access::verify_csrf();
$form = $this->getCheckoutForm();
$valid = $form->validate();
if ($valid){
$basket = Session_Basket::get();
if (!isset($basket->contents ) || count($basket->contents) == 0) {
self::view_basket();
return;
}
/* changed order for nl_NL */
$basket->title = $form->contact->title->value;
$basket->initials = $form->contact->initials->value;
$basket->insertion = $form->contact->insertion->value;
$basket->name = $form->contact->fullname->value;
$basket->street = $form->contact->street->value;
$basket->house = $form->contact->house->value;
$basket->postcode = $form->contact->postcode->value;
$basket->town = $form->contact->town->value;
$basket->suburb = $form->contact->suburb->value;
$basket->email = $form->contact->email->value;
$basket->phone = $form->contact->phone->value;
$basket->childname = $form->contact->childname->value;
$basket->childgroup = $form->contact->childgroup->value;
$basket->comments = $form->contact->comments->value;
$basket->agreeterms=$form->contact->agreeterms->value;
$paypal=$form->contact->paypal->value=="true";
$template = new Theme_View("page.html", "basket");
// NOT USED ===============================
if ($paypal){
// create a prelimary order
$order = basket::createOrder($basket, Order_Model::PAYMENT_PAYPAL);
$paypal = new Paypal();
// create the order first
$view = new View("paypal_redirect.html");
$view ->form = $paypal->process($basket,
url::site("basket/paypal_complete/$order->id", "http"),
url::site("basket/paypal_cancel/$order->id", "http"),
url::site("basket/paypal_ipn/$order->id", "http"));
$template->content = $view;
print $template;
// redirect to paypal
// NOT USED END ===============================
}else
{
$form = new Forge("basket/complete", "", "post", array("id" => "confirm", "name" =>"confirm"));
$view = new View("confirm_order.html");
$view->basket = $basket;
$template->content = $view;
$view->form = $form;
print $template;
}
}
else
{
die("Invalid confirmation!");
}
}
function paypal_ipn($id){
$order = ORM::factory("order")->where("id","=",$id)->find();
if ($order->loaded()){
$paypal = new Paypal();
if ($paypal->validate_ipn($id)){
if ($paypal->ipn_data['payment_status'] == "Completed"){
$order->status = Order_Model::PAYMENT_CONFIRMED;
order_log::log($order,order_log::ORDERED);
// send e-mails
basket::send_order($order);
basket::send_invoice($order);
$order->save();
}
return;
}
print "invalid access. tut tut!";
}
return;
}
public function paypal_complete($id) {
$order = ORM::factory("order")->where("id","=",$id)->find();
$basket = Session_Basket::get();
$basket->clear();
$this->_complete($order);
}
public function paypal_cancel($id){
$order = ORM::factory("order")->where("id","=",$id)->find();
if ($order->loaded()){
$order->delete();
}
$this->checkout();
}
public function complete () {
access::verify_csrf();
$basket = Session_Basket::get();
if (!isset($basket->contents ) || count($basket->contents) == 0) {
self::view_basket();
return;
}
// create order
$order = basket::createOrder($basket, Order_Model::PAYMENT_OFFLINE);
$basket->clear();
order_log::log($order,order_log::ORDERED);
// send e-mails
basket::send_order($order);
basket::send_invoice($order);
$this->_complete($order);
}
private function _complete($order){
$template = new Theme_View("page.html", "basket");
$view = new View("order_complete.html");
$ordernumber = basket::getOrderPrefix().$order->id;
$view->ordernumber = $ordernumber;
$view->order = $order;
$view->webshop = basket::getWebshop();
$view->email = basket::getEmailAddress();
$template->content = $view;
print $template;
}
private function getAddToBasketForm($id){
$form = new Forge("basket/add_to_basket", "", "post", array("id" => "gAddToBasketForm"));
$group = $form->group("add_to_basket")->label(t("Add To Basket"));
$group->hidden("id");
$group->dropdown("product")
->label(t("Product"))
->options(product::getProductArray($id));
$group->input("quantity")->label(t("Quantity"))->id("gQuantity");
$group->submit("")->value(t("Add"));
//$group->submit("proceedToCheckout")->value(t("Proceed To Checkout"));
return $form;
}
public function add_to_basket(){
access::verify_csrf();
if (!isset($_POST['id']))
{
die("no id");
}
$form = self::getAddToBasketForm($_POST['id']);
$valid = $form->validate();
if ($valid){
$basket = Session_Basket::getOrCreate();
$basket->add(
$form->add_to_basket->id->value,
$form->add_to_basket->product->value,
$form->add_to_basket->quantity->value);
$item = ORM::factory("item", $form->add_to_basket->id->value);
Session::instance()->set("redirect_home", $item->parent_id);
print json::reply(array("result" => "success"));
}
else
{
log_error("invalid form!");
}
}
public function add_to_basket_ajax($id) {
$view = new View("add_to_basket_ajax.html");
// get the item to add
$item = ORM::factory("item", $id);
if (!$item->loaded())
{
//TODO
die("Not loaded id");
}
// get the basket to add to
$form = self::getAddToBasketForm($id);
$form->add_to_basket->id->value($id);
$form->add_to_basket->quantity->value(1);
$view->form = $form;
$view->item = $item;
print $view;
}
public function remove_item($key) {
$basket = Session_Basket::getOrCreate();
$basket->remove($key);
url::redirect("basket/view_basket");
}
}

View File

@ -0,0 +1,157 @@
#basket {
float:right;
}
#add_to_basket {float:right}
#basketForm {max-width:200px;float:left;}
#basketThumb {float:left; padding:10px;}
#basketThumb img{max-width:100px;}
#payment {float:right; width:50%}
#checkout input,
#checkout select,
#checkout textarea {
display: block;
clear: both;
padding: .2em;
width: 100%;
}
#checkout input.checkbox,
input[type=checkbox]{
width: 10%;
margin-top: 3px;
}
#checkout input,
#sidebar-basket {max-height:400px; overflow-y:auto; overflow-x:hidden;}
/* Classes */
.order-status-1 a{color:#AA0000 !important}
.order-status-1 tr{background-color:orange !important}
.order-status-2 a{color:#00AA00 !important}
.order-status-2 tr{background-color:green !important}
/*.orders-view ,p{font-size: 10px}*/
.basket-right h3{margin-left: 10px}
.basket-right p{margin-left: 10px}
.basket-right
{
font-family: Verdana, Geneva, sans-serif;
font-size: 1em;
}
.pretty-table
{
padding: 0;
margin: 0;
border-collapse: collapse;
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
font-size: 0.9em;
color: #000;
background: #bcd0e4 url("widget-table-bg.jpg") top left repeat-x;
}
.pretty-table caption
{
caption-side: bottom;
font-size: 0.9em;
font-style: italic;
text-align: right;
padding: 0.5em 0;
}
.pretty-table th, .pretty-table td
{
border: 1px dotted #666;
padding: 0.5em;
text-align: left;
}
.pretty-table th[scope=col]
{
color: #000;
background-color: #8fadcc;
text-transform: uppercase;
font-size: 0.9em;
border-bottom: 2px solid #333;
border-right: 2px solid #333;
}
.pretty-table th+th[scope=col]
{
color: #fff;
background-color: #7d98b3;
border-right: 1px dotted #666;
}
.pretty-table th[scope=row]
{
background-color: #b8cfe5;
border-right: 2px solid #333;
}
.pretty-table tr.alt th, .pretty-table tr.alt td
{
color: #2a4763;
}
.pretty-table tr:hover th[scope=row], .pretty-table tr:hover td
{
background-color: darkblue;
color: #fff;
}
.pretty-table2
{
padding: 0;
margin: 0;
border-collapse: collapse;
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
font-size: 0.9em;
color: #000;
background: #bcd0e4 url("widget-table-bg.jpg") top left repeat-x;
}
.pretty-table2 caption
{
caption-side: bottom;
font-size: 0.9em;
font-style: italic;
text-align: right;
padding: 0.5em 0;
}
.pretty-table2 th
{
border-bottom: 1px solid #666;
padding: 0.5em;
text-align: left;
}
.pretty-table2 td
{
border-top: 1px dotted #666;
border-bottom: 1px dotted #666;
padding: 0.2em;
text-align: left;
}
.pretty-table2 th+th[scope=col]
{
color: #fff;
background-color: #7d98b3;
border-right: 1px dotted #666;
}
.pretty-table2 th[scope=row]
{
background-color: #b8cfe5;
border-right: 2px solid #333;
}
.pretty-table2 tr.alt th, .pretty-table tr.alt td
{
color: #2a4763;
}
.pretty-table3 td
{
border-top: none;
border-bottom: none;
padding: 0.5em;
text-align: left;
}

View File

@ -0,0 +1,785 @@
<?php
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
/* Extended with
2011-01-31 Dutch e-mail text
2011-02-28 function formatMoneyForMail
2011-04-07 order_bankaccount,
2011-04-25 e-mails for payment and delivery confirmation,
added method values to discriminate between mail, email and pickup.
2011-11-17 E-mails for delivey w/o payment, payment after delivery and cancellation
2012-01-04 Pickup location added
*/
class basket_Core {
static $currencies = array(
"AUD" => "Australian Dollars",
"CAD" => "Canadian Dollars",
"EUR" => "Euros",
"GBP" => "Pounds Sterling",
"JPY" => "Yen",
"USD" => "U.S. Dollars",
"NZD" => "New Zealand Dollar",
"CHF" => "Swiss Franc",
"HKD" => "Hong Kong Dollar",
"SGD" => "Singapore Dollar",
"SEK" => "Swedish Krona",
"DKK" => "Danish Krone",
"PLN" => "Polish Zloty",
"NOK" => "Norwegian Krone",
"HUF" => "Hungarian Forint",
"CZK" => "Czech Koruna",
"ILS" => "Israeli Shekel",
"MXN" => "Mexican Peso");
static $format= array(
"AUD" => "$",
"CAD" => "$",
"EUR" => "",
"GBP" => "£",
"JPY" => "¥",
"USD" => "$",
"NZD" => "$",
"CHF" => "",
"HKD" => "$",
"SGD" => "$",
"SEK" => "",
"DKK" => "",
"PLN" => "",
"NOK" => "",
"HUF" => "",
"CZK" => "",
"ILS" => "",
"MXN" => "",
"none" => "");
static $formatweb= array(
"AUD" => "$",
"CAD" => "$",
"EUR" => "&euro;",
"GBP" => "&pound;",
"JPY" => "&yen;",
"USD" => "$",
"NZD" => "$",
"CHF" => "",
"HKD" => "$",
"SGD" => "$",
"SEK" => "",
"DKK" => "",
"PLN" => "",
"NOK" => "",
"HUF" => "",
"CZK" => "",
"ILS" => "",
"MXN" => "");
static public function can_view_orders()
{
if (identity::active_user()->admin){
return true;
}
print identity::active_user();
foreach (identity::active_user()->groups() as $group){
if ($group->name == 'shop'){
return true;
}
}
return false;
}
static function get_configure_form() {
$form = new Forge("admin/configure", "", "post", array("id" => "g-configure-form"));
$group = $form->group("configure")->label(t("Configure Basket"));
$group->input("webshop")->label(t("Webshop"))->id("g-webshop");
$group->input("website")->label(t("Website"))->id("g-order-website");
$group->input("email")->label(t("Offline Paying Email Address"))->id("g-order-email-address");
$group->dropdown("currency")
->label(t("Currency"))
->options(self::$currencies);
$group->checkbox("side_bar")->label(t("Use only side bar"))->id("g-side-bar-only");
$group->checkbox("paypal")->label(t("Use Paypal"))->id("g-paypal");
$group->input("paypal_account")->label(t("Paypal E-Mail Address"))->id("g-paypal-address");
$group->checkbox("allow_pickup")->label(t("Allow Product Pickup"))->id("g-allow-pickup");
$group->input("pickup_location")->label(t("Pickup Location"))->id("g-pickup-location");
$group->input("order_prefix")->label(t("Order Number Prefix"))->id("g-order-prefix");
$group->input("order_bankaccount")->label(t("Order Bank Account"))->id("g-order_bankaccount");
$group->input("order_accountowner")->label(t("Order Account Owner"))->id("g-order_accountowner");
$group->submit("")->value(t("Save"));
return $form;
}
static function get_template_form() {
$form = new Forge("admin/configure/templates", "", "post", array("id" => "g-configure-form"));
$group = $form->group("configure")->label(t("Configure Basket"));
$group->textarea("payment_details")->label(t("Payment Details Description"))->id("g-payment-details");
$group->textarea("order_complete_page")->label(t("Order Complete Page"))->id("g-order-complete_page");
$group->input("order_complete_email_subject")->label(t("Order Complete Email Subject"))->id("g-order-complete_email_subject");
$group->textarea("order_complete_email")->label(t("Order Complete Email"))->id("g-order-complete_email");
$group->input("order_paid_email_subject")->label(t("Order Paid Email Subject"))->id("g-order-paid_email_subject");
$group->textarea("order_paid_email")->label(t("Order Paid Email"))->id("g-order-paid_email");
$group->input("order_paid_delivered_email_subject")->label(t("Order Paid Delivered Email Subject"))->id("g-order-paid-delivered_email_subject");
$group->textarea("order_paid_delivered_email")->label(t("Order Paid Delivered Email"))->id("g-order-paid-delivered_email");
$group->input("order_late_payment_email_subject")->label(t("Order Late Payment Email Subject"))->id("g-order-late-payment_email_subject");
$group->textarea("order_late_payment_email")->label(t("Order Late Payment Email"))->id("g-order-late-payment_email");
$group->input("order_delivered_email_subject")->label(t("Order Delivered Email Subject"))->id("g-order-delivered_email_subject");
$group->textarea("order_delivered_email")->label(t("Order Delivered Email"))->id("g-order-delivered_email");
$group->input("order_delivered_notpaid_email_subject")->label(t("Order Delivered Not Paid Email Subject"))->id("g-order-delivered-notpaid_email_subject");
$group->textarea("order_delivered_notpaid_email")->label(t("Order Delivered Not Paid Email"))->id("g-order-delivered-notpaid_email");
$group->input("order_cancelled_email_subject")->label(t("Order Cancelled Email Subject"))->id("g-order-cancelled_email_subject");
$group->textarea("order_cancelled_email")->label(t("Order Cancelled Email"))->id("g-order-cancelled_email");
$group->textarea("order_email_closing")->label(t("Order Email Closing"))->id("g-order-email-closing");
$group->submit("")->value(t("Save"));
return $form;
}
static function populateForm($form){
$form->configure->webshop->value(basket::getWebshop());
$form->configure->website->value(basket::getWebsite());
$form->configure->email->value(basket::getEmailAddress());
$form->configure->side_bar->checked(basket::is_side_bar_only());
$form->configure->paypal->checked(basket::isPaypal());
$form->configure->paypal_account->value(basket::getPaypalAccount());
$form->configure->currency->selected(basket::getCurrency());
$form->configure->allow_pickup->checked(basket::isAllowPickup());
$form->configure->pickup_location->value(basket::getPickupLocation());
$form->configure->order_prefix->value(basket::getOrderPrefix());
$form->configure->order_bankaccount->value(basket::getOrderBankAccount());
$form->configure->order_accountowner->value(basket::getOrderAccountOwner());
}
static function populateTemplateForm($form){
$form->configure->payment_details->value(basket::getPaymentDetails());
$form->configure->order_complete_page->value(basket::getOrderCompletePage());
$form->configure->order_complete_email_subject->value(basket::getOrderCompleteEmailSubject());
$form->configure->order_complete_email->value(basket::getOrderCompleteEmail());
$form->configure->order_paid_email_subject->value(basket::getOrderPaidEmailSubject());
$form->configure->order_paid_email->value(basket::getOrderPaidEmail());
$form->configure->order_paid_delivered_email_subject->value(basket::getOrderPaidDeliveredEmailSubject());
$form->configure->order_paid_delivered_email->value(basket::getOrderPaidDeliveredEmail());
$form->configure->order_late_payment_email_subject->value(basket::getOrderLatePaymentEmailSubject());
$form->configure->order_late_payment_email->value(basket::getOrderLatePaymentEmail());
$form->configure->order_delivered_email_subject->value(basket::getOrderDeliveredEmailSubject());
$form->configure->order_delivered_email->value(basket::getOrderDeliveredEmail());
$form->configure->order_delivered_notpaid_email_subject->value(basket::getOrderDeliveredNotPaidEmailSubject());
$form->configure->order_delivered_notpaid_email->value(basket::getOrderDeliveredNotPaidEmail());
$form->configure->order_cancelled_email_subject->value(basket::getOrderCancelledEmailSubject());
$form->configure->order_cancelled_email->value(basket::getOrderCancelledEmail());
$form->configure->order_email_closing->value(basket::getOrderEmailClosing());
}
static function extractForm($form){
$webshop = $form->configure->webshop->value;
$website = $form->configure->website->value;
$email = $form->configure->email->value;
$is_side_bar = $form->configure->side_bar->value;
$isPaypal = $form->configure->paypal->value;
$paypal_account = $form->configure->paypal_account->value;
$currency = $form->configure->currency->selected;
$allow_pickup = $form->configure->allow_pickup->value;
$pickup_location = $form->configure->pickup_location->value;
$order_prefix = $form->configure->order_prefix->value;
$order_bankaccount = $form->configure->order_bankaccount->value;
$order_accountowner = $form->configure->order_accountowner->value;
basket::setWebshop($webshop);
basket::setWebsite($website);
basket::setEmailAddress($email);
basket::set_side_bar_only($is_side_bar);
basket::setPaypal($isPaypal);
basket::setPaypalAccount($paypal_account);
basket::setCurrency($currency);
basket::setAllowPickup($allow_pickup);
basket::setPickupLocation($pickup_location);
basket::setOrderPrefix($order_prefix);
basket::setOrderBankAccount($order_bankaccount);
basket::setOrderAccountOwner($order_accountowner);
}
static function extractTemplateForm($form){
$payment_details = $form->configure->payment_details->value;
$order_complete_page = $form->configure->order_complete_page->value;
$order_complete_email_subject = $form->configure->order_complete_email_subject->value;
$order_complete_email = $form->configure->order_complete_email->value;
$order_paid_email_subject = $form->configure->order_paid_email_subject->value;
$order_paid_email = $form->configure->order_paid_email->value;
$order_paid_delivered_email_subject = $form->configure->order_paid_delivered_email_subject->value;
$order_paid_delivered_email = $form->configure->order_paid_delivered_email->value;
$order_late_payment_email_subject = $form->configure->order_late_payment_email_subject->value;
$order_late_payment_email = $form->configure->order_late_payment_email->value;
$order_delivered_email_subject = $form->configure->order_delivered_email_subject->value;
$order_delivered_email = $form->configure->order_delivered_email->value;
$order_delivered_notpaid_email_subject = $form->configure->order_delivered_notpaid_email_subject->value;
$order_delivered_notpaid_email = $form->configure->order_delivered_notpaid_email->value;
$order_cancelled_email_subject = $form->configure->order_cancelled_email_subject->value;
$order_cancelled_email = $form->configure->order_cancelled_email->value;
$order_email_closing = $form->configure->order_email_closing->value;
basket::setPaymentDetails($payment_details);
basket::setOrderCompletePage($order_complete_page);
basket::setOrderCompleteEmailSubject($order_complete_email_subject);
basket::setOrderCompleteEmail($order_complete_email);
basket::setOrderPaidEmailSubject($order_paid_email_subject);
basket::setOrderPaidEmail($order_paid_email);
basket::setOrderPaidDeliveredEmailSubject($order_paid_delivered_email_subject);
basket::setOrderPaidDeliveredEmail($order_paid_delivered_email);
basket::setOrderLatePaymentEmailSubject($order_late_payment_email_subject);
basket::setOrderLatePaymentEmail($order_late_payment_email);
basket::setOrderDeliveredEmailSubject($order_delivered_email_subject);
basket::setOrderDeliveredEmail($order_delivered_email);
basket::setOrderDeliveredNotPaidEmailSubject($order_delivered_notpaid_email_subject);
basket::setOrderDeliveredNotPaidEmail($order_delivered_notpaid_email);
basket::setOrderCancelledEmailSubject($order_cancelled_email_subject);
basket::setOrderCancelledEmail($order_cancelled_email);
basket::setOrderEmailClosing($order_email_closing);
}
static public function is_side_bar_only(){
return module::get_var("basket","is_side_bar_only");
}
static public function set_side_bar_only($value){
module::set_var("basket","is_side_bar_only",$value);
}
static function getWebshop(){
return module::get_var("basket","webshop");
}
static function getWebsite(){
return module::get_var("basket","website");
}
static function getEmailAddress(){
return module::get_var("basket","email");
}
static function isPaypal(){
return module::get_var("basket","paypal");
}
static function getPaypalAccount(){
return module::get_var("basket","paypal_account");
}
static function getCurrency(){
$cur = module::get_var("basket","currency");
if (!isset($cur))
{
$cur = "EUR";
}
return $cur;
}
/*
* Get pickup location from user profile unless it's empty. Then get it from the general settings.
*/
static function getPickupLocation(){
$user = identity::active_user();
$user_basket = ORM::factory("user_basket")->where("id", "=", $user->id)->find();
$pickup_location = $user_basket->pickup_location;
if (($pickup_location == "") or ($pickup_location == null)) {
$pickup_location = module::get_var("basket","pickup_location");}
return $pickup_location;
}
static function getPaymentDetails(){
return module::get_var("basket","payment_details");
}
static function getOrderBankAccount(){
return module::get_var("basket","order_bankaccount");
}
static function getOrderAccountOwner(){
return module::get_var("basket","order_accountowner");
}
static function getOrderPrefix(){
return module::get_var("basket","order_prefix");
}
static function isAllowPickup(){
return module::get_var("basket","allow_pickup");
}
static function getOrderCompletePage(){
return module::get_var("basket","order_complete_page");
}
static function getOrderCompleteEmail(){
return module::get_var("basket","order_complete_email");
}
static function getOrderCompleteEmailSubject(){
return module::get_var("basket","order_complete_email_subject");
}
static function getOrderPaidEmail(){
return module::get_var("basket","order_paid_email");
}
static function getOrderPaidEmailSubject(){
return module::get_var("basket","order_paid_email_subject");
}
static function getOrderPaidDeliveredEmail(){
return module::get_var("basket","order_paid_delivered_email");
}
static function getOrderPaidDeliveredEmailSubject(){
return module::get_var("basket","order_paid_delivered_email_subject");
}
static function getOrderLatePaymentEmail(){
return module::get_var("basket","order_late_payment_email");
}
static function getOrderLatePaymentEmailSubject(){
return module::get_var("basket","order_late_payment_email_subject");
}
static function getOrderDeliveredEmail(){
return module::get_var("basket","order_delivered_email");
}
static function getOrderDeliveredEmailSubject(){
return module::get_var("basket","order_delivered_email_subject");
}
static function getOrderDeliveredNotPaidEmail(){
return module::get_var("basket","order_delivered_notpaid_email");
}
static function getOrderDeliveredNotPaidEmailSubject(){
return module::get_var("basket","order_delivered_notpaid_email_subject");
}
static function getOrderCancelledEmail(){
return module::get_var("basket","order_cancelled_email");
}
static function getOrderCancelledEmailSubject(){
return module::get_var("basket","order_cancelled_email_subject");
}
static function getOrderEmailClosing(){
return module::get_var("basket","order_email_closing");
}
static function formatMoney($money){
return self::$format[self::getCurrency()].number_format($money,2,',','.');
// return self::$format[self::getCurrency()].number_format($money,2);
}
static function formatMoneyForWeb($money){
return self::$formatweb[self::getCurrency()]." ".number_format($money,2,',','.');
//return self::$formatweb[self::getCurrency()].number_format($money,2);
}
static function formatMoneyForMail($money){
return basket::getCurrency()." ".number_format($money,2,',','.');
}
static function replaceStrings($string, $key_values) {
// Replace x_y before replacing x.
krsort($key_values, SORT_STRING);
$keys = array();
$values = array();
foreach ($key_values as $key => $value) {
$keys[] = "%$key";
$values[] = $value;
}
return str_replace($keys, $values, $string);
}
//Added 2011-10-02
static function replaceStringsAll($string, $order) {
$string_new = basket::replaceStrings($string,Array(
"name"=>$order->name,
"order_number"=> basket::getOrderPrefix().$order->id,
"total_cost" => basket::formatMoneyForMail($order->cost),
"order_details"=> $order->text,
"email"=>basket::getEmailAddress(),
"pickup_location"=> basket::getPickupLocation(),
"website"=> basket::getWebsite(),
"webshop"=> basket::getWebshop()));
return $string_new;
}
//Added 2011-10-02
static function createFullName($basket) {
if ($basket->title <> ""):$fullname = $basket->title." "; endif;
if ($basket->initials <> ""):$fullname = $fullname."".$basket->initials." "; endif;
if ($basket->insertion <> ""):$fullname = $fullname."".$basket->insertion." "; endif;
$fullname = $fullname."".$basket->name."";
return $fullname;
}
//Added 2011-10-02
static function deliveryMethod($order) {
//@TODO: configurable delivery methods
if ($order->method == Order_Model::DELIVERY_MAIL) {$delivery_method = "verstuurd per post";}
elseif ($order->method == Order_Model::DELIVERY_EMAIL) {$delivery_method = "verstuurd per e-mail";}
elseif ($order->method == Order_Model::DELIVERY_PICKUP) {$delivery_method = "klaargelegd om af te halen bij ".basket::getPickupLocation()."";}
else {$delivery_method = "GEEN LEVERINGSWIJZE BEKEND";}
return $delivery_method;
}
static function setWebshop($webshop){
module::set_var("basket","webshop",$webshop);
}
static function setWebsite($website){
module::set_var("basket","website",$website);
}
static function setEmailAddress($email){
module::set_var("basket","email",$email);
}
static function setPaypal($paypal){
module::set_var("basket","paypal",$paypal);
}
static function setPaypalAccount($paypal_account){
module::set_var("basket","paypal_account",$paypal_account);
}
static function setCurrency($currency){
module::set_var("basket","currency",$currency);
}
static function setPickupLocation($pickup_location){
module::set_var("basket","pickup_location",$pickup_location);
}
static function setPaymentDetails($details){
module::set_var("basket","payment_details",$details);
}
static function setOrderBankAccount($order_bankaccount){
module::set_var("basket","order_bankaccount",$order_bankaccount);
}
static function setOrderAccountOwner($order_accountowner){
module::set_var("basket","order_accountowner",$order_accountowner);
}
static function setAllowPickup($allow_pickup){
module::set_var("basket","allow_pickup",$allow_pickup);
}
static function setOrderPrefix($order_prefix){
module::set_var("basket","order_prefix",strtolower($order_prefix));
}
static function setOrderCompletePage($details){
module::set_var("basket","order_complete_page",$details);
}
static function setOrderCompleteEmail($details){
module::set_var("basket","order_complete_email",$details);
}
static function setOrderCompleteEmailSubject($details){
module::set_var("basket","order_complete_email_subject",$details);
}
static function setOrderLatePaymentEmail($details){
module::set_var("basket","order_late_payment_email",$details);
}
static function setOrderLatePaymentEmailSubject($details){
module::set_var("basket","order_late_payment_email_subject",$details);
}
static function setOrderPaidEmail($details){
module::set_var("basket","order_paid_email",$details);
}
static function setOrderPaidEmailSubject($details){
module::set_var("basket","order_paid_email_subject",$details);
}
static function setOrderPaidDeliveredEmail($details){
module::set_var("basket","order_paid_delivered_email",$details);
}
static function setOrderPaidDeliveredEmailSubject($details){
module::set_var("basket","order_paid_delivered_email_subject",$details);
}
static function setOrderDeliveredEmail($details){
module::set_var("basket","order_delivered_email",$details);
}
static function setOrderDeliveredEmailSubject($details){
module::set_var("basket","order_delivered_email_subject",$details);
}
static function setOrderDeliveredNotPaidEmail($details){
module::set_var("basket","order_delivered_notpaid_email",$details);
}
static function setOrderDeliveredNotPaidEmailSubject($details){
module::set_var("basket","order_delivered_notpaid_email_subject",$details);
}
static function setOrderCancelledEmail($details){
module::set_var("basket","order_cancelled_email",$details);
}
static function setOrderCancelledEmailSubject($details){
module::set_var("basket","order_cancelled_email_subject",$details);
}
static function setOrderEmailClosing($details){
module::set_var("basket","order_email_closing",$details);
}
static function createOrder($basket, $method){
// fill customer record; added 2011-08-20
$customer = ORM::factory("customer");
$customer->title=$basket->title;
$customer->initials=$basket->initials;
$customer->insertion=$basket->insertion;
$customer->name=$basket->name;
$customer->street=$basket->street;
$customer->housenumber=$basket->house;
$customer->postalcode=$basket->postcode;
$customer->town=$basket->town;
$customer->email=$basket->email;
$customer->phone=$basket->phone;
// $customer->childname=$basket->childname;
// $customer->childgroup=$basket->childgroup;
$customer->deliverypref=$basket->ispp();
$customer->save();
$order = ORM::factory("order");
$order->text = "processing";
$order->customerid=$customer->id;
$order->save();
$ordernumber = basket::getOrderPrefix().$order->id;
$order_bankaccount = basket::getOrderBankAccount();
$order_accountowner = basket::getOrderAccountOwner();
$order_email_closing = basket::getOrderEmailClosing();
//$admin_address = basket::getEmailAddress();
$website=basket::getWebsite();
$postage = $basket->postage_cost();
$product_cost = $basket->cost();
$street = $basket->street;
$fullname = basket::createFullName($basket);
$ppon = $basket->ispp();
if ($ppon){
$total_cost = ($product_cost+$postage);
}
else{
$total_cost = $product_cost;
}
// added Dutch mailtext JtK
//set the timezone to show correct order time
date_default_timezone_set('Europe/Amsterdam');
$text = "U kunt betalen door het totaalbedrag over te maken op de bankrekening van %webshop.
Totaalbedrag: ".basket::formatMoneyForMail($total_cost)."
Rekeningnummer: ".$order_bankaccount."
tnv ".$order_accountowner."
ovv bestelnummer ".$ordernumber."
De aflevering vindt plaats circa 10 werkdagen nadat uw betaling is ontvangen door %webshop.
Voor vragen of opmerkingen over uw bestelling kunt u contact opnemen via bestelling@%website.
BESTELGEGEVENS
Bestelnummer: ".$ordernumber."
Besteld op ".date("d-m-Y G:i")."
Bestemd voor:
".$fullname."";
if ($street <> ""){
$text = $text."
".$basket->street." ".$basket->house."
".$basket->postcode." ".$basket->town."";
}
$text = $text."
E-mail: ".$basket->email."";
if ($basket->phone <> ""){
$text = $text."
Telefoon: ".$basket->phone."
"; }
if ($basket->comments <> ""){
$text = $text."
Opmerking bij de bestelling: ".$basket->comments."
"; }
$text = $text."
Bestelbedrag: ".basket::formatMoneyForMail($product_cost);
// continue with payment details
// posting by normal mail
if ($ppon && $postage > 0){
$method = Order_Model::DELIVERY_MAIL;
$text = $text."
Verpakkings- en verzendkosten: ".basket::formatMoneyForMail($postage)."
Bestelling wordt verstuurd via post.";
}
// pickup
elseif (!$ppon && $postage > 0){
$method = Order_Model::DELIVERY_PICKUP;
$text = $text."
Bestelling afhalen bij %pickup_location.";
}
// posting by e-mail
else{
$method = Order_Model::DELIVERY_EMAIL;
$text = $text."
Bestelling wordt verstuurd via e-mail.";
}
$text = $text."
Totaalbedrag: ".basket::formatMoneyForMail($total_cost)."";
// continue with order details
$text = $text."
Bestelde foto's:";
// create the order items
foreach ($basket->contents as $basket_item){
$item = $basket_item->getItem();
$prod = ORM::factory("product", $basket_item->product);
$text = $text."
-> ".$item->title."
".$prod->name." - ".$prod->description."
aantal: ".$basket_item->quantity." a ".basket::formatMoneyForMail($prod->cost)."
"; }
// continue with footer
$text = $text."
".$order_email_closing."";
//replace variables
$text = basket::replaceStringsAll($text,$order);
$order->name = $fullname;
$order->email = $basket->email;
$order->cost = $total_cost;
$order->text = $text;
$order->status = Order_Model::WAITING_PAYMENT;
$order->method = $method;
$order->save();
//$basket->clear();
return $order;
}
public function send_order($order){
/* internal order mail */
$to = basket::getEmailAddress();
$from = "From: ".basket::getEmailAddress();
$subject = "Bestelling ".basket::getOrderPrefix().$order->id." van ".$order->name;
$body = $order->text;
//send mail
mail($to, $subject, $body, $from);
}
public function send_invoice($order){
// order confirmation mail to customer
$to = $order->email;
$from = "From: ".basket::getEmailAddress();
$subject = basket::replaceStringsAll(basket::getOrderCompleteEmailSubject(),$order);
$body = basket::getOrderCompleteEmail();
//replace variables
$body = basket::replaceStringsAll($body,$order);
//send mail
mail($to, $subject, $body, $from);
}
public function send_invoice_copy($order){
// order confirmation mail to customer
$to = $order->email;
$from = "From: ".basket::getEmailAddress();
$subject = basket::replaceStringsAll(basket::getOrderCompleteEmailSubject(),$order);
$subject = $subject." (KOPIE)";
$body = basket::getOrderCompleteEmail();
//replace variables
$body = basket::replaceStringsAll($body,$order);
//send mail
mail($to, $subject, $body, $from);
}
public function send_payment_confirmation($order){
// payment confirmation mail to customer
$to = $order->email;
$from = "From: ".basket::getEmailAddress();
if ($order->status == Order_Model::PAYMENT_CONFIRMED) {
$subject = basket::replaceStringsAll(basket::getOrderPaidEmailSubject(),$order);
$body = basket::getOrderPaidEmail();
}
elseif ($order->status == Order_Model::DELIVERED) {
$subject = basket::replaceStringsAll(basket::getOrderPaidDeliveredEmailSubject(),$order);
$body = basket::getOrderPaidDeliveredEmail();
}
$body = $body."
".basket::getOrderEmailClosing()."";
//replace variables
$body = basket::replaceStringsAll($body,$order);
//send mail
mail($to, $subject, $body, $from);
}
public function send_payment_reminder($order){
// payment reminder mail to customer
$to = $order->email;
/*
@TODO: replace with getEmailAdressFrom
*/
$from = "From: ".basket::getEmailAddress();
$subject = basket::replaceStringsAll(basket::getOrderLatePaymentEmailSubject(),$order);
$body = basket::getOrderLatePaymentEmail()."
".basket::getOrderEmailClosing()."
OORSPRONKELIJKE BESTELGEGEVENS
".$order->text."";
//replace variables
$body = basket::replaceStringsAll($body,$order);
//send mail
mail($to, $subject, $body, $from);
}
public function send_delivery_confirmation($order){
// delivered confirmation mail to customer
$to = $order->email;
$from = "From: ".basket::getEmailAddress();
if ($order->status == Order_Model::DELIVERED) {
$subject = basket::replaceStringsAll(basket::getOrderdeliveredEmailSubject(),$order);
$body = basket::getOrderDeliveredEmail();
}
elseif ($order->status == Order_Model::DELIVERED_NOTPAID) {
$subject = basket::replaceStringsAll(basket::getOrderDeliveredNotPaidEmailSubject(),$order);
$body = basket::getOrderDeliveredNotPaidEmail();
}
$body = $body."
".basket::getOrderEmailClosing()."";
//replace variables
$body = basket::replaceStringsAll($body,$order);
$body = basket::replaceStrings($body,Array("delivery_method"=>basket::deliveryMethod($order)));
//send mail
mail($to, $subject, $body, $from);
}
public function send_cancellation_confirmation($order){
// delivery cancelled mail to customer
$to = $order->email;
$from = "From: ".basket::getEmailAddress();
$subject = basket::replaceStringsAll(basket::getOrderCancelledEmailSubject(),$order);
$body = basket::getOrderCancelledEmail()."
".basket::getOrderEmailClosing()."";
//replace variables
$body = basket::replaceStringsAll($body,$order);
//send mail
mail($to, $subject, $body, $from);
}
}

View File

@ -0,0 +1,21 @@
<?php defined("SYSPATH") or die("No direct script access.");
class basket_block_Core {
static function get_site_list() {
return array("shopping" => t("Basket"));
}
static function get($block_id, $theme) {
$block = "";
switch ($block_id) {
case "shopping":
$block = new Block();
$block->css_id = "g-view-basket";
$block->title = t("Basket");
$block->content = new View("basket-side-bar.html");
$block->content->basket = Session_Basket::get();
break;
}
return $block;
}
}

View File

@ -0,0 +1,127 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class basket_event_Core{
/**
* adds the shopping basket administration controls to the admin menu
*/
static function admin_menu($menu, $theme){
$menu->add_after("users_groups",
$basket_menu = Menu::factory("submenu")
->id("basket_menu")
->label(t("Basket")));
$basket_menu->append(
Menu::factory("link")
->id("configure")
->label(t("Configure"))
->url(url::site("admin/configure")));
$basket_menu->append(
Menu::factory("link")
->id("templates")
->label(t("Templates"))
->url(url::site("admin/configure/templates")));
$basket_menu->append(
Menu::factory("link")
->id("product_line")
->label(t("Product Lines"))
->url(url::site("admin/product_lines")));
$basket_menu->append(
Menu::factory("link")
->id("postage_bands")
->label(t("Postage Bands"))
->url(url::site("admin/postage_bands")));
$basket_menu->append(
Menu::factory("link")
->id("view_orders")
->label(t("View Orders"))
->url(url::site("basket/view_orders")));
$basket_menu->append(
Menu::factory("link")
->id("view_all_orders")
->label(t("View All Orders"))
->url(url::site("basket/view_all_orders")));
}
static function item_edit_form($item, $form){
$group = $form->group("products")->label(t("Available Products"));
$product_override = ORM::factory("product_override")->where('item_id', "=", $item->id)->find();
$group->checkbox("all")->label(t("No products except.."));
if ($product_override->loaded()){
$group->all->checked($product_override->none);
}
$products = ORM::factory("product")->find_all();
foreach ($products as $product){
$p_group = $group->group("product_$product->id")->label(t("$product->description"));
$description = $product->description;
$cost = $product->cost;
$checked = false;
if ($product_override->loaded()){
$item_product = ORM::factory("item_product")
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded()){
$checked = $item_product->include;
if ($item_product->cost != -1){
$cost = $item_product->cost;
}
}
}
$p_group->checkbox("exclude_$product->id")->label($description)->checked($checked);
$p_group->input("cost_$product->id")->label(t("Cost"))->value($cost);
//$producta[$product->id] = $product->description." (".basket::formatMoney($product->cost).")";
}
}
static function item_edit_form_completed($item, $form){
$product_override = ORM::factory("product_override")->where('item_id', "=", $item->id)->find();
if ($form->products->all->checked)
{
$product_override->none = $form->products->all->checked;
$product_override->item_id=$item->id;
$product_override->save();
$products = ORM::factory("product")->find_all();
foreach ($products as $product){
$p_group = $form->products->__get("product_$product->id");
$item_product = ORM::factory("item_product")
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
$item_product->include = $p_group->__get("exclude_$product->id")->checked;
$item_product->cost = $p_group->__get("cost_$product->id")->value;
$item_product->product_id = $product->id;
$item_product->product_override_id = $product_override->id;
$item_product->save();
}
}
else
{
if ($product_override->loaded()){
$product_override->delete();
}
}
}
}

View File

@ -0,0 +1,299 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class basket_installer
{
static function install(){
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {products} (
`id` int(9) NOT NULL auto_increment,
`name` TEXT NOT NULL,
`cost` DECIMAL(10,2) default 0,
`description` varchar(1024),
`postage_band_id` int(9) default 1,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {product_overrides} (
`id` int(9) NOT NULL auto_increment,
`item_id` int(9) NOT NULL,
`none` BOOLEAN default false,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {item_products} (
`id` int(9) NOT NULL auto_increment,
`product_override_id` int(9) NOT NULL,
`product_id` int(9) NOT NULL,
`include` BOOLEAN default false,
`cost` DECIMAL(10,2) default -1,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (
`id` int(9) NOT NULL auto_increment,
`name` TEXT NOT NULL,
`flat_rate` DECIMAL(10,2) default 0,
`per_item` DECIMAL(10,2) default 0,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
//2011-08-20 added customerid
$db->query("CREATE TABLE IF NOT EXISTS {orders} (
`id` int(9) NOT NULL auto_increment,
`customerid` int(9) NOT NULL,
`status` int(9) DEFAULT 0,
`name` varchar(512),
`email` varchar(256),
`cost` DECIMAL(10,2) default 0,
`method` int(9) DEFAULT 0,
`text` TEXT NOT NULL,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
//2011-08-20 added table
$db->query("CREATE TABLE IF NOT EXISTS {customers} (
`id` int(9) NOT NULL AUTO_INCREMENT,
`title` varchar(32) DEFAULT NULL,
`name` varchar(256) NOT NULL,
`initials` varchar(64) DEFAULT NULL,
`insertion` varchar(16) DEFAULT NULL,
`street` varchar(128) DEFAULT NULL,
`housenumber` varchar(32) DEFAULT NULL,
`postalcode` varchar(16) DEFAULT NULL,
`town` varchar(128) DEFAULT NULL,
`email` varchar(128) NOT NULL,
`phone` varchar(16) DEFAULT NULL,
`childname` varchar(64) DEFAULT NULL,
`childgroup` varchar(32) DEFAULT NULL,
`deliverypref` tinyint(2) DEFAULT NULL,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
//2011-05-01 added table
$db->query("CREATE TABLE IF NOT EXISTS {order_logs} (
`id` int(9) NOT NULL,
`status` int(9) NOT NULL,
`event` int(9) NOT NULL,
`timestamp` int(9) NOT NULL)
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS `ipn_messages` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`date` int(11) NOT NULL,
`key` varchar(20) NOT NULL,
`txn_id` varchar(20) NOT NULL,
`status` varchar(20) NOT NULL,
`success` bool default false,
`text` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
/* name, fixed cost, per item cost */
/* postage_band::create("Geen verzendkosten",0,0);
postage_band::create("Standaard verzendkosten",2,0);
postage_band::create("Verzending via e-mail (gratis)",0,0);
*/
/* name, cost, descr, postageband id */
/* product::create("13x18",3.5,"Afdruk 13x18 cm glanzend",2);
product::create("2x 13x18",5,"ACTIE: Dubbele afdruk 13x18 cm glanzend",2);
product::create("Origineel",7.5,"Originele fotobestand in hoge resolutie",3);
product::create("8 Pasfoto's+9x13",4,"Vel met 8 pasfoto's + afdruk 9x13",2);
product::create("16 Pasfoto's",4,"Vel met 16 pasfoto's glanzend",2);
product::create("10x15",2.5,"Afdruk 10x15 cm glanzend",2);
product::create("20x30",6,"Afdruk 20x30 cm glanzend",2);
product::create("30x45",10,"Afdruk 30x45 cm glanzend",2);
product::create("13x18 (korting)",1.75,"Afdruk 13x18 cm glanzend",2);
product::create("20x30 (korting)",3,"Afdruk 20x30 cm glanzend",2);
product::create("Origineel (korting)",2.5,"Originele fotobestand in hoge resolutie",3);
*/
/* basket config settings */
basket::setWebsite("kidsfotos.nl");
basket::setWebshop("KidsFotos");
basket::setEmailAddress("KidsFotos.nl <bestelling@kidsfotos.nl>");
basket::set_side_bar_only("1");
basket::setAllowPickup("1");
basket::setPickupLocation("De Blauwe Walvis");
basket::setOrderPrefix("2012-");
basket::setOrderBankAccount("59.24.98.220");
basket::setOrderAccountOwner("J. ten Kate, Utrecht");
/* basket template settings */
basket::setPaymentDetails("
<p>U kunt betalen via overmaking op de bankrekening van %webshop.</p>
<p>Instructies vindt u in de bevestingsmail van de bestelling.</p>
<br />
<h3>Algemene voorwaarden</h3>
<p>U kunt de Algemene voorwaarden via deze <a href=#/downloads/Algemene_voorwaarden_2011.pdf# target=#_blank#>link</a> bekijken.</p>");
basket::setOrderCompletePage(
"<p>Hartelijk dank voor uw bestelling. Uw bestelnummer is </b>%order_number</b>.</p>
<br />
<p>%webshop heeft een bevestigingsmail verzonden met de gegevens van uw bestelling en de betalingsinformatie.
<p>Wij verwerken de bestelling zodra de betaling is ontvangen.
<br />
<p>Voor vragen of opmerkingen over uw bestelling kunt u contact opnemen via bestelling@%website</p>");
basket::setOrderCompleteEmailSubject("Uw bestelling %order_number bij %webshop");
basket::setOrderCompleteEmail("Beste %name,
Hartelijk dank voor uw bestelling. De bestelgegevens en betalingsinformatie vindt u hieronder.
%order_details");
basket::setOrderPaidEmailSubject("Update van uw bestelling %order_number bij %webshop: betaling ontvangen");
basket::setOrderPaidEmail("Beste %name,
%webshop heeft uw betaling van %total_cost ontvangen en zal bestelling %order_number verwerken.
U ontvangt een e-mail zodra de bestelling naar u wordt verzonden of klaarligt op het kinderdagverblijf.
Voor vragen of opmerkingen over uw bestelling kunt u contact opnemen via bestelling@%website.");
basket::setOrderLatePaymentEmailSubject("Uw bestelling %order_number bij %webshop: wacht op betaling");
basket::setOrderLatePaymentEmail("Beste %name,
Enige tijd geleden heeft u bij %webshop bestelling %order_number geplaatst. Onderaan vindt u hiervan de details.
Uit onze administratie blijkt dat het bedrag van %total_cost nog niet is voldaan. Wij maken u erop attent dat wij pas na ontvangst van de betaling de bestelling verwerken.
Mocht deze herinnering uw betaling hebben gekruist, dan kunt u deze als niet verzonden beschouwen.
Voor vragen of opmerkingen over uw bestelling kunt u contact opnemen via bestelling@%website.");
basket::setOrderDeliveredEmailSubject("Update van uw bestelling %order_number bij %webshop: bestelling verstuurd");
basket::setOrderDeliveredEmail("Beste %name,
%webshop heeft uw bestelling %order_number %delivery_method.
Nogmaals dank voor uw bestelling en veel plezier met de foto's!
Voor vragen of opmerkingen over uw bestelling kunt u contact opnemen via bestelling@%website.");
basket::setOrderEmailClosing("Met vriendelijke groet,
%webshop.nl - Fotograaf Jeroen ten Kate");
module::set_version("basket", 5);
}
static function upgrade($version) {
$db = Database::instance();
if ($version == 1) {
// fix for allowing decimel place in money
$db->query("ALTER TABLE {products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default 0;");
$db->query("ALTER TABLE {item_products} CHANGE COLUMN `cost` `cost` DECIMAL(10,2) default -1;");
// postage bands
$db->query("ALTER TABLE {products} ADD COLUMN `postage_band_id` int(9) default 1");
$db->query("CREATE TABLE IF NOT EXISTS {postage_bands} (
`id` int(9) NOT NULL auto_increment,
`name` TEXT NOT NULL,
`flat_rate` DECIMAL(10,2) default 0,
`per_item` DECIMAL(10,2) default 0,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
postage_band::create("No Postage",0,0);
module::set_version("basket", $version = 2);
}
if ($version == 2) {
$db->query("CREATE TABLE IF NOT EXISTS {orders} (
`id` int(9) NOT NULL auto_increment,
`text` TEXT NOT NULL,
PRIMARY KEY (`id`))
ENGINE=InnoDB DEFAULT CHARSET=utf8;");
basket::setPaymentDetails(
"<p>Use the following options to pay for this order.</p>
<p>Send a chequre to..</p>
<p>Visit the shop..</p>
<p>By using internet banking..</p>"
);
basket::setOrderPrefix("ORDER");
basket::setOrderCompletePage(
"<p>Your order number is %order_number. To pay for this order please either:</p>
<p> - Send a cheque for %total_cost to with reference %order_number..</p>
<p> - Visit the shop and quote the order %order_number..</p>
<p> - Transfer %total_cost using internet banking with reference %order_number..</p>
<p>Order will be processed as soon as payment is received. You should receive an e-mail with your order details shortly.</p>"
);
basket::setOrderCompleteEmail(
"Hi %name,
Thank you for your order the order details are below. To pay for this order please either:
- Send a cheque for %total_cost to with reference %order_number..
- Visit the shop and quote the order %order_number..
- Transfer %total_cost using internet banking with reference %order_number..
Order will be processed as soon as payment is received. For order pick-ups please visit..
Order Details
-------------
%order_details
Thanks");
basket::setOrderCompleteEmailSubject(
"Photography Order %order_number");
module::set_version("basket", $version = 3);
}
if ($version ==3 ){
$db->query("ALTER TABLE {orders} ADD COLUMN `status` int(9) DEFAULT 0;");
$db->query("CREATE TABLE IF NOT EXISTS {ipn_messages} (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`date` int(11) NOT NULL,
`key` varchar(20) NOT NULL,
`txn_id` varchar(20) NOT NULL,
`status` varchar(20) NOT NULL,
`success` bool default false,
`text` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
module::set_version("basket", $version = 4);
}
if ($version==4){
$db->query("ALTER TABLE {orders} ADD COLUMN `name` varchar(1024);");
$db->query("ALTER TABLE {orders} ADD COLUMN `email` varchar(1024);");
$db->query("ALTER TABLE {orders} ADD COLUMN `method` int(9) DEFAULT 0;");
$db->query("ALTER TABLE {orders} ADD COLUMN `cost` DECIMAL(10,2) default 0");
module::set_version("basket", $version = 5);
}
//
if ($version==5){
$db->query("ALTER TABLE {orders} ADD COLUMN `customerid` int(9) NOT NULL;");
$db->query("ALTER TABLE {customers} ADD COLUMN `childname` varchar(64);");
$db->query("ALTER TABLE {customers} ADD COLUMN `childgroup` varchar(32);");
module::set_version("basket", $version = 6);
}
}
static function uninstall(){
$db = Database::instance();
$db->query("DROP TABLE IF EXISTS {products}");
$db->query("DROP TABLE IF EXISTS {product_overrides}");
$db->query("DROP TABLE IF EXISTS {item_products}");
$db->query("DROP TABLE IF EXISTS {postage_bands}");
//$db->query("DROP TABLE IF EXISTS {orders}");
}
}

View File

@ -0,0 +1,56 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class basket_theme_Core {
static function head($theme) {
$theme->css("basket.css");
}
static function header_top($theme) {
if (!basket::is_side_bar_only())
{
$view = new View("basket.html");
$view->basket = Session_Basket::get();
return $view->render();
}
return "";
}
static function admin_head($theme) {
if (strpos(Router::$current_uri, "admin/product_lines") !== false) {
$theme->script("gallery.panel.js");
}
}
static function photo_top($theme){
if (!basket::is_side_bar_only())
{
if ( product::isForSale($theme->item()->id)){
$view = new View("add_to_basket.html");
$view->item = $theme->item();
return $view->render();
}
}
return "";
}
}

View File

@ -0,0 +1,46 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class order_log {
const ORDERED = 1;
const PAID = 2;
const LATE_PAYMENT = 3;
const COPY_SENT = 9;
const DELIVERED_NOTPAID = 10;
const DELIVERED = 20;
const EXPIRED = 30;
const CANCELLED = 99;
/**
* Add a log entry.
*
* @param string $category an arbitrary category we can use to filter log messages
* @param string $message a detailed log message
* @param integer $severity INFO, WARNING or ERROR
* @param string $html an html snippet presented alongside the log message to aid the admin
*/
static function log($order, $event) {
$log = ORM::factory("order_log");
$log->id = $order->id;
$log->status = $order->status;
$log->event = $event;
$log->timestamp = time();
$log->save();
}
}

View File

@ -0,0 +1,97 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class postage_band_Core {
static function get_add_form_admin() {
$form = new Forge("admin/postage_bands/add_postage_band", "", "post", array("id" => "gAddPostageForm"));
$group = $form->group("add_postage")->label(t("Add Postage Band"));
$group->input("name")->label(t("Name"))->id("gPostageName")
->error_messages("in_use", t("There is already a postage band with that name"));
$group->input("flat_rate")->label(t("Flat Rate"))->id("gFlatRate");
$group->input("per_item")->label(t("Per Item"))->id("gPetItem");
$group->submit("")->value(t("Add Postage Band"));
$postage = ORM::factory("postage_band");
return $form;
}
static function get_edit_form_admin($postage) {
$form = new Forge("admin/postage_bands/edit_postage_band/$postage->id", "", "post",
array("id" => "gEditPostageForm"));
$group = $form->group("edit_postage")->label(t("Edit Postage Band"));
$group->input("name")->label(t("Name"))->id("gPostageName")->value($postage->name);
$group->inputs["name"]->error_messages(
"in_use", t("There is already a postage band with that name"));
$group->input("flat_rate")->label(t("Flat Rate"))->id("gFlatRate")->value($postage->flat_rate);
$group->input("per_item")->label(t("Per Item"))->id("gPetItem")->
value($postage->per_item);
$group->submit("")->value(t("Modify Postage Band"));
return $form;
}
static function get_delete_form_admin($postage) {
$form = new Forge("admin/postage_bands/delete_postage_band/$postage->id", "", "post",
array("id" => "gDeletePostageForm"));
$group = $form->group("delete_postage")->label(
t("Are you sure you want to delete postage band %name?", array("name" => $postage->name)));
$group->submit("")->value(t("Delete postage band %name", array("name" => $postage->name)));
return $form;
}
/**
* Create a new postage band
*
* @param string $name
* @param string $full_name
* @param string $password
* @return User_Model
*/
static function create($name, $flatrate, $peritemcost) {
$postage = ORM::factory("postage_band")->where("name", "=", $name)->find();
if ($postage->loaded()) {
throw new Exception("@todo postage already EXISTS $name");
}
$postage->name = $name;
$postage->flat_rate = $flatrate;
$postage->per_item = $peritemcost;
$postage->save();
return $postage;
}
/**
* returns the array of postage bands
* @return an array of postage bands
*/
static function getPostageArray(){
$postagea = array();
$postages = ORM::factory("postage_band")->find_all();
foreach ($postages as $postage){
$show = true;
$postagea[$postage->id] = $postage->name;
}
return $postagea;
}
}

View File

@ -0,0 +1,189 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class product_Core {
static function get_add_form_admin() {
$form = new Forge("admin/product_lines/add_product", "", "post", array("id" => "gAddProductForm"));
$group = $form->group("add_product")->label(t("Add Product"));
$group->input("name")->label(t("Name"))->id("gProductName")
->error_messages("in_use", t("There is already a product with that name"));
$group->input("cost")->label(t("Cost"))->id("gCost");
$group->input("description")->label(t("Description"))->id("gDescription");
$group->dropdown("postage_band")
->label(t("Postage Band"))
->options(postage_band::getPostageArray());
$group->submit("")->value(t("Add Product"));
$product = ORM::factory("product");
return $form;
}
static function get_edit_form_admin($product) {
$form = new Forge("admin/product_lines/edit_product/$product->id", "", "post",
array("id" => "gEditProductForm"));
$group = $form->group("edit_product")->label(t("Edit Product"));
$group->input("name")->label(t("Name"))->id("gProductName")->value($product->name);
$group->inputs["name"]->error_messages(
"in_use", t("There is already a product with that name"));
$group->input("cost")->label(t("Cost"))->id("gCost")->value($product->cost);
$group->input("description")->label(t("Description"))->id("gDescription")->
value($product->description);
$group->dropdown("postage_band")
->label(t("Postage Band"))
->options(postage_band::getPostageArray())
->selected($product->postage_band_id);
$group->submit("")->value(t("Modify Product"));
return $form;
}
static function get_delete_form_admin($product) {
$form = new Forge("admin/product_lines/delete_product/$product->id", "", "post",
array("id" => "gDeleteProductForm"));
$group = $form->group("delete_product")->label(
t("Are you sure you want to delete product %name?", array("name" => $product->name)));
$group->submit("")->value(t("Delete product %name", array("name" => $product->name)));
return $form;
}
/**
* Create a new product
*
* @param string $name
* @param string $full_name
* @param string $password
* @return User_Model
*/
static function create($name, $cost, $description, $postage_band) {
$product = ORM::factory("product")->where("name", "=", $name)->find();
if ($product->loaded()) {
throw new Exception("@todo USER_ALREADY_EXISTS $name");
}
$product->name = $name;
$product->cost = $cost;
$product->description = $description;
$product->postage_band_id = $postage_band;
$product->save();
return $product;
}
static function getProductArray($id){
$producta = array();
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', "=", $id)->find();
if (!$product_override->loaded()){
// no override found so check parents
// check parents for product override
$item = ORM::factory("item",$id);
$parents = $item->parents();
foreach ($parents as $parent){
// check for product override
$temp_override = ORM::factory("product_override")->where('item_id', "=", $parent->id)->find();
if ($temp_override ->loaded()){
$product_override = $temp_override;
//break;
}
}
}
$products = ORM::factory("product")->find_all();
foreach ($products as $product){
$show = true;
$cost = $product->cost;
if ($product_override->loaded()){
$show = !$product_override->none;
$item_product = ORM::factory("item_product")
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded()){
$cost = $item_product->cost;
if (!$show){
$show = $item_product->include;
}
}
}
if ($show)
{
$producta[$product->id] = html::clean($product->description)." (".basket::formatMoneyForWeb($cost).")";
}
}
return $producta;
}
static function isForSale($id){
try
{
// check for product override
$product_override = ORM::factory("product_override")->where('item_id', "=", $id)->find();
if (!$product_override->loaded()){
// no override found so check parents
// check parents for product override
$item = ORM::factory("item",$id);
$parents = $item->parents();
foreach ($parents as $parent){
// check for product override
$temp_override = ORM::factory("product_override")->where('item_id', "=", $parent->id)->find();
if ($temp_override ->loaded()){
$product_override = $temp_override;
//break;
}
}
}
$products = ORM::factory("product")->find_all();
if ($product_override->loaded() && $product_override->none){
foreach ($products as $product){
$item_product = ORM::factory("item_product")
->where('product_override_id', "=", $product_override->id)
->where('product_id', "=", $product->id)->find();
if ($item_product->loaded()){
if ($item_product->include){
return true;
}
}
}
return false;
} else {
return count($products) > 0;
}
}
catch (Exception $e)
{
echo $e;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

View File

@ -0,0 +1,330 @@
<?php
/*******************************************************************************
* PHP Paypal IPN Integration Class
*******************************************************************************
* Author: Micah Carrick
* Email: email@micahcarrick.com
* Website: http://www.micahcarrick.com
*
* File: paypal.class.php
* Version: 1.3.0
* Copyright: (c) 2005 - Micah Carrick
* You are free to use, distribute, and modify this software
* under the terms of the GNU General Public License. See the
* included license.txt file.
*
*******************************************************************************
* VERION HISTORY:
* v1.3.0 [10.10.2005] - Fixed it so that single quotes are handled the
* right way rather than simple stripping them. This
* was needed because the user could still put in
* quotes.
*
* v1.2.1 [06.05.2005] - Fixed typo from previous fix :)
*
* v1.2.0 [05.31.2005] - Added the optional ability to remove all quotes
* from the paypal posts. The IPN will come back
* invalid sometimes when quotes are used in certian
* fields.
*
* v1.1.0 [05.15.2005] - Revised the form output in the submit_paypal_post
* method to allow non-javascript capable browsers
* to provide a means of manual form submission.
*
* v1.0.0 [04.16.2005] - Initial Version
*
*******************************************************************************
* DESCRIPTION:
*
* NOTE: See www.micahcarrick.com for the most recent version of this class
* along with any applicable sample files and other documentaion.
*
* This file provides a neat and simple method to interface with paypal and
* The paypal Instant Payment Notification (IPN) interface. This file is
* NOT intended to make the paypal integration "plug 'n' play". It still
* requires the developer (that should be you) to understand the paypal
* process and know the variables you want/need to pass to paypal to
* achieve what you want.
*
* This class handles the submission of an order to paypal aswell as the
* processing an Instant Payment Notification.
*
* This code is based on that of the php-toolkit from paypal. I've taken
* the basic principals and put it in to a class so that it is a little
* easier--at least for me--to use. The php-toolkit can be downloaded from
* http://sourceforge.net/projects/paypal.
*
* To submit an order to paypal, have your order form POST to a file with:
*
* $p = new paypal_class;
* $p->add_field('business', 'somebody@domain.com');
* $p->add_field('first_name', $_POST['first_name']);
* ... (add all your fields in the same manor)
* $p->submit_paypal_post();
*
* To process an IPN, have your IPN processing file contain:
*
* $p = new paypal_class;
* if ($p->validate_ipn()) {
* ... (IPN is verified. Details are in the ipn_data() array)
* }
*
*
* In case you are new to paypal, here is some information to help you:
*
* 1. Download and read the Merchant User Manual and Integration Guide from
* http://www.paypal.com/en_US/pdf/integration_guide.pdf. This gives
* you all the information you need including the fields you can pass to
* paypal (using add_field() with this class) aswell as all the fields
* that are returned in an IPN post (stored in the ipn_data() array in
* this class). It also diagrams the entire transaction process.
*
* 2. Create a "sandbox" account for a buyer and a seller. This is just
* a test account(s) that allow you to test your site from both the
* seller and buyer perspective. The instructions for this is available
* at https://developer.paypal.com/ as well as a great forum where you
* can ask all your paypal integration questions. Make sure you follow
* all the directions in setting up a sandbox test environment, including
* the addition of fake bank accounts and credit cards.
*
*******************************************************************************
*/
class Paypal_Core {
var $last_error; // holds the last error encountered
var $ipn_response; // holds the IPN response from paypal
public $ipn_data = array(); // array contains the POST values for IPN
var $fields = array(); // array holds the fields to submit to paypal
public function __construct()
{
// initialization constructor. Called when class is created.
// sandbox paypal
//$this->paypal_url = "https://www.sandbox.paypal.com/cgi-bin/webscr";
//$this->secure_url = "ssl://www.sandbox.paypal.com";
// normal paypal
$this->paypal_url = "https://www.paypal.com/cgi-bin/webscr";
$this->secure_url = "ssl://www.paypal.com";
$this->last_error = '';
//$this->ipn_log_file = Kohana::log_directory().Kohana::config('paypal.ipn_logfile');
//$this->ipn_log = true;
$this->ipn_response = '';
// populate $fields array with a few default values. See the paypal
// documentation for a list of fields and their data types. These defaul
// values can be overwritten by the calling script.
}
function add_field($field, $value) {
// adds a key=>value pair to the fields array, which is what will be
// sent to paypal as POST variables. If the value is already in the
// array, it will be overwritten.
$this->fields["$field"] = $value;
}
public function process($session_basket, $return_url, $cancel_url, $notify_url){
$this->add_field('rm','2');
$this->add_field('cmd','_cart');
$this->add_field('upload','1');
$this->add_field('currency_code', basket::getCurrency());
$this->add_field('business', basket::getPaypalAccount());
// IPN stuff
$this->add_field('return', $return_url);
$this->add_field('cancel_return', $cancel_url);
$this->add_field('notify_url', $notify_url);
// postage
if ($session_basket->ispp()){
$postage = $session_basket->postage_cost();
if ($postage > 0) {
$this->add_field('shipping_1',$postage);
}
}
// basket contents
$id = 1;
foreach ($session_basket->contents as $key => $basket_item){
$this->add_field("item_name_$id", $basket_item->getCode());
$this->add_field("amount_$id", $basket_item->cost_per);
$this->add_field("quantity_$id",$basket_item->quantity);
$id++;
}
// shipping address
$this->add_field("payer_email", $session_basket->email);
$this->add_field("address_name", $session_basket->name);
$this->add_field("address_street", $session_basket->house." ".$session_basket->street);
$this->add_field("address_city", $session_basket->town);
$this->add_field("address_zip", $session_basket->postcode);
$this->add_field("contact_phone", $session_basket->phone);
$string = "<form method=\"post\" name=\"paypal_form\" "
."action=\"".$this->paypal_url."\">\n";
foreach ($this->fields as $name => $value) {
$string = $string."<input type=\"hidden\" name=\"$name\" value=\"$value\"/>\n";
}
$string = $string."</form><script>function s_f(){document.forms[\"paypal_form\"].submit();}; window.setTimeout(s_f,20);</script>";
return $string;
}
function validate_ipn($key) {
// parse the paypal URL
$url_parsed=parse_url($this->paypal_url);
// generate the post string from the _POST vars aswell as load the
// _POST vars into an arry so we can play with them from the calling
// script.
$post_string = 'cmd=_notify-validate';
foreach ($_POST as $field=>$value) {
$this->ipn_data["$field"] = $value;
$value = urlencode(stripslashes($value));
$value = preg_replace('/(.*[^%^0^D])(%0A)(.*)/i','${1}%0D%0A${3}',$value);
$post_string .= '&'.$field.'='.$value;
}
// open the connection to paypal
$fp = fsockopen($this->secure_url,443,$err_num,$err_str,30);
if(!$fp) {
// could not open the connection. If loggin is on, the error message
// will be in the log.
$this->last_error = "fsockopen error no. $errnum: $errstr";
$this->log_ipn_results($key,false);
return false;
} else {
// Post the data back to paypal
fputs($fp, "POST ".$url_parsed['path']." HTTP/1.1\r\n");
fputs($fp, "Host: ".$url_parsed['host']."\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($post_string)."\r\n\r\n");
//fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
// loop through the response from the server and append to variable
while(!feof($fp)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (stristr($this->ipn_response,"VERIFIED")===false)
{
// Invalid IPN transaction. Check the log for details.
$this->last_error = 'IPN Validation Failed. '.$url_parsed['host'].'\\'.$url_parsed['path'];
$this->log_ipn_results($key,false);
return false;
}
else{
// Valid IPN transaction.
// check recievers e-mail
$business = basket::getPaypalAccount();
if ($this->ipn_data['receiver_email']!=$business)
{
$this->last_error = 'receivers e-mail did not match '.$business;
$this->log_ipn_results($key,false);
return false;
}
// if confirmed check message has not been received already
if ($this->ipn_data['payment_status'] == "Completed"){
$message = ORM::factory("ipn_message")
->where('key',"=",$key)
->where('status',"=",'completed')
->where('txn_id',"=",$this->ipn_data['txn_id'])->find();
if ($message->loaded()){
$this->last_error = 'Message alread received.';
$this->log_ipn_results($key,false);
return false;
}
}
$this->log_ipn_results($key,true);
return true;
}
}
function log_ipn_results($key, $success) {
// Timestamp
$text = '['.date('m/d/Y g:i A').'] - ';
$message = ORM::factory("ipn_message");
$message->date = time();
$message->key = $key;
$message->txn_id = $this->ipn_data['txn_id'];
$message->status = $this->ipn_data['payment_status'];
$message->success = $success;
// Success or failure being logged?
if ($success) $text .= "SUCCESS!\n";
else $text .= 'FAIL: '.$this->last_error."\n";
// Log the POST variables
$text .= "IPN POST Vars from Paypal:\n";
foreach ($this->ipn_data as $key=>$value) {
$text .= "$key=$value \n";
}
// Log the response from the paypal server
$text .= "\nIPN Response from Paypal Server:\n ".$this->ipn_response;
$message->text = $text;
$message->save();
}
function dump_fields() {
// Used for debugging, this function will output all the field/value pairs
// that are currently defined in the instance of the class using the
// add_field() function.
echo "<h3>paypal_class->dump_fields() Output:</h3>";
echo "<table width=\"95%\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">
<tr>
<td bgcolor=\"black\"><b><font color=\"white\">Field Name</font></b></td>
<td bgcolor=\"black\"><b><font color=\"white\">Value</font></b></td>
</tr>";
ksort($this->fields);
foreach ($this->fields as $key => $value) {
echo "<tr><td>$key</td><td>".urldecode($value)."&nbsp;</td></tr>";
}
echo "</table><br>";
}
}

View File

@ -0,0 +1,216 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class basket_item
{
public $product;
public $item;
public $quantity;
public $cost = 0;
public $cost_per = 0;
public $items;
public function __construct($aProduct, $aItem, $aQuantity){
// TODO check individual product.
$this->product = $aProduct;
$this->item = $aItem;
$this->quantity = $aQuantity;
$this->calculate_cost();
}
private function calculate_cost(){
$prod = ORM::factory("product", $this->product);
$this->cost = $prod->cost * $this->quantity;
$this->cost_per = $prod->cost;
}
// PUBLIC FUNCTIONS
public function add($quantity){
$this->quantity += $quantity;
$this->calculate_cost();
}
public function size(){
return $this->quantity;
}
public function getItem(){
$photo = ORM::factory("item", $this->item);
return $photo;
}
public function product_description(){
$prod = ORM::factory("product", $this->product);
return $prod->description;
}
/* added for basket sidebar labels */
public function product_name(){
$prod = ORM::factory("product", $this->product);
return $prod->name;
}
public function getProduct(){
$prod = ORM::factory("product", $this->product);
return $prod;
}
public function getCode(){
$photo = ORM::factory("item", $this->item);
$prod = ORM::factory("product", $this->product);
return $photo->id." - ".$photo->title." - ".$prod->name;
}
}
class Session_Basket_Core {
public $contents = array();
// added for customer record
public $title = "";
public $initials = "";
public $insertion = "";
public $name = "";
public $house = "";
public $street = "";
public $suburb = "";
public $town = "";
public $postcode = "";
public $email = "";
public $phone = "";
// added for user comment
public $comments = "";
// added for reference with pickup
public $childname = "";
public $childgroup = "";
// added for agreement to General Terms
public $agreeterms = "";
public $ppenabled = true;
//clear the basket
public function clear(){
if (isset($this->contents)){
foreach ($this->contents as $key => $item){
unset($this->contents[$key]);
}
}
$this->ppenabled = true;
}
//enable/disble pack&post
public function enablepp(){
$this->ppenabled = true;
}
public function disablepp(){
$this->ppenabled = false;
}
//get pack&post choice
public function ispp(){
return $this->ppenabled;
}
private function create_key($product, $id){
return "$product _ $id";
}
//get size
public function size(){
$size = 0;
if (isset($this->contents)){
foreach ($this->contents as $product => $basket_item){
$size += $basket_item->size();
}
}
return $size;
}
// to add an item to the basket
public function add($id, $product, $quantity){
$key = $this->create_key($product, $id);
// add more of a product already in the basket
if (isset($this->contents[$key])){
$this->contents[$key]->add($quantity);
}
// new product in the basket
else {
$this->contents[$key] = new basket_item($product, $id, $quantity);
}
}
// to remove an item from the basket
public function remove($key){
unset($this->contents[$key]);
}
//calculate total postage cost
public function postage_cost(){
$postage_cost = 0;
$postage_bands = array();
$postage_quantities = array();
if (isset($this->contents)){
// create array of postage bands
foreach ($this->contents as $product => $basket_item){
$postage_band = $basket_item->getProduct()->postage_band;
if (isset($postage_bands[$postage_band->id])){
$postage_quantities[$postage_band->id] += $basket_item->quantity;
}
else{
$postage_quantities[$postage_band->id] = $basket_item->quantity;
$postage_bands[$postage_band->id] = $postage_band;
}
}
foreach ($postage_bands as $id => $postage_band){
$postage_cost += $postage_band->flat_rate + ($postage_band->per_item * $postage_quantities[$id]);
}
}
return $postage_cost;
}
//calculate total basket cost
public function cost(){
$cost = 0;
if (isset($this->contents)){
foreach ($this->contents as $product => $basket_item){
$cost += $basket_item->cost;
}
}
return $cost;
}
//return the basket of the session
public static function get(){
return Session::instance()->get("basket");
}
public static function getOrCreate(){
$session = Session::instance();
$basket = $session->get("basket");
if (!$basket){
$basket = new Session_Basket();
$session->set("basket", $basket);
}
return $basket;
}
}

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Customer_Model extends ORM {
}

View File

@ -0,0 +1,16 @@
<?php defined("SYSPATH") or die("No direct script access.");
class Ipn_message_Model extends ORM {
public function formatedTime(){
return date("D jS F H:i", $this->date);
}
public function json_encode(){
$toReturn = array(
'id' => $this->id,
'date' => $this->formatedTime(),
'text' => text::convertText($this->text));
return $toReturn;
}
}

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Item_Product_Model extends ORM {
protected $belongs_to= array('product_override');
}

View File

@ -0,0 +1,87 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Order_Model extends ORM {
const WAITING_PAYMENT = 1;
const PAYMENT_CONFIRMED = 2;
const DELIVERED_NOTPAID = 10;
const DELIVERED = 20;
const EXPIRED = 21;
const CANCELLED = 99;
const PAYMENT_PAYPAL = 1;
const PAYMENT_OFFLINE = 2;
const DELIVERY_MAIL = 2;
const DELIVERY_EMAIL = 3;
const DELIVERY_PICKUP = 4;
public function title(){
return basket::getOrderPrefix().$this->id." ".$this->name." ".$this->status();
}
public function status(){
switch ($this->status){
case Order_Model::WAITING_PAYMENT:
//return "Waiting Payment";
return "Wacht op betaling";
case Order_Model::PAYMENT_CONFIRMED:
//return "Payment Confirmed";
return "Betaling bevestigd";
//@TODO add completed+delivery method
case Order_Model::DELIVERED_NOTPAID:
//return "Delivered,w/o payment";
return "Afgeleverd zonder betaling";
case Order_Model::DELIVERED:
//return "Complete";
return "Afgehandeld";
case Order_Model::EXPIRED:
//return "Expired";
return "Verlopen";
case Order_Model::CANCELLED:
//return "Cancelled";
return "Geannuleerd";
default:
//return "Unknown";
return "Onbekend";
}
}
public function payment_method(){
switch ($this->method){
case 1:
//return "through Paypal";
return "Via PayPal";
case 2:
//return "offline";
return "Overmaking - versturen per post";
case 3:
//return "offline";
return "Overmaking - versturen per e-mail";
case 4:
//return "offline";
return "Overmaking - afhalen";
default:
//return "Unknown";
return "Onbekend";
}
}
}

View File

@ -0,0 +1,84 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2011 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Order_Log_Model extends ORM {
public function status(){
switch ($this->status){
case 1:
//return "Waiting Payment";
return "Wacht op betaling";
case 2:
//return "Payment Confirmed";
return "Betaling bevestigd";
case 3:
//return "Late Payment";
return "Betalingsherinnering verstuurd";
case 10:
//return "Delivered,w/o payment";
return "Afgeleverd zonder betaling";
case 20:
//return "Complete";
return "Afgehandeld";
case 21:
//return "Expired";
return "Verlopen";
case 99:
//return "Cancelled";
return "Geannuleerd";
default:
//return "Unknown";
return "Onbekend";
}
}
public function event(){
switch ($this->event){
case 1:
//return "Waiting Payment";
return "Bestelling geplaatst";
case 2:
//return "Payment Confirmed";
return "Betaling ontvangen";
case 3:
//return "Late Payment";
return "Betalingsherinnering verstuurd";
case 9:
//return "Order Copy";
return "Kopie bestelling verstuurd";
case 10:
//return "Delivered,w/o payment";
return "Bestelling afgeleverd zonder betaling";
case 20:
//return "Complete";
return "Bestelling verzonden";
case 21:
//return "Expired";
return "Bestelling verlopen";
case 99:
//return "Cancelled";
return "Bestelling geannuleerd";
default:
//return "Unknown";
return "Onbekend";
}
}
}

View File

@ -0,0 +1,25 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Order_Update extends ORM {
const WAITING_PAYMENT = 1;
const PAYMENT_CONFIRMED= 2;
const LATE_PAYMENT= 3;
}

View File

@ -0,0 +1,26 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Postage_Band_Model extends ORM {
var $rules = array(
"name" => "length[1,32]");
protected $has_many=array('products');
}

View File

@ -0,0 +1,26 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Product_Model extends ORM {
var $rules = array(
"name" => "length[1,32]",
"description" => "length[0,255]");
protected $belongs_to=array('postage_band');
}

View File

@ -0,0 +1,22 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Product_Override_Model extends ORM {
protected $has_many=array('item_products');
}

View File

@ -0,0 +1,3 @@
name = "Shopping Basket"
description = "Provides a simple shopping basket and checkout with paypal integration"
version = 5

View File

@ -0,0 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="add_to_basket">
<a href="<?= url::site("basket/add_to_basket_ajax/$item->id") ?>" title="<?= t("Add To basket") ?>" class="g-dialog-link">
<?= t("Add To basket") ?></a>
</div>

View File

@ -0,0 +1,11 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-add-to-basket">
<div id="basketThumb">
<img src="<?= $item->thumb_url()?>" title="<?= $item->title?>" alt="<?= $item->title?>" />
</div>
<b>Kies het afdrukformaat en aantal afdrukken</b>
<div id="basketForm">
<? /*<b>Kies het gewenste fotoformaat en het aantal foto's</b> */ ?>
<?= $form ?>
</div>
</div>

View File

@ -0,0 +1,7 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-configure">
<h1> <?= t("Configure Shopping Basket") ?> </h1>
<p> <?= t("Use this page to configure the shopping basket. If you have paypal you can use this to processs the final payments.") ?>
</p>
<?= $form ?>
</div>

View File

@ -0,0 +1,71 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<div class="gBlock">
<a href="<?= url::site("admin/postage_bands/add_postage_band_form") ?>"
class="g-dialog-link g-button right ui-icon-left ui-state-default ui-corner-all"
title="<?= t("Create a new Postage Band") ?>">
<span class="ui-icon ui-icon-circle-plus"></span>
<?= t("Add a new Postage Band") ?>
</a>
<h2>
<?= t("Postage Bands") ?>
</h2>
<div class="g-block-content">
<table id="g-postage-admin-list">
<tr>
<th><?= t("Name") ?></th>
<th><?= t("Flat Rate") ?></th>
<th><?= t("Per Item") ?></th>
<th><?= t("Actions") ?></th>
</tr>
<? foreach ($postage_bands as $i => $postage_band): ?>
<tr id="g-product-<?= $postage_band->id ?>" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="product-<?= $postage_band->id ?>" class="core-info ">
<?= html::clean($postage_band->name) ?>
</td>
<td>
<?= basket::formatMoneyForWeb($postage_band->flat_rate) ?>
</td>
<td>
<?= basket::formatMoneyForWeb($postage_band->per_item) ?>
</td>
<td class="g-actions">
<a href="<?= url::site("admin/postage_bands/edit_postage_band_form/$postage_band->id") ?>"
open_text="<?= t("close") ?>"
class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-pencil"></span><?= t("edit") ?></a>
<a href="<?= url::site("admin/postage_bands/delete_postage_band_form/$postage_band->id") ?>"
class="g-dialog-link g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-trash"></span><?= t("delete") ?></a>
</td>
</tr>
<? endforeach ?>
</table>
</div>
</div>

View File

@ -0,0 +1,60 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<div class="g-block">
<a href="<?= url::site("admin/product_lines/add_product_form") ?>"
class="g-dialog-link g-button right ui-icon-left ui-state-default ui-corner-all"
title="<?= t("Create a new Product") ?>">
<span class="ui-icon ui-icon-circle-plus"></span>
<?= t("Add a new Product") ?>
</a>
<h2><?= t("Product Lines") ?></h2>
<div class="g-block-content">
<table id="g-product-admin-list">
<tr>
<th><?= t("Name") ?></th>
<th><?= t("Cost") ?></th>
<th><?= t("Description") ?></th>
<th><?= t("Postage Band") ?></th>
<th><?= t("Actions") ?></th>
</tr>
<? foreach ($products as $i => $product): ?>
<tr id="gProduct-<?= $product->id ?>" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="product-<?= $product->id ?>" class="core-info ">
<?= html::clean($product->name) ?></td>
<td><?= basket::formatMoneyForWeb($product->cost) ?></td>
<td><?= html::clean($product->description) ?></td>
<td><?= html::clean($product->postage_band->name) ?></td>
<td class="g-actions"><a href="<?= url::site("admin/product_lines/edit_product_form/$product->id") ?>"
open_text="<?= t("close") ?>"
class="g-panel-link g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-pencil"></span><span class="gButtonText"><?= t("edit") ?></span></a>
<a href="<?= url::site("admin/product_lines/delete_product_form/$product->id") ?>"
class="g-dialog-link g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-trash"></span><?= t("delete") ?></a>
</td>
</tr>
<? endforeach ?>
</table>
</div>
</div>

View File

@ -0,0 +1,8 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="g-admin-configure">
<h1> <?= t("Configure Templates used for Offline Payment.") ?> </h1>
<p>
<?= t("The following can be edited to control what the user see during offline payment. Please read the documentation for more information about variables you can use in the templates") ?>
</p>
<?= $form ?>
</div>

View File

@ -0,0 +1,62 @@
<? if ($theme->page_type != 'basket'){
if (basket::can_view_orders()){
?><a class="g-button ui-icon-left ui-state-default ui-corner-all ui-state-hover"
href="<?= url::site("basket/view_Orders") ?>" title="<?= t("View Orders") ?>">
<span class="ui-icon ui-icon-clipboard"></span><?= t("View Orders")?></a><?
}
$item = $theme->item();
if ($item->is_photo() && product::isForSale($theme->item()->id)){
?><p>
<a class="g-dialog-link g-button ui-icon-left ui-state-default ui-corner-all ui-state-hover" href="<?= url::site("basket/add_to_basket_ajax/$item->id") ?>"
title="<?= t("Add To Basket")?>"><span class="ui-icon ui-icon-plusthick"></span><?= t("Add To Basket") ?></a></p>
<?
}
if (isset($basket) && isset($basket->contents) && ($basket->size() > 0)) {
?>
<div id="sidebar-basket">
<table id="gBasketList">
<tr>
<th><?= t("Product") ?></th>
<th><?= t("Cost") ?></th>
<th></th>
</tr><?
$total=0;
foreach ($basket->contents as $key => $prod_details){
?><tr id="" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="item-<?= $prod_details->item ?>" class="core-info"><?
$item = $prod_details->getItem();
$width = $item->width;
?><img src="<?= $item->thumb_url()?>" title="<?= $item->title?>" alt="<?= $item->title?>"
<? if ($width < module::get_var("gallery", "resize_size")):?>
style="max-width:60px;"/><br/>
<? else: ?>
style="max-width:90px;"/><br/>
<? endif; ?>
<?= html::clean($prod_details->quantity) ?> x <?= html::clean($prod_details->product_name())/*= html::clean($prod_details->product_description())*/ ?></td>
<td><? $total += $prod_details->cost?><?= basket::formatMoneyForWeb($prod_details->cost); ?></td>
<td class="g-actions"><a href="<?= url::site("basket/remove_item/$key") ?>"
class="g-button2 ui-state-default ui-corner-all ui-icon-left"><span class="ui-icon ui-icon-trash"></span></a></td>
</tr>
<?
}
?>
<tr class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td><b><?= t("Total") ?></b></td>
<td id="total"><b><?= $basket->ispp()?basket::formatMoneyForWeb($total + $postage):basket::formatMoneyForWeb($total)?></b></td>
<td></td>
</tr>
</table>
</div><br/>
<p><a class="g-button right ui-icon-left ui-state-default ui-corner-all ui-state-hover"
href="<?= url::site("basket/view_basket") ?>" title="<?= t("Checkout") ?>">
<span class="ui-icon ui-icon-cart"></span><?= t("Checkout") ?></a></p><?
}
else {?>
<div id="sidebar-basket">
<?= t("Shopping Basket is Empty") ?>
</div><?
}
}

View File

@ -0,0 +1,35 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<? if ($theme->page_type != 'basket'): ?>
<? if (basket::can_view_orders()): ?>
<a href="<?= url::site("basket/view_Orders") ?>"
title="<?= t("View Orders") ?>">View Orders</a>
<? endif?>
<? if (isset($basket) && isset($basket->contents) && ($basket->size() > 0)): ?>
<div id="basket">
<a href="<?= url::site("basket/view_basket") ?>"
title="<?= t("View Basket") ?>">
<img src="<?= url::file("modules/basket/images/basket.png") ?>"><br/>
<?= $basket->size()?> items</a>
</div>
<? endif ?>
<? endif ?>

View File

@ -0,0 +1,167 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<SCRIPT language="JavaScript">
function isValidEmail(s){
return (s.indexOf(".")>2)&&(s.indexOf("@")>0);
}
function isHotmail(s) {
return(s.indexOf("hotmail")==-1)
}
function se(val){
val.style.backgroundColor="#FAA";
}
function re(val){
val.style.backgroundColor="#FFF";
}
function checkInput(val){
if ((!val.value) || (val.value.length==0)) {se(val);return false;}
re(val);
return true;
}
function checkMandatory() {
var p=true;
var doc=document.checkout;
//check initials
if(!checkInput(doc.initials)){p=false;}
//check name
if(!checkInput(doc.fullname)){p=false;}
//check phone
if(!checkInput(doc.phone)){p=false;}
//check email
if((!checkInput(doc.email))||(!isValidEmail(doc.email.value))){se(doc.email);p=false;}
if (!p){
alert('U heeft een of meer verplichte velden niet ingevuld.');
}
return p;
}
function checkAddress() {
var p=true;
var doc=document.checkout;
//check address
if(!checkInput(doc.street)){p=false;}
if(!checkInput(doc.house)){p=false;}
if(!checkInput(doc.postcode)){p=false;}
if(!checkInput(doc.town)){p=false;}
if (!p){
alert('U heeft een of meer adresvelden niet ingevuld.');
}
return p;
}
function checkChild() {
var p=true;
var doc=document.checkout;
//check child's name and group
if(!checkInput(doc.childname)){p=false;}
if(!checkInput(doc.childgroup)){p=false;}
if (!p){
alert('U heeft de naam en/of groep van uw kind niet ingevuld.');
}
return p;
}
function checkTerms() {
var doc=document.checkout;
//check agreeTerms
if(doc.agreeterms.checked==false){
alert('Om te kunnen bestellen dient u akkoord te gaan met de Algemene voorwaarden.');
return false;
}
if (!isHotmail(doc.email.value)){
alert('Attentie: U heeft een e-mailadres van Hotmail opgegeven. Als u na het afronden van de bestelling geen bevestiging ontvangt, controleer dan de Junk-folder.');
}
return true;
}
//checkout with pickup
function checkCheckout() {
if (checkMandatory()){
if (checkTerms()) {
document.checkout.submit();
}
}
}
//checkout with e-mail
function checkCheckoutMail() {
if (checkMandatory()){
if (checkTerms()) {
document.checkout.submit();
}
}
}
//checkout with pack&post
function checkCheckoutPP() {
var p=true;
if (checkMandatory()){
if (checkAddress()) {
if (checkTerms()) {
document.checkout.submit();
}
}
}
}
</SCRIPT>
<div class="g-block">
<h2><?= t("Delivery and Contact (Step 1 of 3)") ?></h2>
<div id="b-complete">
<? $payment_details = basket::getPaymentDetails();
$webshop = basket::getWebshop();
$payment_details = basket::replaceStrings($payment_details,Array("webshop"=> $webshop));?>
<? /* here the payment options text is loaded */?>
<? if ($payment_details):?>
<div class="basket-right" id="payment">
<h3> <?= t("Payment options") ?></h3>
<?= $payment_details; ?>
</div>
<? endif; ?>
<? /* here the form is loaded */?>
<?= $form ?>
<div><label><?= t("* required field") ?><p></p></label></div>
<div class="basketbuttons">
<? /* added BEGIN: to allow user to go back */?>
<script language="JavaScript">
function back(){
history.go(-1);
}
</script>
<a href="javascript:back();" class="left g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Back to Basket") ?></a>
<? /* check for pack&post */?>
<? $basket = Session_Basket::get(); ?>
<? $postage = $basket->postage_cost();?>
<? /* Pickup not selected and postage cost */
if ($basket->ispp() && $postage > 0):?>
<a href="javascript: checkCheckoutPP()" class="right g-button ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("To Order Confirmation") ?></a>
<? /* Pickup selected and postage cost */
elseif ($postage > 0):?>
<a href="javascript: checkCheckout()" class="right g-button ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("To Order Confirmation") ?></a>
<? /* no postage cost */
else: ?>
<a href="javascript: checkCheckoutMail()" class="right g-button ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("To Order Confirmation") ?></a>
<? endif; ?>
</div>
</div>
</div>

View File

@ -0,0 +1,152 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<SCRIPT language="JavaScript">
function so(){
document.confirm.submit();
}
</SCRIPT>
<?= $form ?>
<div class="gBlock">
<h2><?= t("Order Summary (Step 2 of 3)") ?></h2>
<div class="g-block-content scrollables">
<table id="g-basket-list" class="pretty-table2">
<tr>
<th></th>
<th><?= t("Photo") ?></th>
<th><?= t("Product") ?></th>
<th style="text-align:right;"><?= t("Quantity") ?></th>
<th style="text-align:right;"><?= t("Cost") ?></th>
</tr>
<? foreach ($basket->contents as $key => $prod_details): ?>
<tr id="" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="item-<?= $prod_details->item ?>" class="core-info ">
<? $item = $prod_details->getItem(); ?>
<? $width = $item->width; /* added JtK */?>
<div id="basketThumb">
<a href="<?= $item->resize_url()?>" class="preview-image">
<img src="<?= $item->thumb_url()?>" title="<?= $item->title?>" alt="<?= $item->title?>
<? if ($width < module::get_var("gallery", "resize_size")):/* added JtK */?>
style="width=30px;"/></a>
<? else: ?>
style="width=45px;"/></a>
<? endif; ?>
</div>
</td>
<td id="item-<?= $prod_details->item ?>" class="core-info ">
<? $item = $prod_details->getItem(); ?>
<div>
<?= html::clean($item->title) ?>
</div>
</td>
<td><?= html::clean($prod_details->product_description()) ?></td>
<td style="text-align:right;"><?= html::clean($prod_details->quantity) ?></td>
<td style="text-align:right;"><?= basket::formatMoneyForWeb($prod_details->cost) ?></td>
</tr>
<? endforeach ?>
<? $postage = $basket->postage_cost();?>
<? if ($postage > 0):?>
<tr id="" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td></td>
<td></td>
<td <?=$basket->ispp()?"":"style=\"text-decoration:line-through\""; ?>><?= t("Packaging and Posting") ?></td>
<td></td>
<td style="text-align:right;<?=$basket->ispp()?"":" text-decoration:line-through;";?>"><?= basket::formatMoneyForWeb($postage)?></td>
</tr>
<? endif;?>
<tr id="" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td></td>
<td></td>
<td><b><?= t("Total Cost") ?></b></td>
<td></td>
<td style="text-align:right;"><b><?= $basket->ispp()?basket::formatMoneyForWeb($basket->cost() + $postage):basket::formatMoneyForWeb($basket->cost()); ?></b></td>
<? /*
<td></td><td></td><td>Total Cost</td><td><?= $basket->ispp()?basket::formatMoneyForWeb($basket->cost() + $postage):basket::formatMoneyForWeb($basket->cost()); ?></td>
*/ ?>
</tr>
</table>
</div>
<table>
<tr>
<td>
<? if ($basket->street <> ""):?>
<h3><label><?= t("Name and Address") ?></label></h3>
<? else :?>
<h3><label><?= t("Name") ?></label></h3>
<? endif;?>
<?= basket::createFullName($basket) ?><br/>
<? if ($basket->street <> ""):?>
<?= $basket->street ?>&nbsp;<?= $basket->house ?><br/>
<?= $basket->postcode ?>&nbsp;<?= $basket->town ?><br/>
<? endif;?>
<br/>
<label><?= t("E-mail Address") ?>: </label><?= $basket->email ?><br/>
<? if ($basket->phone <> ""):?>
<label><?= t("Phone") ?>: </label><?= $basket->phone ?><br/>
<? endif;?>
<br/>
<? $postage = $basket->postage_cost();
$ppon = $basket->ispp();?>
<label><?= t("Delivery")?>:</label>&nbsp;
<? if (($ppon) && ($postage > 0)):?>
<?= t("Delivery by mail") ?><br/>
<? elseif ($postage > 0):?>
<? $pickup_location = basket::getPickupLocation(); ?>
<?= t("Pickup at")." ".$pickup_location ?><br/>
<? else:?>
<?= t("Delivery by e-mail") ?><br/>
<? endif;?>
<br/>
<label><input type="checkbox" checked=checked disabled=disabled/> <?= t(" I agree with the General Terms")?></label>
</td>
<td>
<? if ($basket->childname <> ""):?>
<br/>
<label><?= t("Child's Name")?>:</label>&nbsp;<?= $basket->childname ?><br/>
<label><?= t("Child's Group")?>:</label>&nbsp;<?= $basket->childgroup ?><br/>
<? endif;?>
<? if ($basket->comments <> ""):?>
<br/>
<b><label>Opmerking:</label></b> <?= $basket->comments ?>
<br/>
<? endif;?>
</td>
</tr>
</table>
<div class="basketbuttons">
<? /* added BEGIN: to allow user to go back */?>
<script language="JavaScript">
function back(){
history.go(-1);
}
</script>
<a href="javascript:back();" class="left g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Back to Checkout") ?></a>
<? /* added END */?>
<? /*
<a href="<?= url::site("basket/checkout") ?>" class="left g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Back to Checkout") ?></a>
*/?>
<a href="javascript: so()" class="right g-button ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Confirm Order") ?></a>
</div>
</div>

View File

@ -0,0 +1,27 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<?/* <h2><? t("Thank you for your order (Step 3 of 3)") ?></h2> */?>
<div class="g-block">
<div id="b-complete">
<h2>Bestelling geplaatst (stap 3 van 3)</h2>
<?= basket::replaceStringsAll(basket::getOrderCompletePage(),$order);?>
</div>
</div>

View File

@ -0,0 +1,4 @@
<?= $form?>
<h1>Processing</h1><h3>If you are not automatically redirected to
paypal within 5 seconds <a href='javascript:s_f();'>Click Here</a>.</h3>

View File

@ -0,0 +1,16 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gAdminConfigure">
<SCRIPT language="JavaScript">function so(){document.generateKeys.submit();}</SCRIPT>
<h1> <?= t("Paypal Encryption Wizard - Step 1") ?> </h1>
<p>
<?= t("The first step is to fill in some details about yourself. These details are used to create a set of encryption keys that will be used to communicate with paypal.") ?>
</p>
<?= $form ?>
<a href="<?= url::site("admin/configure") ?>"
class="left gButtonLink ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Cancel") ?></a>
<a href="<?= url::site("javascript: so();") ?>"
class="right gButtonLink ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Next") ?></a>
</div>

View File

@ -0,0 +1,17 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gAdminConfigure">
<SCRIPT language="JavaScript">function so(){document.paypalKey.submit();}</SCRIPT>
<h1> <?= t("Paypal Encryption Wizard - Step 2") ?> </h1>
<p>
<?= t("Open your paypal account on a seperate window and navigate to My account / profile / Selling Preferences - Encrypted Payment Settings.") ?>
<?= t("From this page press the download button to donwload paypals public certificate. Then paste the documents contents into the edit box below.") ?>
</p>
<?= $form ?>
<a href="<?= url::site("admin/configure") ?>"
class="left gButtonLink ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Cancel") ?></a>
<a href="<?= url::site("javascript: so();") ?>"
class="right gButtonLink ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Next") ?></a>
</div>

View File

@ -0,0 +1,20 @@
<html>
<head>
<title>Print Order</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript">
$(document).ready(function(){
window.print();
window.close();
});
</script>
</head>
<body>
<tt>
<?= $order ?>
</tt>
</body>
</html>

View File

@ -0,0 +1,145 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<script>
var b,d;
function previewImage(element)
{
var ele=$(element),i=$(document.createElement('div')),img=$(new Image());
img.load(function(){
var o=$('<div></div>').appendTo(document.body).addClass('ui-widget-overlay').css({width:d.width(),height:d.height()});
i.css({'position':'absolute',left:(b.width()/2)-(this.width / 2),top:(b.height()/2)-(this.height/2)}).click(function(){i.remove();o.remove();}).append(img);
$("body").append(i);
}).attr('src',ele.attr('href'));
return false;
}
$(window).load(function(){
b=$("body");d=$("document");
$("#gBasketList").find(".preview-image").bind("click",function(){return previewImage(this)});
});
</script>
<div class="g-block">
<h2><?= t("Basket Contents") ?></h2>
<div class="basketbuttons">
<? if (isset($basket->contents ) && count($basket->contents) > 0): ?>
<script language="JavaScript">
$(document).ready(function(){
$("#pickup").click(function(){
if (this.checked)
{
window.location = "<?= url::site("basket/view_basket/nopp") ?>";
}
else
{
window.location = "<?= url::site("basket/view_basket/ppon") ?>";
}
});
})
</script>
<? endif; ?>
</div>
<div class="g-block-content scrollable">
<? if (isset($basket->contents ) && count($basket->contents) > 0): ?>
<table id="gBasketList" class="pretty-table2">
<tr><? /* added 5x 'width/align' JtK */?>
<th><?= t("Picture") ?></th>
<th><?= t("Product") ?></th>
<th style="text-align:right;"><?= t("Quantity") ?></th>
<th style="text-align:right;"><?= t("Cost") ?></th>
<th><?= t("Actions") ?></th>
</tr>
<? $total=0;?>
<? foreach ($basket->contents as $key => $prod_details): ?>
<tr id="" class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td id="item-<?= $prod_details->item ?>" class="core-info ">
<? $item = $prod_details->getItem(); ?>
<? $width = $item->width; /* added JtK */?>
<div id="basketThumb">
<a href="<?= $item->resize_url()?>" class="preview-image">
<img src="<?= $item->thumb_url()?>" title="<?= $item->title?>" alt="<?= $item->title?>
<? if ($width < module::get_var("gallery", "resize_size")):/* added JtK */?>
style="width=60px;"/></a>
<? else: ?>
style="width=90px;"/></a>
<? endif; ?>
</div>
</td>
<td><?= html::clean($prod_details->product_description()) ?></td>
<td style="text-align:right;"><?= html::clean($prod_details->quantity) ?></td>
<td style="text-align:right;"><? $total += $prod_details->cost /* added 'align=right' JtK */?>
<?= basket::formatMoneyForWeb($prod_details->cost); ?></td>
<td style="text-align:center;"><a href="<?= url::site("basket/remove_item/$key") ?>"
class="g-button2 ui-state-default ui-corner-all ui-icon-left"><? /* changed 'g-button2' JtK */?>
<span class="ui-icon ui-icon-trash" title="<?= t("Remove") ?>"></span></a>
</td>
</tr>
<? endforeach ?>
<? /* line with postage */ ?>
<? $postage = $basket->postage_cost();?>
<? if ($postage > 0):?>
<tr class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td></td>
<td <?=$basket->ispp()?"":"style=\"text-decoration:line-through\""; ?>><?= t("Postage and Packaging") ?></td>
<td></td>
<td style="text-align:right;<?=$basket->ispp()?"":" text-decoration:line-through;";?>"><?= basket::formatMoneyForWeb($postage)?></td>
<td></td>
</tr>
<? endif;?>
<? /* line with total */ ?>
<tr class="<?= text::alternate("gOddRow", "gEvenRow") ?>">
<td></td>
<td><b><?= t("Total Cost") ?></b></td><? /* added 'width/<b>' JtK */?>
<td></td>
<td style="text-align:right;" id="total"><b><? /* added class+<b>' JtK */?><?= $basket->ispp()?basket::formatMoneyForWeb($total + $postage):basket::formatMoneyForWeb($total)?></b></td>
<td></td>
</tr>
<? if ($postage > 0):?>
<? if (basket::isAllowPickup()):?>
<tr class="pretty-table3">
<td colspan="5"><input id="pickup" type="checkbox" <?=$basket->ispp()?"":"checked"; ?>/><?= t(" Select if you wish to pick up the photos.") ?></td>
</tr>
<? endif;?>
<? endif;?>
</table>
<? else: ?>
<?= t("Shopping Basket is Empty") ?>
<? endif; ?>
</div>
<div class="basketbuttons">
<? if (isset($basket->contents ) && count($basket->contents) > 0): ?>
<? /* added BEGIN: to allow user to go back */?>
<script language="JavaScript">
function back(){
history.go(-1);
}
</script>
<a href="javascript:back();"
class="left g-button ui-state-default ui-corner-all ui-icon-left">
<span class="ui-icon ui-icon-arrow-1-w"></span><?= t("Back to Photos") ?></a>
<? /* added END */?>
<a href="<?= url::site("basket/checkout") ?>"
class="right g-button ui-state-default ui-corner-all ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Proceed to Checkout") ?></a>
<? endif; ?>
</div>
</div>

View File

@ -0,0 +1,46 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<h1>IPN Messages for <?= $order->title()?></h1>
<a href="<?=url::site("basket/view_orders");?>">Back to orders</a>
<div class="left" style="width:150px;float:left;font-size:10px;">
<ul>
<?
foreach ($ipn_messages as $i => $ipn_message){
?><li><a href="javascript:ld(<?=$ipn_message->id?>)"><?= $ipn_message->date." ".$ipn_message->status ?></a></li><?
}
?>
</ul>
</div>
<div class="scrollable" style="text-align:left;float:left;padding:0;font-size:12px;display:block;"><pre id="ipn_text"></pre>
</div>
<SCRIPT language="JavaScript">
var ot,csrf;
$(window).load(new function(){ot=$("#ipn_text");csrf="?csrf=<?= $csrf ?>"});
function ld(n){
ot.html("Loading...");
ot.load('<?=url::site("basket/show_ipn")?>/'+n+csrf,
function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == "error") {ot.html(responseText);}
});
}
</SCRIPT>

View File

@ -0,0 +1,36 @@
<h2><?= $order->title()?></h2>
<div class="basketbuttons"> <?
if ($order->status==Order_Model::WAITING_PAYMENT){?>
<table>
<tr>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/confirm_order_payment/".$order->id)."?csrf=$csrf";?>">Bevestig betaling</a></td>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/remind_order_payment/".$order->id)."?csrf=$csrf";?>">Stuur betalingsherinnering</a></td>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/send_order_copy/".$order->id)."?csrf=$csrf";?>">Stuur kopie bestelling</a></td>
</tr>
<tr>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/confirm_order_delivery/".$order->id)."?csrf=$csrf";?>">Bevestig verzending zonder betaling</a></td>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/confirm_order_cancelled/".$order->id)."?csrf=$csrf";?>">Annuleer bestelling</a></td>
</tr>
</table>
<?
}
if ($order->status==Order_Model::DELIVERED_NOTPAID){?>
<table>
<tr>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/confirm_order_payment/".$order->id)."?csrf=$csrf";?>">Bevestig betaling</a></td>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/remind_order_payment/".$order->id)."?csrf=$csrf";?>">Stuur betalingsherinnering</a></td>
<td><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/send_order_copy/".$order->id)."?csrf=$csrf";?>">Stuur kopie bestelling</a></td>
</ </tr>
</table>
<?
}
if ($order->status==Order_Model::PAYMENT_CONFIRMED){
?><br/><a class="g-button ui-state-default ui-icon-right" href="<?= url::site("basket/confirm_order_delivery/".$order->id)."?csrf=$csrf";?>">Bevestig verzending</a> <?
}
if ($order->method==Order_Model::PAYMENT_PAYPAL){
?><br/><a href="<?= url::site("basket/view_ipn/".$order->id);?>">View Paypal IPN Messages</a>
<? } ?>
</div>
Betaal- en verzendwijze: <?= $order->payment_method()?></br>
<?= str_replace(array("\r\n", "\n", "\r"),"<br/>",$order->text);?>

View File

@ -0,0 +1,42 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<div class="left" style="width:600px;float:left;font-size:12px;display:block;">
<h2><?= t("Order History") ?></h2>
<table id="order_ovw" class="pretty-table">
<tr>
<th>Bestelnummer</th>
<th>Bestelstatus</th>
<th>Gebeurtenis</th>
<th>Datum/tijd</th>
</tr>
<? foreach ($order_logs as $i => $order_log){
?>
<tr>
<td><?=basket::getOrderPrefix().$order_log->id?></td>
<td><?=$order_log->status()?></td>
<td><?=$order_log->event()?></td>
<td><?=gallery::date_time($order_log->timestamp)?></td>
</tr>
<?
}
?>
</table>
</div>

View File

@ -0,0 +1,128 @@
<?php defined("SYSPATH") or die("No direct script access.")
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
?>
<div class="basketbuttons">
<form action="javascript: so()" method="post" id="show_order" name="show_order">
<input type="hidden" name="csrf" value="<?= $csrf ?>" />
<label for="orderno" ><?= t("Order Number") ?></label>
<input type="text" id="orderno" name="orderno" value="" class="textbox" />
<a href="javascript: so()" class="g-button ui-state-default ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Search") ?></a>
<a style="display:none" id="print_button" href="" class="g-button ui-state-default ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("Print") ?></a>
<a style="display:none" id="print_button" href="" class="g-button ui-state-default ui-icon-right">
<span class="ui-icon ui-icon-arrow-1-e"></span><?= t("No products except..") ?></a>
</form>
</div>
<div class="left" style="width:600px;float:left;font-size:12px;display:block;">
<table id="order_ovw" class="pretty-table">
<tr>
<th>Bestelnummer</th>
<th>Naam</th>
<th>Bestelstatus</th>
<th>Verzending</th>
<th>Bedrag</th>
</tr>
<? foreach ($orders as $i => $order){
?>
<tr class="order-status-<?=$order->status?>">
<td class="order-status-<?=$order->status?>"><a href="javascript:loadOrder(<?=$order->id?>)"><?=basket::getOrderPrefix().$order->id?></a></td>
<td><?=$order->name?></td>
<? $id=$order->id;?>
<?/*
<td class="order-status-<?=$order->status?>"><a href="javascript:loadOrder(<?=$order->id?>)"><?=basket::getOrderPrefix().$order->id?>
<td><a href="<?=url::site("basket/view_order_logs(".$id.")")?>"><?=$order->status()?></a></td>
<td><?=$order->status()?></td>
*/?>
<td class="order-status-<?=$order->status?>"><a href="javascript:loadOrderLog(<?=$order->id?>)" alt="toon order historie"><?=$order->status()?></a></td>
<td class="order-status-<?=$order->status?>"><?=$order->payment_method()?></td>
<td style="text-align:right;"><?=basket::formatMoneyForWeb($order->cost)?></td>
</tr>
<?
$total=$total+$order->cost;
}
?>
<tr class="order-status-<?=$order->status?>">
<td></td>
<td></td>
<td></td>
<td style="text-align:right;"><b>Totaal</b></td>
<td style="text-align:right;"><b><?=basket::formatMoneyForWeb($total)?></b></td>
</tr>
</table>
</div>
<div class="scrollable" style="text-align:left;float:left;padding:0;font-size:12px;display:block;"><pre id="order_text"></pre>
</div>
<SCRIPT language="JavaScript">
var doc,printButton,orderText,csrf;
$(window).load(new function(){
doc=document.show_order;
printButton=$("#print_button");
orderText=$("#order_text");
csrf="?csrf="+doc.csrf.value
});
function se(v){v.style.backgroundColor="#FAA";}
function re(v){v.style.backgroundColor="#FFF";}
function ci(v){if ((!v.value)||(v.value.length==0)){se(v);return false;}re(v);return true;}
function loadOrder(n){
printButton.css({display:'none'});
orderText.html("Loading...");
orderText.load('<?=url::site("basket/show_order")?>/'+n+csrf,
function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == "success") {
doc.orderno.value=n;
printButton.css({display:'inline-block'});
printButton.attr({target: "_blank",href : '<?=url::site("basket/print_order")?>/'+n+csrf});
}
if (textStatus == "error") {
orderText.html(responseText);
printButton.css({display:'none'});
}
}
);
}
//load
function loadOrderLog(n){
printButton.css({display:'none'});
orderText.html("Loading...");
orderText.load('<?=url::site("basket/show_order_logs")?>/'+n+csrf,
function (responseText, textStatus, XMLHttpRequest) {
if (textStatus == "success") {
doc.orderno.value=n;
}
if (textStatus == "error") {
orderText.html(responseText);
}
}
);
}
function so(){
printButton.css({display:'none'});
if(ci(doc.orderno)){
loadOrder(doc.orderno.value);
}
}
</SCRIPT>