Commit ab9d6a3c by Riku Silvola

Merge branch 'master' of codecrew.fi:bortal

2 parents ae5d3663 454f7c0e
...@@ -209,11 +209,9 @@ public class BillBean implements BillBeanLocal { ...@@ -209,11 +209,9 @@ public class BillBean implements BillBeanLocal {
Product creditproduct = productBean.findCreditProduct(); Product creditproduct = productBean.findCreditProduct();
EventUser user = bill.getUser(); EventUser user = bill.getUser();
AccountEvent ac = productBean.createAccountEvent(creditproduct, AccountEvent ac = productBean.createAccountEvent(creditproduct, bill.totalPrice(), user);
bill.totalPrice(), user);
logger.info("Created creditentry. {}, userproducts {}", ac, user logger.info("Created creditentry. {}, userproducts {}", ac, user.getAccountEvents().size());
.getAccountEvents().size());
ac.setDelivered(when); ac.setDelivered(when);
ac.setEventTime(when); ac.setEventTime(when);
...@@ -224,27 +222,20 @@ public class BillBean implements BillBeanLocal { ...@@ -224,27 +222,20 @@ public class BillBean implements BillBeanLocal {
bill.setPaidDate(when.getTime()); bill.setPaidDate(when.getTime());
// bill = billFacade.merge(bill); // bill = billFacade.merge(bill);
boolean checked = false;
for (BillLine bl : bill.getBillLines()) { for (BillLine bl : bill.getBillLines()) {
Product prod = bl.getLineProduct(); Product prod = bl.getLineProduct();
if (prod != null if (prod != null && prod.getProductFlags().contains(ProductFlag.PREPAID_INSTANT_CREATE)) {
&& prod.getProductFlags().contains(
ProductFlag.PREPAID_INSTANT_CREATE)) { logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
if (prod.getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
logger.debug("Creating Bill prepaidInstant product {}, {}", || prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
prod.getName(), bl.getQuantity()); placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity());
if (prod.getProductFlags().contains(
ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| prod.getProductFlags().contains(
ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(bill.getUser(), prod,
bl.getQuantity());
} }
AccountEvent ac2 = productPBean.createAccountEvent(prod, AccountEvent ac2 = productPBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave()); logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size());
logger.info("Created ac from product. {}, userproducts {}",
ac2, user.getAccountEvents().size());
ac2.setSeller(permbean.getCurrentUser()); ac2.setSeller(permbean.getCurrentUser());
...@@ -253,9 +244,7 @@ public class BillBean implements BillBeanLocal { ...@@ -253,9 +244,7 @@ public class BillBean implements BillBeanLocal {
} }
MailMessage msg = new MailMessage(); MailMessage msg = new MailMessage();
msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject")); msg.setSubject(I18n.get("bill.billMarkedPaidMail.subject"));
msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill msg.setMessage(I18n.get("bill.billMarkedPaidMail.message", (bill.getBillNumber() == null) ? "----" : bill.getBillNumber().toString()));
.getBillNumber() == null) ? "----" : bill.getBillNumber()
.toString()));
msg.setTo(bill.getUser().getUser()); msg.setTo(bill.getUser().getUser());
utilbean.sendMail(msg); utilbean.sendMail(msg);
eventUserFacade.flush(); eventUserFacade.flush();
...@@ -265,13 +254,9 @@ public class BillBean implements BillBeanLocal { ...@@ -265,13 +254,9 @@ public class BillBean implements BillBeanLocal {
@Override @Override
@RolesAllowed({ BillPermission.S_CREATE_BILL, BillPermission.S_WRITE_ALL }) @RolesAllowed({ BillPermission.S_CREATE_BILL, BillPermission.S_WRITE_ALL })
public void createBill(Bill bill) { public void createBill(Bill bill) {
if (!permbean.isCurrentUser(bill.getUser()) if (!permbean.isCurrentUser(bill.getUser()) && !permbean.hasPermission(BillPermission.WRITE_ALL)) {
&& !permbean.hasPermission(BillPermission.WRITE_ALL)) { loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to create bill for user ");
loggingBean.logMessage(SecurityLogType.permissionDenied, throw new EJBAccessException("Could not create bill for another user");
permbean.getCurrentUser(),
"Not enought rights to create bill for user ");
throw new EJBAccessException(
"Could not create bill for another user");
} }
billFacade.create(bill); billFacade.create(bill);
generateBillNumber(bill); generateBillNumber(bill);
...@@ -285,13 +270,9 @@ public class BillBean implements BillBeanLocal { ...@@ -285,13 +270,9 @@ public class BillBean implements BillBeanLocal {
@Override @Override
@RolesAllowed({ BillPermission.S_VIEW_OWN, BillPermission.S_READ_ALL }) @RolesAllowed({ BillPermission.S_VIEW_OWN, BillPermission.S_READ_ALL })
public List<Bill> find(EventUser user) { public List<Bill> find(EventUser user) {
if (!permbean.isCurrentUser(user) if (!permbean.isCurrentUser(user) && !permbean.hasPermission(BillPermission.READ_ALL)) {
&& !permbean.hasPermission(BillPermission.READ_ALL)) { loggingBean.logMessage(SecurityLogType.permissionDenied, permbean.getCurrentUser(), "Not enought rights to get bill list for user ");
loggingBean.logMessage(SecurityLogType.permissionDenied, throw new EJBAccessException("Could not list bills for another user");
permbean.getCurrentUser(),
"Not enought rights to get bill list for user ");
throw new EJBAccessException(
"Could not list bills for another user");
} }
return billFacade.find(user); return billFacade.find(user);
} }
......
...@@ -107,6 +107,9 @@ public class CardPrintBean implements CardPrintBeanLocal { ...@@ -107,6 +107,9 @@ public class CardPrintBean implements CardPrintBeanLocal {
.read(new ByteArrayInputStream(user.getCurrentImage() .read(new ByteArrayInputStream(user.getCurrentImage()
.getImageData())); .getImageData()));
if(faceBufferedImage.getWidth() > 1024 || faceBufferedImage.getHeight() > 1024) {
throw new Exception("Image dimensions too large, please take/upload smaller!");
}
int originalWidth = faceBufferedImage.getWidth(); int originalWidth = faceBufferedImage.getWidth();
int originalHeight = faceBufferedImage.getHeight(); int originalHeight = faceBufferedImage.getHeight();
......
...@@ -78,15 +78,14 @@ public class ProductPBean { ...@@ -78,15 +78,14 @@ public class ProductPBean {
unitPrice = unitPrice.multiply(d.getPercentage()); unitPrice = unitPrice.multiply(d.getPercentage());
} }
AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, AccountEvent ret = new AccountEvent(user, product, unitPrice, quantity, Calendar.getInstance());
Calendar.getInstance());
ret.setDelivered(Calendar.getInstance()); ret.setDelivered(Calendar.getInstance());
ret.setSeller(permbean.getCurrentUser()); ret.setSeller(permbean.getCurrentUser());
if (foodwave != null) { if (foodwave != null) {
ret.setFoodWave(foodwave); ret.setFoodWave(foodwave);
if(foodwave.getAccountEvents() == null) { if (foodwave.getAccountEvents() == null) {
foodwave.setAccountEvents(new ArrayList<AccountEvent>()); foodwave.setAccountEvents(new ArrayList<AccountEvent>());
} }
foodwave.getAccountEvents().add(ret); foodwave.getAccountEvents().add(ret);
......
...@@ -41,14 +41,14 @@ ...@@ -41,14 +41,14 @@
<h:commandButton action="#{foodWaveView.saveTemplate()}" <h:commandButton action="#{foodWaveView.saveTemplate()}"
value="#{i18n['foodwavetemplate.save']}" /> value="#{i18n['foodwavetemplate.save']}" />
</h:panelGrid> </h:panelGrid>
<h:selectOneMenu value="#{foodWaveView.currentProduct}" <!-- <h:selectOneMenu value="#{foodWaveView.currentProduct}"
converter="#{productConverter}"> converter="#{productConverter}">
<f:selectItems value="#{foodWaveView.products}" var="product" <f:selectItems value="#{foodWaveView.products}" var="product"
itemLabel="#{product.name}"></f:selectItems> itemLabel="#{product.name}"></f:selectItems>
</h:selectOneMenu> </h:selectOneMenu>
<p:commandButton value="#{i18n['foodwavetemplate.addproduct']}" <p:commandButton value="#{i18n['foodwavetemplate.addproduct']}"
actionListener="#{foodWaveView.addProductToTemplate}" actionListener="#{foodWaveView.addProductToTemplate}"
update="productTable" /> update="productTable" /> -->
<h:panelGrid columns="4"> <h:panelGrid columns="4">
......
...@@ -7,6 +7,7 @@ import javax.faces.bean.RequestScoped; ...@@ -7,6 +7,7 @@ import javax.faces.bean.RequestScoped;
import javax.inject.Named; import javax.inject.Named;
import fi.insomnia.bortal.beans.ActionLogBeanLocal; import fi.insomnia.bortal.beans.ActionLogBeanLocal;
import fi.insomnia.bortal.enums.apps.ContentPermission;
import fi.insomnia.bortal.model.ActionLogMessage; import fi.insomnia.bortal.model.ActionLogMessage;
import fi.insomnia.bortal.web.cdiview.GenericCDIView; import fi.insomnia.bortal.web.cdiview.GenericCDIView;
...@@ -29,6 +30,9 @@ public class ActionLogMessageView extends GenericCDIView { ...@@ -29,6 +30,9 @@ public class ActionLogMessageView extends GenericCDIView {
} }
public List<ActionLogMessage> getMessages() { public List<ActionLogMessage> getMessages() {
if (super.hasPermission(ContentPermission.MANAGE_ACTIONLOG)) {
return actionLogBean.getAllActionLogEvents(); return actionLogBean.getAllActionLogEvents();
} }
return null;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!