You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.2 KiB
53 lines
1.2 KiB
package controller;
|
|
import db.UserContract;
|
|
import sugoi.form.Form;
|
|
|
|
class Amap extends Controller
|
|
{
|
|
|
|
public function new()
|
|
{
|
|
super();
|
|
}
|
|
|
|
@tpl("amap/default.mtt")
|
|
function doDefault() {
|
|
var contracts = db.Contract.getActiveContracts(app.user.amap, true, false);
|
|
for ( c in Lambda.array(contracts).copy()) {
|
|
if (c.endDate.getTime() < Date.now().getTime() ) contracts.remove(c);
|
|
}
|
|
view.contracts = contracts;
|
|
}
|
|
|
|
@tpl("form.mtt")
|
|
function doEdit() {
|
|
|
|
if (!app.user.isAmapManager()) throw t._("You don't have access to this section");
|
|
|
|
var group = app.user.amap;
|
|
|
|
var form = Form.fromSpod(group);
|
|
|
|
if (form.checkToken()) {
|
|
|
|
if(form.getValueOf("id") != app.user.amap.id) {
|
|
var editedGroup = db.Amap.manager.get(form.getValueOf("id"),false);
|
|
throw Error("/amap/edit",'Erreur, vous êtes en train de modifier "${editedGroup.name}" alors que vous êtes connecté à "${app.user.amap.name}"');
|
|
}
|
|
|
|
form.toSpod(group);
|
|
|
|
if (group.extUrl != null){
|
|
if ( group.extUrl.indexOf("http://") ==-1 && group.extUrl.indexOf("https://") ==-1 ){
|
|
group.extUrl = "http://" + group.extUrl;
|
|
}
|
|
}
|
|
|
|
group.update();
|
|
throw Ok("/amapadmin", t._("The group has been updated."));
|
|
}
|
|
|
|
view.form = form;
|
|
}
|
|
|
|
}
|