예제 #1
0
 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} (\n                 `id` int(9) NOT NULL auto_increment,\n                 `name` TEXT NOT NULL,\n                 `flat_rate` DECIMAL(10,2) default 0,\n                 `per_item` DECIMAL(10,2) default 0,\n                 PRIMARY KEY (`id`))\n                 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} (\n                 `id` int(9) NOT NULL auto_increment,\n                 `text` TEXT NOT NULL,\n                 PRIMARY KEY (`id`))\n                 ENGINE=InnoDB DEFAULT CHARSET=utf8;");
         basket::setPaymentDetails("<p>Use the following options to pay for this order.</p>\n<p>Send a chequre to..</p>\n<p>Visit the shop..</p>\n<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>\n<p> - Send a cheque for %total_cost to with reference %order_number..</p>\n<p> - Visit the shop and quote the order %order_number..</p>\n<p> - Transfer %total_cost using internet banking with reference %order_number..</p>\n<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,\n\nThank you for your order the order details are below. To pay for this order please either:\n\n- Send a cheque for %total_cost to with reference %order_number..\n- Visit the shop and quote the order %order_number..\n- Transfer %total_cost using internet banking with reference %order_number..\n\nOrder will be processed as soon as payment is received. For order pick-ups please visit..\n\nOrder Details\n-------------\n%order_details\n\nThanks");
         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} (\n        `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `date`  int(11) NOT NULL,\n        `key` varchar(20) NOT NULL,\n        `txn_id` varchar(20) NOT NULL,\n        `status` varchar(20) NOT NULL,\n        `success` bool default false,\n        `text` text,\n        PRIMARY KEY  (`id`)\n      ) 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);
     }
 }
예제 #2
0
 static function get_edit_form_admin($product)
 {
     $form = new Forge("admin/product_lines/edit_product/{$product->id}", "", "post", array("id" => "g-edit-product-form"));
     $group = $form->group("edit_product")->label(t("Edit Product"));
     $group->input("name")->label(t("Name"))->id("g-product-name")->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("g-cost")->value($product->cost);
     $group->input("description")->label(t("Description"))->id("g-description")->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 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} (\n                 `id` int(9) NOT NULL auto_increment,\n                 `name` TEXT NOT NULL,\n                 `flat_rate` DECIMAL(10,2) default 0,\n                 `per_item` DECIMAL(10,2) default 0,\n                 PRIMARY KEY (`id`))\n                 ENGINE=InnoDB DEFAULT CHARSET=utf8;");
         postage_band::create("No Postage", 0, 0);
         module::set_version("basket", $version = 2);
     }
 }
 public function edit_postage_band_form($id)
 {
     $postage = ORM::factory("postage_band", $id);
     if (!$postage->loaded()) {
         throw new Kohana_404_Exception();
     }
     $form = postage_band::get_edit_form_admin($postage);
     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;
 }