static function initBasketProducts($language, $isReset)
 {
     $db = Database::instance();
     //if it's a reset request, empty the tables
     if ($isReset) {
         $db->query("DELETE FROM {bp_postage_bands}");
         $db->query("DELETE FROM {bp_products}");
         $db->query("DELETE FROM {bp_product_overrides}");
         $db->query("DELETE FROM {bp_item_products}");
     }
     //Add postage_bands if the table is empty
     $postage_band = ORM::factory("bp_postage_band")->where("id", "=", 1)->find();
     if (!$postage_band->loaded()) {
         //==========================
         // SETTINGS FOR ENGLISH
         if ($language == "en_US" or $language == "en_UK") {
             // name, fixed cost, per item cost, is download
             bp_postage_band::create("No posting cost", 0, 0, false);
             bp_postage_band::create("Default posting cost", 2, 0, false);
             bp_postage_band::create("Posting by e-mail (free)", 0, 0, true);
         } elseif ($language == "nl_NL") {
             // name, fixed cost, per item cost, is download
             bp_postage_band::create("Geen verzendkosten", 0, 0, false);
             bp_postage_band::create("Standaard verzendkosten", 2, 0, false);
             bp_postage_band::create("Verzending via e-mail (gratis)", 0, 0, true);
         }
     }
     //Add products if the table is empty
     $product = ORM::factory("bp_product")->where("id", "=", 1)->find();
     if (!$product->loaded()) {
         //==========================
         // SETTINGS FOR ENGLISH
         if ($language == "en_US" or $language == "en_UK") {
             //get posting band id for mail
             $postage = ORM::factory("bp_postage_band")->where("name", "=", "Default posting cost")->find();
             // name, cost, descr, postageband id
             bp_product::create("4x6", 6, "Print 4x6 inch glossy", $postage->id);
             bp_product::create("8x10", 9, "Print 8x10 inch glossy", $postage->id);
             //get posting band id for e-mail
             $postage = ORM::factory("bp_postage_band")->where("name", "=", "Posting by e-mail (free)")->find();
             bp_product::create("Original", 10, "Original high resolution photo file", $postage->id);
         } elseif ($language == "nl_NL") {
             //get posting band id for mail
             $postage = ORM::factory("bp_postage_band")->where("name", "=", "Standaard verzendkosten")->find();
             // name, cost, descr, postageband id
             bp_product::create("13x18", 6, "Afdruk 13x18 cm glanzend", $postage->id);
             bp_product::create("20x30", 9, "Afdruk 20x30 cm glanzend", $postage->id);
             //get posting band id for e-mail
             $postage = ORM::factory("bp_postage_band")->where("name", "=", "Verzending via e-mail (gratis)")->find();
             bp_product::create("Origineel", 10, "Originele fotobestand in hoge resolutie", $postage->id);
         }
     }
 }
 public function add_product()
 {
     access::verify_csrf();
     $form = bp_product::get_add_form_admin();
     $valid = $form->validate();
     $name = $form->add_product->inputs["name"]->value;
     $product = ORM::factory("bp_product")->where("name", "=", $name)->find();
     if ($product->loaded()) {
         $form->add_product->inputs["name"]->add_error("in_use", 1);
         $valid = false;
     }
     if ($valid) {
         $product = bp_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;
     }
 }