|
@ -14,66 +14,66 @@ class Group extends controller.Controller |
|
|
*/ |
|
|
*/ |
|
|
@tpl('group/view.mtt') |
|
|
@tpl('group/view.mtt') |
|
|
function doDefault(group:db.Amap){ |
|
|
function doDefault(group:db.Amap){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (group.regOption == db.Amap.RegOption.Open) { |
|
|
if (group.regOption == db.Amap.RegOption.Open) { |
|
|
app.session.data.amapId = group.id; |
|
|
app.session.data.amapId = group.id; |
|
|
throw Redirect("/"); |
|
|
throw Redirect("/"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.group = group; |
|
|
view.group = group; |
|
|
view.contracts = group.getActiveContracts(); |
|
|
view.contracts = group.getActiveContracts(); |
|
|
view.pageTitle = group.name; |
|
|
view.pageTitle = group.name; |
|
|
group.getMainPlace(); //just to update cache |
|
|
group.getMainPlace(); //just to update cache |
|
|
if (app.user != null){ |
|
|
if (app.user != null){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.isMember = Lambda.has(app.user.getAmaps(), group); |
|
|
view.isMember = Lambda.has(app.user.getAmaps(), group); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Register to a waiting list. |
|
|
* Register to a waiting list. |
|
|
* the user can be logged or not ! |
|
|
* the user can be logged or not ! |
|
|
*/ |
|
|
*/ |
|
|
@tpl('form.mtt') |
|
|
@tpl('form.mtt') |
|
|
function doList(group:db.Amap){ |
|
|
function doList(group:db.Amap){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//checks |
|
|
//checks |
|
|
if (group.regOption != db.Amap.RegOption.WaitingList) throw Redirect("/group/" + group.id); |
|
|
if (group.regOption != db.Amap.RegOption.WaitingList) throw Redirect("/group/" + group.id); |
|
|
if (app.user != null) { |
|
|
if (app.user != null) { |
|
|
try{ |
|
|
try{ |
|
|
WaitingListService.canRegister(app.user,group); |
|
|
WaitingListService.canRegister(app.user,group); |
|
|
}catch(e:tink.core.Error){ |
|
|
|
|
|
|
|
|
}catch(e:tink.core.Error){ |
|
|
throw Error("/group/" + group.id,e.message); |
|
|
throw Error("/group/" + group.id,e.message); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//build form |
|
|
//build form |
|
|
var form = new sugoi.form.Form("reg"); |
|
|
|
|
|
|
|
|
var form = new sugoi.form.Form("reg"); |
|
|
if (app.user == null){ |
|
|
if (app.user == null){ |
|
|
form.addElement(new StringInput("userFirstName", t._("Your firstname"),"",true)); |
|
|
form.addElement(new StringInput("userFirstName", t._("Your firstname"),"",true)); |
|
|
form.addElement(new StringInput("userLastName", t._("Your lastname") ,"",true)); |
|
|
form.addElement(new StringInput("userLastName", t._("Your lastname") ,"",true)); |
|
|
form.addElement(new StringInput("userEmail", t._("Your e-mail"), "", true)); |
|
|
|
|
|
|
|
|
form.addElement(new StringInput("userEmail", t._("Your e-mail"), "", true)); |
|
|
} |
|
|
} |
|
|
form.addElement(new sugoi.form.elements.TextArea("msg", t._("Leave a message"))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
form.addElement(new sugoi.form.elements.TextArea("msg", t._("Leave a message"),"",false)); |
|
|
|
|
|
|
|
|
if (form.isValid()){ |
|
|
if (form.isValid()){ |
|
|
try{ |
|
|
try{ |
|
|
if (app.user == null){ |
|
|
if (app.user == null){ |
|
|
var f = form; |
|
|
var f = form; |
|
|
var user = service.UserService.softRegistration(f.getValueOf("userFirstName"),f.getValueOf("userLastName"), f.getValueOf("userEmail") ); |
|
|
var user = service.UserService.softRegistration(f.getValueOf("userFirstName"),f.getValueOf("userLastName"), f.getValueOf("userEmail") ); |
|
|
db.User.login(user, user.email); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.User.login(user, user.email); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WaitingListService.registerToWl(app.user,group,form.getValueOf("msg")); |
|
|
WaitingListService.registerToWl(app.user,group,form.getValueOf("msg")); |
|
|
throw Ok("/group/" + group.id,t._("Your subscription to the waiting list has been recorded. You will receive an e-mail as soon as your request is processed.") ); |
|
|
throw Ok("/group/" + group.id,t._("Your subscription to the waiting list has been recorded. You will receive an e-mail as soon as your request is processed.") ); |
|
|
}catch(e:tink.core.Error){ |
|
|
}catch(e:tink.core.Error){ |
|
|
throw Error("/group/list/" + group.id,e.message); |
|
|
throw Error("/group/list/" + group.id,e.message); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.title = t._("Subscription to \"::groupeName::\" waiting list", {groupeName:group.name}); |
|
|
view.title = t._("Subscription to \"::groupeName::\" waiting list", {groupeName:group.name}); |
|
|
view.form = form; |
|
|
|
|
|
|
|
|
view.form = form; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -82,27 +82,27 @@ class Group extends controller.Controller |
|
|
function doListCancel(group:db.Amap){ |
|
|
function doListCancel(group:db.Amap){ |
|
|
try{ |
|
|
try{ |
|
|
WaitingListService.removeFromWl(app.user,group); |
|
|
WaitingListService.removeFromWl(app.user,group); |
|
|
}catch(e:tink.core.Error){ |
|
|
|
|
|
|
|
|
}catch(e:tink.core.Error){ |
|
|
throw Error("/group/" + group.id,e.message); |
|
|
throw Error("/group/" + group.id,e.message); |
|
|
} |
|
|
} |
|
|
throw Ok("/group/" + group.id,t._("You've been removed from the waiting list")); |
|
|
throw Ok("/group/" + group.id,t._("You've been removed from the waiting list")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Register direclty in an open group |
|
|
* Register direclty in an open group |
|
|
* |
|
|
|
|
|
|
|
|
* |
|
|
* the user can be logged or not ! |
|
|
* the user can be logged or not ! |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@tpl('form.mtt') |
|
|
@tpl('form.mtt') |
|
|
function doRegister(group:db.Amap){ |
|
|
function doRegister(group:db.Amap){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (group.regOption != db.Amap.RegOption.Open) throw Redirect("/group/" + group.id); |
|
|
if (group.regOption != db.Amap.RegOption.Open) throw Redirect("/group/" + group.id); |
|
|
if (app.user != null){ |
|
|
|
|
|
if ( db.UserAmap.manager.select($amapId == group.id && $user == app.user) != null) throw Error("/group/" + group.id, t._("You are already member of this group.")); |
|
|
|
|
|
|
|
|
if (app.user != null){ |
|
|
|
|
|
if ( db.UserAmap.manager.select($amapId == group.id && $user == app.user) != null) throw Error("/group/" + group.id, t._("You are already member of this group.")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var form = new sugoi.form.Form("reg"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var form = new sugoi.form.Form("reg"); |
|
|
form.submitButtonLabel = t._("Join the group"); |
|
|
form.submitButtonLabel = t._("Join the group"); |
|
|
form.addElement(new sugoi.form.elements.Html("html",t._("Confirm your subscription to \"::groupName::\"", {groupName:group.name}))); |
|
|
form.addElement(new sugoi.form.elements.Html("html",t._("Confirm your subscription to \"::groupName::\"", {groupName:group.name}))); |
|
|
if (app.user == null){ |
|
|
if (app.user == null){ |
|
@ -110,15 +110,15 @@ class Group extends controller.Controller |
|
|
form.addElement(new StringInput("userLastName", t._("Your lastname"), "", true)); |
|
|
form.addElement(new StringInput("userLastName", t._("Your lastname"), "", true)); |
|
|
var em = new StringInput("userEmail", t._("Your e-mail"), "", true); |
|
|
var em = new StringInput("userEmail", t._("Your e-mail"), "", true); |
|
|
em.addValidator(new EmailValidator()); |
|
|
em.addValidator(new EmailValidator()); |
|
|
form.addElement(em); |
|
|
|
|
|
form.addElement(new StringInput("address", t._("Address"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("zipCode", t._("Zip code"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("city", t._("City"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("phone", t._("Phone"), "", true)); |
|
|
|
|
|
|
|
|
form.addElement(em); |
|
|
|
|
|
form.addElement(new StringInput("address", t._("Address"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("zipCode", t._("Zip code"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("city", t._("City"), "", true)); |
|
|
|
|
|
form.addElement(new StringInput("phone", t._("Phone"), "", true)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (form.isValid()){ |
|
|
if (form.isValid()){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (app.user == null){ |
|
|
if (app.user == null){ |
|
|
var f = form; |
|
|
var f = form; |
|
|
var user = new db.User(); |
|
|
var user = new db.User(); |
|
@ -129,92 +129,92 @@ class Group extends controller.Controller |
|
|
user.zipCode = f.getValueOf("zipCode"); |
|
|
user.zipCode = f.getValueOf("zipCode"); |
|
|
user.city = f.getValueOf("city"); |
|
|
user.city = f.getValueOf("city"); |
|
|
user.phone = f.getValueOf("phone"); |
|
|
user.phone = f.getValueOf("phone"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( db.User.getSameEmail(user.email).length > 0 ) { |
|
|
if ( db.User.getSameEmail(user.email).length > 0 ) { |
|
|
throw Ok("/user/login",t._("You already subscribed to Cagette.net, please log in on this page")); |
|
|
throw Ok("/user/login",t._("You already subscribed to Cagette.net, please log in on this page")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
user.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.insert(); |
|
|
app.session.setUser(user); |
|
|
app.session.setUser(user); |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var w = new db.UserAmap(); |
|
|
var w = new db.UserAmap(); |
|
|
w.user = app.user; |
|
|
w.user = app.user; |
|
|
w.amap = group; |
|
|
w.amap = group; |
|
|
w.insert(); |
|
|
w.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Ok("/user/choose", t._("Your subscription has been taken into account")); |
|
|
throw Ok("/user/choose", t._("Your subscription has been taken into account")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.title = t._("Subscription to \"::groupName::\"", {groupName:group.name}); |
|
|
view.title = t._("Subscription to \"::groupName::\"", {groupName:group.name}); |
|
|
view.form = form; |
|
|
view.form = form; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}*/ |
|
|
}*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* create a new group |
|
|
* create a new group |
|
|
*/ |
|
|
*/ |
|
|
@tpl("form.mtt") |
|
|
@tpl("form.mtt") |
|
|
function doCreate() { |
|
|
function doCreate() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.title = t._("Create a new Cagette Group"); |
|
|
view.title = t._("Create a new Cagette Group"); |
|
|
|
|
|
|
|
|
var f = new sugoi.form.Form("c"); |
|
|
var f = new sugoi.form.Form("c"); |
|
|
f.addElement(new StringInput("name", t._("Name of your group"), "", true)); |
|
|
f.addElement(new StringInput("name", t._("Name of your group"), "", true)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//group type |
|
|
//group type |
|
|
var data = [ |
|
|
var data = [ |
|
|
{label:t._("CSA"),value:"0"}, |
|
|
{label:t._("CSA"),value:"0"}, |
|
|
{label:t._("Grouped orders"),value:"1"}, |
|
|
{label:t._("Grouped orders"),value:"1"}, |
|
|
{label:t._("Farmers collective"),value:"2"}, |
|
|
{label:t._("Farmers collective"),value:"2"}, |
|
|
{label:t._("Farm shop"),value:"3"}, |
|
|
{label:t._("Farm shop"),value:"3"}, |
|
|
]; |
|
|
|
|
|
|
|
|
]; |
|
|
var gt = new sugoi.form.elements.RadioGroup("type", t._("Group type"), data ,"1","1",true,true,true); |
|
|
var gt = new sugoi.form.elements.RadioGroup("type", t._("Group type"), data ,"1","1",true,true,true); |
|
|
f.addElement(gt); |
|
|
f.addElement(gt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (f.checkToken()) { |
|
|
if (f.checkToken()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var user = app.user; |
|
|
var user = app.user; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var g = new db.Amap(); |
|
|
var g = new db.Amap(); |
|
|
g.name = f.getValueOf("name"); |
|
|
g.name = f.getValueOf("name"); |
|
|
g.contact = user; |
|
|
g.contact = user; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var type:db.Amap.GroupType = Type.createEnumIndex(db.Amap.GroupType, Std.parseInt(f.getValueOf("type")) ); |
|
|
var type:db.Amap.GroupType = Type.createEnumIndex(db.Amap.GroupType, Std.parseInt(f.getValueOf("type")) ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(type){ |
|
|
switch(type){ |
|
|
case null : |
|
|
|
|
|
|
|
|
case null : |
|
|
throw "unknown group type"; |
|
|
throw "unknown group type"; |
|
|
case db.Amap.GroupType.Amap : |
|
|
|
|
|
|
|
|
case db.Amap.GroupType.Amap : |
|
|
g.flags.set(db.Amap.AmapFlags.HasMembership); |
|
|
g.flags.set(db.Amap.AmapFlags.HasMembership); |
|
|
g.regOption = db.Amap.RegOption.WaitingList; |
|
|
g.regOption = db.Amap.RegOption.WaitingList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case db.Amap.GroupType.GroupedOrders : |
|
|
case db.Amap.GroupType.GroupedOrders : |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.flags.set(db.Amap.AmapFlags.HasMembership); |
|
|
g.flags.set(db.Amap.AmapFlags.HasMembership); |
|
|
g.regOption = db.Amap.RegOption.WaitingList; |
|
|
g.regOption = db.Amap.RegOption.WaitingList; |
|
|
|
|
|
|
|
|
case db.Amap.GroupType.ProducerDrive : |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case db.Amap.GroupType.ProducerDrive : |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.regOption = db.Amap.RegOption.Open; |
|
|
g.regOption = db.Amap.RegOption.Open; |
|
|
g.flags.set(db.Amap.AmapFlags.PhoneRequired); |
|
|
g.flags.set(db.Amap.AmapFlags.PhoneRequired); |
|
|
|
|
|
|
|
|
case db.Amap.GroupType.FarmShop : |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case db.Amap.GroupType.FarmShop : |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.flags.set(db.Amap.AmapFlags.ShopMode); |
|
|
g.regOption = db.Amap.RegOption.Open; |
|
|
g.regOption = db.Amap.RegOption.Open; |
|
|
g.flags.set(db.Amap.AmapFlags.PhoneRequired); |
|
|
g.flags.set(db.Amap.AmapFlags.PhoneRequired); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
g.groupType = type; |
|
|
g.groupType = type; |
|
|
g.insert(); |
|
|
g.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ua = new db.UserAmap(); |
|
|
var ua = new db.UserAmap(); |
|
|
ua.user = user; |
|
|
ua.user = user; |
|
|
ua.amap = g; |
|
|
ua.amap = g; |
|
|
ua.rights = [db.UserAmap.Right.GroupAdmin,db.UserAmap.Right.Membership,db.UserAmap.Right.Messages,db.UserAmap.Right.ContractAdmin(null)]; |
|
|
ua.rights = [db.UserAmap.Right.GroupAdmin,db.UserAmap.Right.Membership,db.UserAmap.Right.Messages,db.UserAmap.Right.ContractAdmin(null)]; |
|
|
ua.insert(); |
|
|
ua.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//example datas |
|
|
//example datas |
|
|
var place = new db.Place(); |
|
|
var place = new db.Place(); |
|
|
place.name = t._("Market square"); |
|
|
place.name = t._("Market square"); |
|
@ -222,7 +222,7 @@ class Group extends controller.Controller |
|
|
place.city = "St Martin de la Cagette"; |
|
|
place.city = "St Martin de la Cagette"; |
|
|
place.amap = g; |
|
|
place.amap = g; |
|
|
place.insert(); |
|
|
place.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//contrat AMAP |
|
|
//contrat AMAP |
|
|
var vendor = new db.Vendor(); |
|
|
var vendor = new db.Vendor(); |
|
|
vendor.amap = g; |
|
|
vendor.amap = g; |
|
@ -230,8 +230,8 @@ class Group extends controller.Controller |
|
|
vendor.zipCode = "000"; |
|
|
vendor.zipCode = "000"; |
|
|
vendor.city = "Langon"; |
|
|
vendor.city = "Langon"; |
|
|
vendor.email = "jean@cagette.net"; |
|
|
vendor.email = "jean@cagette.net"; |
|
|
vendor.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor.insert(); |
|
|
|
|
|
|
|
|
if (type == Amap){ |
|
|
if (type == Amap){ |
|
|
var contract = new db.Contract(); |
|
|
var contract = new db.Contract(); |
|
|
contract.name = t._("CSA contract Vegetables - Example"); |
|
|
contract.name = t._("CSA contract Vegetables - Example"); |
|
@ -244,32 +244,32 @@ class Group extends controller.Controller |
|
|
contract.contact = user; |
|
|
contract.contact = user; |
|
|
contract.distributorNum = 2; |
|
|
contract.distributorNum = 2; |
|
|
contract.insert(); |
|
|
contract.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var p = new db.Product(); |
|
|
var p = new db.Product(); |
|
|
p.name = t._("Big basket of vegetables"); |
|
|
p.name = t._("Big basket of vegetables"); |
|
|
p.price = 15; |
|
|
p.price = 15; |
|
|
p.organic = true; |
|
|
p.organic = true; |
|
|
p.contract = contract; |
|
|
p.contract = contract; |
|
|
p.insert(); |
|
|
p.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var p = new db.Product(); |
|
|
var p = new db.Product(); |
|
|
p.name = t._("Small basket of vegetables"); |
|
|
p.name = t._("Small basket of vegetables"); |
|
|
p.price = 10; |
|
|
p.price = 10; |
|
|
p.organic = true; |
|
|
p.organic = true; |
|
|
p.contract = contract; |
|
|
p.contract = contract; |
|
|
p.insert(); |
|
|
p.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrderService.make(user, 1, p, null, true); |
|
|
OrderService.make(user, 1, p, null, true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var d = new db.Distribution(); |
|
|
var d = new db.Distribution(); |
|
|
d.contract = contract; |
|
|
d.contract = contract; |
|
|
d.date = DateTools.delta(Date.now(), 1000.0 * 60 * 60 * 24 * 14); |
|
|
d.date = DateTools.delta(Date.now(), 1000.0 * 60 * 60 * 24 * 14); |
|
|
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); |
|
|
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); |
|
|
d.place = place; |
|
|
d.place = place; |
|
|
d.insert(); |
|
|
d.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//contrat variable |
|
|
//contrat variable |
|
|
var vendor = new db.Vendor(); |
|
|
var vendor = new db.Vendor(); |
|
|
vendor.amap = g; |
|
|
vendor.amap = g; |
|
@ -277,8 +277,8 @@ class Group extends controller.Controller |
|
|
vendor.zipCode = "000"; |
|
|
vendor.zipCode = "000"; |
|
|
vendor.city = t._("Bazas"); |
|
|
vendor.city = t._("Bazas"); |
|
|
vendor.email = "galinette@cagette.net"; |
|
|
vendor.email = "galinette@cagette.net"; |
|
|
vendor.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor.insert(); |
|
|
|
|
|
|
|
|
var contract = new db.Contract(); |
|
|
var contract = new db.Contract(); |
|
|
contract.name = t._("Chicken Contract - Example"); |
|
|
contract.name = t._("Chicken Contract - Example"); |
|
|
contract.description = t._("Example of contract with variable orders. It is allowed to order something else at every delivery."); |
|
|
contract.description = t._("Example of contract with variable orders. It is allowed to order something else at every delivery."); |
|
@ -291,7 +291,7 @@ class Group extends controller.Controller |
|
|
contract.distributorNum = 2; |
|
|
contract.distributorNum = 2; |
|
|
contract.flags.set(db.Contract.ContractFlags.UsersCanOrder); |
|
|
contract.flags.set(db.Contract.ContractFlags.UsersCanOrder); |
|
|
contract.insert(); |
|
|
contract.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var egg = new db.Product(); |
|
|
var egg = new db.Product(); |
|
|
egg.name = t._("12 eggs"); |
|
|
egg.name = t._("12 eggs"); |
|
|
egg.price = 5; |
|
|
egg.price = 5; |
|
@ -299,7 +299,7 @@ class Group extends controller.Controller |
|
|
egg.organic = true; |
|
|
egg.organic = true; |
|
|
egg.contract = contract; |
|
|
egg.contract = contract; |
|
|
egg.insert(); |
|
|
egg.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var p = new db.Product(); |
|
|
var p = new db.Product(); |
|
|
p.name = t._("Chicken"); |
|
|
p.name = t._("Chicken"); |
|
|
//p.type = 2; |
|
|
//p.type = 2; |
|
@ -307,7 +307,7 @@ class Group extends controller.Controller |
|
|
p.organic = true; |
|
|
p.organic = true; |
|
|
p.contract = contract; |
|
|
p.contract = contract; |
|
|
p.insert(); |
|
|
p.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var d = new db.Distribution(); |
|
|
var d = new db.Distribution(); |
|
|
d.contract = contract; |
|
|
d.contract = contract; |
|
|
d.orderStartDate = Date.now(); |
|
|
d.orderStartDate = Date.now(); |
|
@ -316,36 +316,36 @@ class Group extends controller.Controller |
|
|
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); |
|
|
d.end = DateTools.delta(d.date, 1000.0 * 60 * 90); |
|
|
d.place = place; |
|
|
d.place = place; |
|
|
d.insert(); |
|
|
d.insert(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OrderService.make(user, 2, egg, d.id); |
|
|
OrderService.make(user, 2, egg, d.id); |
|
|
OrderService.make(user, 1, p, d.id); |
|
|
OrderService.make(user, 1, p, d.id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.current.session.data.amapId = g.id; |
|
|
App.current.session.data.amapId = g.id; |
|
|
app.session.data.newGroup = true; |
|
|
app.session.data.newGroup = true; |
|
|
throw Redirect("/"); |
|
|
throw Redirect("/"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.form= f; |
|
|
view.form= f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
Displays a google map in a popup |
|
|
Displays a google map in a popup |
|
|
**/ |
|
|
**/ |
|
|
@tpl('group/place.mtt') |
|
|
@tpl('group/place.mtt') |
|
|
public function doPlace(place:db.Place){ |
|
|
public function doPlace(place:db.Place){ |
|
|
view.place = place; |
|
|
view.place = place; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//build adress for google maps |
|
|
//build adress for google maps |
|
|
var addr = ""; |
|
|
var addr = ""; |
|
|
if (place.address1 != null) addr += place.address1; |
|
|
if (place.address1 != null) addr += place.address1; |
|
|
if (place.address2 != null) addr += ", " + place.address2; |
|
|
if (place.address2 != null) addr += ", " + place.address2; |
|
|
if (place.zipCode != null) addr += " " + place.zipCode; |
|
|
if (place.zipCode != null) addr += " " + place.zipCode; |
|
|
if (place.city != null) addr += " " + place.city; |
|
|
if (place.city != null) addr += " " + place.city; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.addr = view.escapeJS(addr); |
|
|
view.addr = view.escapeJS(addr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Groups map |
|
|
* Groups map |
|
|
*/ |
|
|
*/ |
|
@ -353,16 +353,16 @@ class Group extends controller.Controller |
|
|
public function doMap(?args:{?lat:Float,?lng:Float,?address:String}){ |
|
|
public function doMap(?args:{?lat:Float,?lng:Float,?address:String}){ |
|
|
|
|
|
|
|
|
view.container = "container-fluid"; |
|
|
view.container = "container-fluid"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if no param is sent, focus on Paris |
|
|
//if no param is sent, focus on Paris |
|
|
if (args == null || (args.address == null && args.lat == null && args.lng == null)){ |
|
|
if (args == null || (args.address == null && args.lat == null && args.lng == null)){ |
|
|
args = {lat:48.855675, lng:2.3472365}; |
|
|
args = {lat:48.855675, lng:2.3472365}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
view.lat = args.lat; |
|
|
view.lat = args.lat; |
|
|
view.lng = args.lng; |
|
|
view.lng = args.lng; |
|
|
view.address = args.address; |
|
|
|
|
|
|
|
|
view.address = args.address; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |