Skip to content

Instantly share code, notes, and snippets.

@ainvyu
Created December 14, 2012 15:12
Show Gist options
  • Save ainvyu/4286141 to your computer and use it in GitHub Desktop.
Save ainvyu/4286141 to your computer and use it in GitHub Desktop.
Fucking CPS
exports.basket_section_add = function(req, res) {
var basket_number = req.session.basket_number;
var category1 = req.body.category1;
var category2 = req.body.category2;
var category3 = req.body.category3;
console.log(basket_number);
dbconn.query("SELECT product_number FROM product WHERE category3=$1", [ category3 ], db.after( function (results) {
var selected_product_number = results.rows[0].product_number;
var basket_id = parseInt((new Date).getTime() / 1000);
dbconn.query("INSERT INTO basket_section(basket_number, category1, category2, category3, selected_product_number, quantity, fixed, basket_id) VALUES($1, $2, $3, $4, $5, $6, $7, $8)", [ basket_number, category1, category2, category3, selected_product_number, -1, "false", basket_id ], db.after( function (results) {
dbconn.query("SELECT section_number FROM basket_section WHERE basket_id=$1", [ basket_id ], db.after( function (result) {
var added_section_number = result.rows[0].section_number;
res.send({
status: "success",
selected_product_number: selected_product_number,
section_number: added_section_number
});
}));
}));
}));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment