modify the General Data tab of a project in order to include
the table to manage the end date communications to customer. FEA: ItEr76S21UpdateEndDateToCustomer
This commit is contained in:
parent
a5fec5b8b6
commit
02d674c64e
5 changed files with 206 additions and 5 deletions
|
|
@ -612,6 +612,7 @@ public class Order extends OrderLineGroup implements Comparable {
|
|||
return Collections.unmodifiableSortedSet(this.endDateCommunicationToCustomer);
|
||||
}
|
||||
|
||||
|
||||
public void updateFirstAskedEndDate(Date communicationDate) {
|
||||
if (this.endDateCommunicationToCustomer != null && !this.endDateCommunicationToCustomer.isEmpty()) {
|
||||
this.endDateCommunicationToCustomer.first().setCommunicationDate(communicationDate);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,13 @@
|
|||
|
||||
package org.libreplan.web.orders;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.libreplan.business.calendars.entities.BaseCalendar;
|
||||
import org.libreplan.business.externalcompanies.entities.EndDateCommunicationToCustomer;
|
||||
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
|
|
@ -128,4 +131,12 @@ public interface IOrderModel extends IIntegrationEntityModel {
|
|||
|
||||
PlanningState getPlanningState();
|
||||
|
||||
void removeAskedEndDate(EndDateCommunicationToCustomer endDate);
|
||||
|
||||
SortedSet<EndDateCommunicationToCustomer> getEndDates();
|
||||
|
||||
void addAskedEndDate(Date value);
|
||||
|
||||
boolean alreadyExistsRepeatedEndDate(Date value);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
|||
import org.libreplan.business.common.exceptions.ValidationException;
|
||||
import org.libreplan.business.externalcompanies.entities.DeadlineCommunication;
|
||||
import org.libreplan.business.externalcompanies.entities.DeliverDateComparator;
|
||||
import org.libreplan.business.externalcompanies.entities.EndDateCommunicationToCustomer;
|
||||
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||
import org.libreplan.business.orders.entities.HoursGroup;
|
||||
|
|
@ -74,6 +75,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.util.LongOperationFeedback;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
|
@ -228,6 +230,10 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
private Grid gridAskedEndDates;
|
||||
|
||||
private EndDatesRenderer endDatesRenderer = new EndDatesRenderer();
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -1003,6 +1009,8 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
});
|
||||
|
||||
gridAskedEndDates = (Grid) editWindow.getFellow("gridAskedEndDates");
|
||||
|
||||
}
|
||||
|
||||
public void setupOrderDetails() {
|
||||
|
|
@ -1568,4 +1576,109 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public SortedSet<EndDateCommunicationToCustomer> getEndDates() {
|
||||
return orderModel.getEndDates();
|
||||
}
|
||||
|
||||
public void addAskedEndDate(Datebox newEndDate) {
|
||||
if (newEndDate == null || newEndDate.getValue() == null) {
|
||||
messagesForUser.showMessage(Level.ERROR, _("You must select a valid date. "));
|
||||
return;
|
||||
}
|
||||
if (thereIsSomeCommunicationDateEmpty()) {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.ERROR,
|
||||
_("It will only be possible to add a end date if all the exiting ones in the table have already been sent to customer.."));
|
||||
return;
|
||||
}
|
||||
if (orderModel.alreadyExistsRepeatedEndDate(newEndDate.getValue())) {
|
||||
messagesForUser.showMessage(Level.ERROR,
|
||||
_("It already exists a end date with the same date. "));
|
||||
return;
|
||||
}
|
||||
orderModel.addAskedEndDate(newEndDate.getValue());
|
||||
reloadGridAskedEndDates();
|
||||
}
|
||||
|
||||
private void reloadGridAskedEndDates() {
|
||||
Util.reloadBindings(gridAskedEndDates);
|
||||
}
|
||||
|
||||
private boolean thereIsSomeCommunicationDateEmpty() {
|
||||
for (EndDateCommunicationToCustomer endDate : orderModel.getEndDates()) {
|
||||
if (endDate.getCommunicationDate() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public EndDatesRenderer getEndDatesRenderer() {
|
||||
return this.endDatesRenderer;
|
||||
}
|
||||
|
||||
private class EndDatesRenderer implements RowRenderer {
|
||||
|
||||
@Override
|
||||
public void render(Row row, Object data) throws Exception {
|
||||
EndDateCommunicationToCustomer endDate = (EndDateCommunicationToCustomer) data;
|
||||
row.setValue(endDate);
|
||||
|
||||
appendLabel(row, toString(endDate.getSaveDate(), "dd/MM/yyyy HH:mm"));
|
||||
appendLabel(row, toString(endDate.getEndDate(), "dd/MM/yyyy"));
|
||||
appendLabel(row, toString(endDate.getCommunicationDate(), "dd/MM/yyyy HH:mm"));
|
||||
appendOperations(row, endDate);
|
||||
}
|
||||
|
||||
private String toString(Date date, String precision) {
|
||||
if (date == null) {
|
||||
return "";
|
||||
}
|
||||
return new SimpleDateFormat(precision, Locales.getCurrent()).format(date);
|
||||
}
|
||||
|
||||
private void appendLabel(Row row, String label) {
|
||||
row.appendChild(new Label(label));
|
||||
}
|
||||
|
||||
private void appendOperations(Row row, EndDateCommunicationToCustomer endDate) {
|
||||
Hbox hbox = new Hbox();
|
||||
hbox.appendChild(getDeleteButton(endDate));
|
||||
row.appendChild(hbox);
|
||||
}
|
||||
|
||||
private Button getDeleteButton(final EndDateCommunicationToCustomer endDate) {
|
||||
|
||||
Button deleteButton = new Button();
|
||||
deleteButton.setDisabled(isNotUpdate(endDate));
|
||||
deleteButton.setSclass("icono");
|
||||
deleteButton.setImage("/common/img/ico_borrar1.png");
|
||||
deleteButton.setHoverImage("/common/img/ico_borrar.png");
|
||||
deleteButton.setTooltiptext(_("Delete"));
|
||||
deleteButton.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
removeAskedEndDate(endDate);
|
||||
}
|
||||
});
|
||||
|
||||
return deleteButton;
|
||||
}
|
||||
|
||||
private boolean isNotUpdate(final EndDateCommunicationToCustomer endDate) {
|
||||
EndDateCommunicationToCustomer lastAskedEndDate = getOrder()
|
||||
.getEndDateCommunicationToCustomer().first();
|
||||
if ((lastAskedEndDate != null) && (lastAskedEndDate.equals(endDate))) {
|
||||
return (lastAskedEndDate.getCommunicationDate() != null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAskedEndDate(EndDateCommunicationToCustomer endDate) {
|
||||
orderModel.removeAskedEndDate(endDate);
|
||||
reloadGridAskedEndDates();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.libreplan.business.advance.entities.AdvanceMeasurement;
|
||||
|
|
@ -46,7 +48,7 @@ import org.libreplan.business.common.entities.Configuration;
|
|||
import org.libreplan.business.common.entities.EntityNameEnum;
|
||||
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.libreplan.business.externalcompanies.daos.IExternalCompanyDAO;
|
||||
import org.libreplan.business.externalcompanies.entities.DeadlineCommunication;
|
||||
import org.libreplan.business.externalcompanies.entities.EndDateCommunicationToCustomer;
|
||||
import org.libreplan.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.libreplan.business.labels.daos.ILabelDAO;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
|
|
@ -280,9 +282,16 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
|
|||
forceLoadLabels(order);
|
||||
forceLoadMaterialAssignments(order);
|
||||
forceLoadTaskQualityForms(order);
|
||||
forceLoadEndDateCommunicationToCustomer(order);
|
||||
initOldCodes();
|
||||
}
|
||||
|
||||
private void forceLoadEndDateCommunicationToCustomer(Order order) {
|
||||
if (order != null) {
|
||||
order.getEndDateCommunicationToCustomer().size();
|
||||
}
|
||||
}
|
||||
|
||||
private void forceLoadDeliveringDates(Order order){
|
||||
order.getDeliveringDates().size();
|
||||
}
|
||||
|
|
@ -850,4 +859,48 @@ public class OrderModel extends IntegrationEntityModel implements IOrderModel {
|
|||
return planningState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAskedEndDate(EndDateCommunicationToCustomer endDate) {
|
||||
Order order = (Order) getOrder();
|
||||
if (getOrder() != null && endDate != null) {
|
||||
order.removeAskedEndDate(endDate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SortedSet<EndDateCommunicationToCustomer> getEndDates() {
|
||||
Order order = (Order) getOrder();
|
||||
if (getOrder() != null) {
|
||||
return order.getEndDateCommunicationToCustomer();
|
||||
}
|
||||
return new TreeSet<EndDateCommunicationToCustomer>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAskedEndDate(Date value) {
|
||||
if (getOrder() != null) {
|
||||
Order order = (Order) getOrder();
|
||||
|
||||
EndDateCommunicationToCustomer askedEndDate = EndDateCommunicationToCustomer.create(
|
||||
new Date(), value, null);
|
||||
order.addAskedEndDate(askedEndDate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean alreadyExistsRepeatedEndDate(Date value) {
|
||||
if(getOrder() != null){
|
||||
Order order = (Order) getOrder();
|
||||
if (order.getEndDateCommunicationToCustomer().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EndDateCommunicationToCustomer endDateCommunicationToCustomer = order
|
||||
.getEndDateCommunicationToCustomer().first();
|
||||
Date currentEndDate = endDateCommunicationToCustomer.getEndDate();
|
||||
return (currentEndDate.compareTo(value) == 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Customer')}" />
|
||||
<bandboxSearch id="bdExternalCompanies" widthBandbox="465px" widthListbox="480px"
|
||||
<bandboxSearch id="bdExternalCompanies" widthBandbox="355px" widthListbox="370px"
|
||||
finder="ExternalCompanyBandboxFinder"
|
||||
model="@{controller.externalCompaniesAreClient}"
|
||||
selectedElement="@{controller.order.customer}"
|
||||
|
|
@ -218,14 +218,15 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Customer reference')}" />
|
||||
<textbox value="@{controller.order.customerReference}" width="465px"
|
||||
<textbox value="@{controller.order.customerReference}" width="350px"
|
||||
disabled="@{controller.subcontractedProject}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<separator spacing="20px"/>
|
||||
|
||||
<groupbox style="margin-top: 5px" sclass="assignedresources" closable="false">
|
||||
<caption label="${i18n:_('Delivery dates requested by the customer. ')}" />
|
||||
<grid id="gridDeliveryDates"
|
||||
model="@{controller.deliverDates}"
|
||||
mold="paging" pageSize="4" fixedLayout="true" width="400px"
|
||||
|
|
@ -241,7 +242,29 @@
|
|||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
</hbox>
|
||||
<separator spacing="20px"/>
|
||||
<groupbox style="margin-top: 5px" sclass="assignedresources" closable="false">
|
||||
<caption label="${i18n:_('Delivery dates asked by the subcontractor. ')}" />
|
||||
<hbox align="bottom" sclass="add-resources-or-criteria">
|
||||
<label value="${i18n:_('New end date for the customer')}" />
|
||||
<datebox id="newEndDate"/>
|
||||
<button label="${i18n:_('Add')}" onClick="controller.addAskedEndDate(newEndDate)"/>
|
||||
</hbox>
|
||||
|
||||
<separator spacing="10px"/>
|
||||
<grid id="gridAskedEndDates" model="@{controller.endDates}"
|
||||
rowRenderer="@{controller.endDatesRenderer}"
|
||||
mold="paging" pageSize="10" fixedLayout="true" width="880px">
|
||||
<columns>
|
||||
<column label="${i18n:_('Save date')}" sort="auto(saveDate)" align="center" width="220px"/>
|
||||
<column label="${i18n:_('End date')}" align="center" width="220px"/>
|
||||
<column label="${i18n:_('Communication date')}" align="center" width="220px"/>
|
||||
<column label="${i18n:_('Operations')}" align="center"/>
|
||||
</columns>
|
||||
</grid>
|
||||
</groupbox>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
<tabpanel>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue