OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Comparer les révisions

Ignorer les espaces blanc Révision 146 → Révision 147

/trunk/jOpenCalendar/src/org/jopencalendar/LayoutUtilsTest.java
Nouveau fichier
0,0 → 1,39
package org.jopencalendar;
 
import static org.junit.Assert.assertEquals;
 
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
 
public class LayoutUtilsTest {
 
@Before
public void setUp() throws Exception {
}
 
@After
public void tearDown() throws Exception {
}
 
@Test
public void testFindBreak() {
final String str = "0123-56 89";
assertEquals(-1, LayoutUtils.findBreakBefore(str, 0));
assertEquals(-1, LayoutUtils.findBreakBefore(str, 3));
assertEquals(4, LayoutUtils.findBreakBefore(str, 4));
assertEquals(4, LayoutUtils.findBreakBefore(str, 5));
assertEquals(4, LayoutUtils.findBreakBefore(str, 6));
assertEquals(7, LayoutUtils.findBreakBefore(str, 7));
assertEquals(7, LayoutUtils.findBreakBefore(str, 9));
 
assertEquals(-1, LayoutUtils.findBreakAfter(str, 9));
assertEquals(-1, LayoutUtils.findBreakAfter(str, 8));
assertEquals(7, LayoutUtils.findBreakAfter(str, 7));
assertEquals(7, LayoutUtils.findBreakAfter(str, 5));
assertEquals(4, LayoutUtils.findBreakAfter(str, 4));
assertEquals(4, LayoutUtils.findBreakAfter(str, 3));
assertEquals(4, LayoutUtils.findBreakAfter(str, 0));
}
 
}
/trunk/jOpenCalendar/.classpath
2,5 → 2,6
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/UserColor.java
10,15 → 10,15
 
public class UserColor {
private static UserColor instance;
private String[] colors = new String[] { "#303F9F", "#31DE39", "#FFC107", "#C2185B", "#00796B", "#212121", "#00BCD4", "#A6A6A6", "#795548", "#B3E5FC", "#FF0000" };
private Map<Integer, Color> map = new HashMap<Integer, Color>();
private static final String[] COLORS = new String[] { "#303F9F", "#31DE39", "#FFC107", "#C2185B", "#00796B", "#212121", "#00BCD4", "#A6A6A6", "#795548", "#B3E5FC", "#FF0000" };
private final Map<Integer, Color> map = new HashMap<>();
 
public UserColor() {
List<User> users = UserManager.getInstance().getAllUser();
final List<User> users = UserManager.getInstance().getAllActiveUsers();
final int size = users.size();
for (int i = 0; i < size; i++) {
User u = users.get(i);
map.put(u.getId(), Color.decode(colors[i % colors.length]));
final User u = users.get(i);
map.put(u.getId(), Color.decode(COLORS[i % COLORS.length]));
}
}
 
26,7 → 26,7
return map.get(id);
}
 
public synchronized static final UserColor getInstance() {
public static final synchronized UserColor getInstance() {
if (instance == null) {
instance = new UserColor();
}
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationMenuProvider.java
22,6 → 22,7
 
public class OperationMenuProvider implements JPopupMenuProvider {
public OperationMenuProvider() {
//
}
 
@Override
40,7 → 41,7
}
if (!selectedItems.isEmpty()) {
final JMenu menuAssign = new JMenu("Assigner à");
final List<User> users = UserManager.getInstance().getAllUser();
final List<User> users = UserManager.getInstance().getAllActiveUsers();
// Sort by full name
Collections.sort(users, new UserComparator());
for (User user : users) {
81,11 → 82,9
menu.add(dup);
}
 
if (!selectedItems.isEmpty()) {
if (!oneIsLocked) {
menu.addSeparator();
menu.add(new DeleteAction(selectedItems));
}
if (!selectedItems.isEmpty() && !oneIsLocked) {
menu.addSeparator();
menu.add(new DeleteAction(selectedItems));
}
return menu;
}
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/CheckListModel.java
5,9 → 5,9
 
import javax.swing.AbstractListModel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
 
import org.openconcerto.ui.list.CheckListItem;
import org.openconcerto.utils.SwingWorker2;
 
public abstract class CheckListModel extends AbstractListModel {
private List<CheckListItem> items = new ArrayList<CheckListItem>();
24,7 → 24,7
 
public void loadContent() {
assert SwingUtilities.isEventDispatchThread();
SwingWorker2<List<CheckListItem>, Object> worker = new SwingWorker2<List<CheckListItem>, Object>() {
SwingWorker<List<CheckListItem>, Object> worker = new SwingWorker<List<CheckListItem>, Object>() {
 
@Override
protected List<CheckListItem> doInBackground() throws Exception {
/trunk/Modules/Module Operation/src/org/openconcerto/modules/operation/OperationHistoryPanel.java
17,6 → 17,7
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.SwingWorker;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
33,7 → 34,6
import org.openconcerto.sql.users.rights.JListSQLTablePanel;
import org.openconcerto.sql.view.IListPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.utils.SwingWorker2;
import org.openconcerto.utils.cc.ITransformer;
 
public class OperationHistoryPanel extends JPanel {
40,10 → 40,10
OperationHistoryPanel() {
this.setLayout(new GridLayout(1, 1));
final SQLBase b = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
final Map<String, List<String>> mapList = new HashMap<String, List<String>>();
final Map<String, List<String>> mapList = new HashMap<>();
mapList.put("Interventions", Arrays.asList("OPERATION"));
 
final Map<SQLTable, SQLField> map = new HashMap<SQLTable, SQLField>();
final Map<SQLTable, SQLField> map = new HashMap<>();
final ComboSQLRequest comboRequest = JListSQLTablePanel.createComboRequest(Configuration.getInstance().getDirectory().getElement(b.getTable("SITE")), true);
 
JPanel panel = new JPanel();
73,7 → 73,7
final List<SQLRowValues> selectedRows = list.getSelectedRows();
final IListPanel listePanel = listHistoriquePanel.getListePanel(0);
if (selectedRows != null && !selectedRows.isEmpty()) {
final Set<Long> idsCalendarItemGroup = new HashSet<Long>();
final Set<Long> idsCalendarItemGroup = new HashSet<>();
for (SQLRowValues sqlRowValues : selectedRows) {
idsCalendarItemGroup.add(Long.valueOf(sqlRowValues.getForeign("ID_CALENDAR_ITEM_GROUP").getID()));
}
87,7 → 87,7
 
select.setWhere(where);
 
final SwingWorker2<Boolean, String> w = new SwingWorker2<Boolean, String>() {
final SwingWorker<Boolean, String> w = new SwingWorker<Boolean, String>() {
 
@Override
protected Boolean doInBackground() throws Exception {
96,6 → 96,7
return l.isEmpty();
}
 
@Override
protected void done() {
Boolean b;
try {
108,7 → 109,7
e.printStackTrace();
}
 
};
}
};
w.execute();
 
/trunk/Modules/Module Badge/.classpath
1,7 → 1,7
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadSQLElement.java
29,6 → 29,8
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.users.User;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.EditPanelListener;
99,21 → 101,19
 
super._initTableSource(source);
 
User user = UserManager.getInstance().getCurrentUser();
if (!user.getRights().haveRight(LeadSQLElement.CODE_NOT_RESTRICT)) {
SQLRow row = Configuration.getInstance().getRoot().findTable("USER_COMMON").getRow(UserManager.getInstance().getCurrentUser().getId());
List<SQLRow> rows = row.getReferentRows(Configuration.getInstance().getRoot().findTable("COMMERCIAL").getField("ID_USER_COMMON"));
if (!UserRightsManager.getCurrentUserRights().haveRight(LeadSQLElement.CODE_NOT_RESTRICT)) {
final SQLRow row = Configuration.getInstance().getRoot().findTable("USER_COMMON").getRow(UserManager.getInstance().getCurrentUser().getId());
final List<SQLRow> rows = row.getReferentRows(Configuration.getInstance().getRoot().findTable("COMMERCIAL").getField("ID_USER_COMMON"));
final List<Integer> listComm = new ArrayList<Integer>();
for (SQLRow sqlRow : rows) {
listComm.add(sqlRow.getID());
}
if (listComm != null && listComm.size() > 0) {
if (!listComm.isEmpty()) {
source.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
 
SQLField field = input.getTable(Module.TABLE_LEAD).getField("ID_COMMERCIAL");
final SQLField field = input.getTable(Module.TABLE_LEAD).getField("ID_COMMERCIAL");
Where w = new Where(field, listComm);
w = w.or(new Where(field, "IS", (Object) null));
w = w.or(new Where(field, "=", getTable().getTable("COMMERCIAL").getUndefinedID()));
128,9 → 128,8
 
@Override
protected Object show_(SQLRowAccessor r) {
SQLRowAccessor rAdr = r.getForeign("ID_ADRESSE");
final SQLRowAccessor rAdr = r.getForeign("ID_ADRESSE");
if (rAdr != null && !rAdr.isUndefined()) {
 
return rAdr.getString("RUE");
}
return "";
265,7 → 264,6
try {
rowVals.commit();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadGroup.java
2,6 → 2,7
 
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.sql.users.rights.UserRightsManager;
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
48,12 → 49,12
gState.addItem("STATUS");
gState.addItem("ID_COMMERCIAL");
gState.addItem("REMIND_DATE");
UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
UserRights rights = UserRightsManager.getCurrentUserRights();
if (rights.haveRight("CLIENT_PROSPECT")) {
gState.addItem("ID_CLIENT");
}
gState.addItem("DISPO");
 
this.add(gState);
 
}
/trunk/Modules/Module Google API/.classpath
1,7 → 1,6
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry exported="true" kind="lib" path="lib/gdata-analytics-2.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/gdata-analytics-meta-2.1.jar"/>
48,5 → 47,6
<classpathentry exported="true" kind="lib" path="lib/gdata-youtube-meta-2.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/guava-10.0.1.jar"/>
<classpathentry exported="true" kind="lib" path="lib/mail.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Expense/src/org/openconcerto/modules/humanresources/travel/expense/Module.java
54,6 → 54,7
GlobalMapper.getInstance().map(ExpenseStateSQLElement.ELEMENT_CODE + ".default", new ExpenseStateGroup());
dir.addSQLElement(new ExpenseSQLElement());
dir.addSQLElement(new ExpenseStateSQLElement());
dir.getShowAs().show(Module.TABLE_EXPENSE_STATE, "NAME");
}
 
@Override
/trunk/Modules/Module Batch Processing/src/org/openconcerto/modules/common/batchprocessing/BatchEditorPanel.java
22,6 → 22,7
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.PropsConfiguration;
32,7 → 33,6
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.ReloadPanel;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.SwingWorker2;
 
public class BatchEditorPanel extends JPanel {
 
43,7 → 43,7
List<SQLField> f = new ArrayList<SQLField>();
for (SQLField sqlField : fields) {
if (ForbiddenFieldName.isAllowed(sqlField.getName()) && translator.getLabelFor(sqlField) != null) {
if (filter == null || (filter != null && !filter.isFiltered(sqlField))) {
if (filter == null || !filter.isFiltered(sqlField)) {
f.add(sqlField);
}
}
60,12 → 60,12
GridBagConstraints c = new DefaultGridBagConstraints();
this.add(new JLabel("Champ"), c);
 
final JComboBox combo = new JComboBox(f.toArray());
final JComboBox<SQLField> combo = new JComboBox<SQLField>(f.toArray(new SQLField[1]));
combo.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
value = translator.getLabelFor(((SQLField) value));
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
String label = translator.getLabelFor(((SQLField) value));
return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus);
}
});
 
127,7 → 127,7
 
combo.setEnabled(false);
reload.setMode(ReloadPanel.MODE_ROTATE);
SwingWorker2<Object, Object> w = new SwingWorker2<Object, Object>() {
SwingWorker<Object, Object> w = new SwingWorker<Object, Object>() {
 
@Override
protected Object doInBackground() throws Exception {
/trunk/Modules/Module HTTP/.classpath
1,7 → 1,6
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry exported="true" kind="lib" path="lib/commons-codec-1.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.1.1.jar"/>
11,5 → 10,6
<classpathentry exported="true" kind="lib" path="lib/httpmime-4.1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/sardine.jar"/>
<classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.6.2.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Exchange Rates/src/org/openconcerto/modules/finance/accounting/exchangerates/Module.java
1,5 → 1,6
package org.openconcerto.modules.finance.accounting.exchangerates;
 
import java.awt.GraphicsEnvironment;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
130,7 → 131,9
}
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
if (!GraphicsEnvironment.isHeadless()) {
JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
}
}
}
 
178,7 → 181,12
if (this.commercialConverter != null) {
tauxCommercial = commercialConverter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
} else {
tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
try {
tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
} catch (IllegalStateException e) {
// Aucun taux n'existe encore dans la base.
tauxCommercial = null;
}
}
if (tauxCommercial == null) {
tauxCommercial = BigDecimal.ONE;
/trunk/Modules/Module OCR/src/org/openconcerto/modules/ocr/parser/OrangeInvoiceParser.java
1,7 → 1,6
package org.openconcerto.modules.ocr.parser;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/trunk/Modules/Module Axis SOAP/.classpath
1,11 → 1,11
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry exported="true" kind="lib" path="lib/axis-1.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-discovery-0.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/jaxrpc.jar"/>
<classpathentry exported="true" kind="lib" path="lib/wsdl4j-1.5.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Customer Support/module.properties
Nouveau fichier
0,0 → 1,6
# [\p{Alnum}_.]{3,}
id=org.openconcerto.modules.customersupport
# \p{Digit}(\.\p{Digit}+)?
version=1.0
contact=ILM Informatique
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/ModuleResources.properties
Nouveau fichier
0,0 → 1,2
name=Customer Ticket
description=Adds customer ticket support
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketListAction.java
Nouveau fichier
0,0 → 1,146
package org.openconcerto.modules.customersupport;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.utils.CollectionUtils;
 
public class CustomerSupportTicketListAction extends CreateFrameAbstractAction {
 
private SQLElement eltTicket = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET);
 
@Override
public JFrame createFrame() {
return new PanelFrame(getPanel(), "Liste des tickets de support");
}
 
public CustomerSupportTicketListAction() {
super("Liste des tickets de support");
}
 
@SuppressWarnings("unchecked")
public JPanel getPanel() {
 
JPanel panel = new JPanel(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.NONE;
 
JTabbedPane tabbedPane = new JTabbedPane();
 
// Tous
Map<IListe, SQLField> listeFilter = new HashMap<IListe, SQLField>();
ListeAddPanel panelAll = createPanel(null);
listeFilter.put(panelAll.getListe(), panelAll.getListe().getModel().getTable().getField("DATE"));
 
tabbedPane.add("Tous", panelAll);
 
// Sans statut
ListeAddPanel panelEmpty = createPanel("");
listeFilter.put(panelEmpty.getListe(), panelEmpty.getListe().getModel().getTable().getField("DATE"));
 
tabbedPane.add("Sans statut", panelEmpty);
 
SQLSelect selStatus = new SQLSelect();
selStatus.addSelect(this.eltTicket.getTable().getField("STATUS"));
selStatus.addGroupBy(this.eltTicket.getTable().getField("STATUS"));
selStatus.addFieldOrder(this.eltTicket.getTable().getField("STATUS"));
 
final List<String> listStatus = Configuration.getInstance().getBase().getDataSource().executeCol(selStatus.asString());
 
// Date panel
 
for (String status : listStatus) {
if (status != null && status.trim().length() > 0) {
ListeAddPanel p = createPanel(status);
listeFilter.put(p.getListe(), p.getListe().getModel().getTable().getField("DATE"));
tabbedPane.add(status, p);
}
}
 
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
panel.add(tabbedPane, c);
IListFilterDatePanel panelDate = new IListFilterDatePanel(listeFilter, IListFilterDatePanel.getDefaultMap());
 
c.gridy = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.weighty = 0;
c.gridy++;
panel.add(panelDate, c);
 
return panel;
}
 
private ListeAddPanel createPanel(String status) {
// Filter
final SQLTableModelSourceOnline source = this.eltTicket.getTableSource(true);
 
if (status != null) {
Where wAttente = new Where(this.eltTicket.getTable().getField("STATUS"), "=", status);
source.getReq().setWhere(wAttente);
}
 
// Filter
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
Calendar c = r.getDate("REMIND_DATE");
if (c == null) {
return null;
} else {
return c.getTime();
}
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(eltTicket.getTable());
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
}
};
 
dateRemind.setRenderer(new RemindDateRenderer());
source.getColumns().add(dateRemind);
 
final ListeAddPanel pane = new ListeAddPanel(this.eltTicket, new IListe(source), "Status" + status);
pane.getListe().setOpaque(false);
pane.setOpaque(false);
 
return pane;
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketSQLElement.java
Nouveau fichier
0,0 → 1,153
package org.openconcerto.modules.customersupport;
 
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
 
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.erp.core.common.ui.PanelFrame;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.IListFrame;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.ListMap;
 
public class CustomerSupportTicketSQLElement extends ModuleElement {
 
public CustomerSupportTicketSQLElement(final AbstractModule module) {
super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET);
this.setL18nLocation(CustomerSupportTicketSQLElement.class);
 
// Suivi
final RowAction.PredicateRowAction addSuiviAction = new RowAction.PredicateRowAction(new AbstractAction("Suivi du ticket") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
SuiviTicketPanel panel = new SuiviTicketPanel(sRow);
PanelFrame frame = new PanelFrame(panel, "Suivi ticket client");
frame.setSize(800, 600);
FrameUtil.show(frame);
}
}, true) {
};
addSuiviAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(addSuiviAction);
 
// Suivi
final RowAction.PredicateRowAction detailsAction = new RowAction.PredicateRowAction(new AbstractAction("Détails client") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
EditFrame frame = new EditFrame(getForeignElement("ID_CLIENT"), EditMode.READONLY);
frame.selectionId(sRow.getForeignID("ID_CLIENT"));
frame.pack();
FrameUtil.show(frame);
}
}, true) {
};
detailsAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(detailsAction);
 
// Histo
final RowAction.PredicateRowAction addHistoriqueAction = new RowAction.PredicateRowAction(new AbstractAction("Historique des interventions sur tickets") {
 
@Override
public void actionPerformed(ActionEvent e) {
final SQLElement elementHisto = getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
final ListeAddPanel panel = new ListeAddPanel(elementHisto);
IListFrame frame = new IListFrame(panel);
 
IListFilterDatePanel panelDate = new IListFilterDatePanel(panel.getListe(), elementHisto.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap());
GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.weighty = 0;
c.gridy++;
panel.add(panelDate, c);
FrameUtil.show(frame);
}
}, true) {
};
addHistoriqueAction.setPredicate(IListeEvent.createSelectionCountPredicate(0, Integer.MAX_VALUE));
getRowActions().add(addHistoriqueAction);
 
}
 
@Override
public Set<String> getReadOnlyFields() {
Set<String> s = new HashSet<String>();
s.add("NUMBER");
return s;
}
 
@Override
protected String createCode() {
return "customersupport.ticket";
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMBER");
l.add("DATE");
l.add("LABEL");
l.add("ID_CLIENT");
l.add("STATUS");
l.add("RATING");
l.add("INFOS");
l.add("CLOSED_AND_ARCHIVED");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("NUMBER");
l.add("DATE");
l.add("ID_CLIENT");
l.add("LABEL");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
ListMap<String, String> map = new ListMap<String, String>();
map.put(null, Arrays.asList("NUMBER", "DATE", "ID_CLIENT", "LABEL", "RATING", "STATUS"));
return map;
}
 
@Override
public SQLComponent createComponent() {
final String groupId = this.getCode() + ".default";
final Group group = GlobalMapper.getInstance().getGroup(groupId);
if (group == null) {
throw new IllegalStateException("No group found for id " + groupId);
}
return createComponent(group);
}
 
protected SQLComponent createComponent(final Group group) {
return new CustomerSupportTicketSQLComponent(this, group);
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/SQLElementNames_en.xml
Nouveau fichier
0,0 → 1,3
<translations>
<element refid="customersupportticket.ticket" name="support ticket" />
</translations>
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketListOpenPanel.java
Nouveau fichier
0,0 → 1,136
package org.openconcerto.modules.customersupport;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.sql.Date;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
 
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.CollectionUtils;
 
public class CustomerSupportTicketListOpenPanel {
 
private SQLElement eltTicket;
 
public CustomerSupportTicketListOpenPanel(SQLElement elt) {
this.eltTicket = elt;
}
 
@SuppressWarnings("unchecked")
public JPanel getPanel() {
 
JPanel panel = new JPanel(new GridBagLayout());
 
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.NONE;
 
JTabbedPane tabbedPane = new JTabbedPane();
 
// Tous
Map<IListe, SQLField> listeFilter = new HashMap<IListe, SQLField>();
ListeAddPanel panelAll = createPanel(null);
listeFilter.put(panelAll.getListe(), panelAll.getListe().getModel().getTable().getField("DATE"));
 
tabbedPane.add("Tous", panelAll);
 
// Sans statut
ListeAddPanel panelEmpty = createPanel("");
listeFilter.put(panelEmpty.getListe(), panelEmpty.getListe().getModel().getTable().getField("DATE"));
 
tabbedPane.add("Sans statut", panelEmpty);
 
SQLSelect selStatus = new SQLSelect();
selStatus.addSelect(this.eltTicket.getTable().getField("STATUS"));
selStatus.addGroupBy(this.eltTicket.getTable().getField("STATUS"));
selStatus.addFieldOrder(this.eltTicket.getTable().getField("STATUS"));
 
final List<String> listStatus = Configuration.getInstance().getBase().getDataSource().executeCol(selStatus.asString());
 
// Date panel
for (String status : listStatus) {
if (status != null && status.trim().length() > 0) {
ListeAddPanel p = createPanel(status);
listeFilter.put(p.getListe(), p.getListe().getModel().getTable().getField("DATE"));
tabbedPane.add(status, p);
}
}
 
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
panel.add(tabbedPane, c);
IListFilterDatePanel panelDate = new IListFilterDatePanel(listeFilter, IListFilterDatePanel.getDefaultMap());
 
c.gridy = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.weighty = 0;
c.gridy++;
panel.add(panelDate, c);
 
return panel;
}
 
private ListeAddPanel createPanel(String status) {
// Filter
final SQLTableModelSourceOnline source = this.eltTicket.getTableSource(true);
 
if (status != null) {
Where wAttente = new Where(this.eltTicket.getTable().getField("STATUS"), "=", status);
source.getReq().setWhere(wAttente);
}
 
// Filter
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
Calendar c = r.getDate("REMIND_DATE");
if (c == null) {
return null;
} else {
return c.getTime();
}
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(eltTicket.getTable());
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
}
};
 
dateRemind.setRenderer(new RemindDateRenderer());
source.getColumns().add(dateRemind);
 
final ListeAddPanel pane = new ListeAddPanel(this.eltTicket, new IListe(source), "Status" + status);
pane.getListe().setOpaque(false);
pane.setOpaque(false);
return pane;
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerTicketSupportHistoryGroup.java
Nouveau fichier
0,0 → 1,21
package org.openconcerto.modules.customersupport;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class CustomerTicketSupportHistoryGroup extends Group {
 
public CustomerTicketSupportHistoryGroup() {
super("customersupportticket.ticket.history");
final Group g = new Group("customersupportticket.ticket.history.identifier");
g.addItem("DATE");
g.addItem("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET, LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
g.addItem("ID_USER_COMMON", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gAddress = new Group("customersupportticket.ticket.history.content", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("INFORMATION", new LayoutHints(true, true, false, true, true, true));
this.add(gAddress);
 
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/RemindDateRenderer.java
Nouveau fichier
0,0 → 1,37
package org.openconcerto.modules.customersupport;
 
import java.awt.Color;
import java.awt.Component;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
 
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
 
import org.openconcerto.ui.table.TableCellRendererUtils;
 
public class RemindDateRenderer extends DefaultTableCellRenderer {
 
private static final Color COLOR_ORANGE = new Color(253, 173, 53);
private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
private final java.util.Date toDay = Calendar.getInstance().getTime();
 
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
final Component res = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
TableCellRendererUtils.setColors(res, table, isSelected);
if (value != null) {
final Date date = (Date) value;
String t = dateFormat.format(date);
((JLabel) res).setText(t);
if (toDay.after(date)) {
((JLabel) res).setBackground(COLOR_ORANGE);
}
}
return res;
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/SQLElementNames_fr.xml
Nouveau fichier
0,0 → 1,5
<translations>
<element refid="customersupport.ticket" nameClass="masculine" name="ticket de support" />
<element refid="customersupport.ticket.history" nameClass="feminine" name="Intervention sur ticket" />
 
</translations>
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/translation_fr.xml
Nouveau fichier
0,0 → 1,3
<translation lang="fr">
<item id="customersupportticket.ticket.history.content" label="Détails de l'intervention" />
</translation>
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketSQLComponent.java
Nouveau fichier
0,0 → 1,90
package org.openconcerto.modules.customersupport;
 
import java.sql.SQLException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
 
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.ui.JDateTime;
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.ExceptionHandler;
 
public class CustomerSupportTicketSQLComponent extends GroupSQLComponent {
public CustomerSupportTicketSQLComponent(SQLElement element, Group group) {
super(element, group);
}
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>(1);
s.add("ID_CLIENT");
s.add("ID_USER_COMMON");
s.add("LABEL");
s.add("DATE");
s.add("STATUS");
return s;
}
 
@Override
public int insert(SQLRow order) {
 
int id = super.insert(order);
SQLRow row = getTable().getRow(id);
try {
final SQLRowValues createEmptyUpdateRow = row.createEmptyUpdateRow();
createEmptyUpdateRow.put("NUMBER", id);
if (row.getObject("DATE") == null) {
createEmptyUpdateRow.put("DATE", new Date());
}
SQLRowValues rowValsHisto = new SQLRowValues(getTable().getTable(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY));
rowValsHisto.put("INFORMATION", "Ouverture du ticket");
rowValsHisto.put("DATE", row.getObject("DATE"));
rowValsHisto.put("ID_USER_COMMON", row.getForeignID("ID_USER_COMMON"));
rowValsHisto.put("ID_" + getTable().getName(), createEmptyUpdateRow);
createEmptyUpdateRow.commit();
} catch (SQLException e) {
ExceptionHandler.handle("Impossible d'affecter un numéro sur le ticket", e);
}
return id;
}
 
@Override
public JComponent createEditor(String id) {
 
if (id.equals("INFOS")) {
final ITextArea jTextArea = new ITextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setRows(3);
return jTextArea;
} else if (id.equals("TYPE") || id.equals("STATUS") || id.equals("RATING")) {
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
} else if (id.equals("DATE")) {
return new JDateTime(true);
}
return super.createEditor(id);
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("STATUS", "Nouveau");
rowVals.put("RATING", "Normale");
 
final int idUser = UserManager.getInstance().getCurrentUser().getId();
rowVals.put("ID_USER_COMMON", idUser);
 
return rowVals;
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/labels_fr.xml
Nouveau fichier
0,0 → 1,22
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="CUSTOMER_SUPPORT_TICKET">
<FIELD name="STATUS" label="Status" />
<FIELD name="LABEL" label="Libellé" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="NUMBER" label="Numéro" />
<FIELD name="ID_USER_COMMON" label="Assigné à" />
<FIELD name="INFOS" label="Détails du ticket" />
<FIELD name="RATING" label="Priorité" />
<FIELD name="TYPE" label="Type" />
<FIELD name="REMIND_DATE" label="Prochain rappel le" />
<FIELD name="DATE" label="Date" />
<FIELD name="CLOSED_AND_ARCHIVED" label="Archivé" />
</TABLE>
<TABLE name="CUSTOMER_SUPPORT_TICKET_HISTORY">
<FIELD name="ID_CUSTOMER_SUPPORT_TICKET" label="Ticket" />
<FIELD name="ID_USER_COMMON" label="Utilisateur en charge" />
<FIELD name="INFORMATION" label="Détails de l'intervention" />
<FIELD name="DATE" label="Date" />
</TABLE>
</ROOT>
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketHistoryListAction.java
Nouveau fichier
0,0 → 1,42
package org.openconcerto.modules.customersupport;
 
import java.awt.GridBagConstraints;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.core.common.ui.IListFilterDatePanel;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.PanelFrame;
 
public class CustomerSupportTicketHistoryListAction extends CreateFrameAbstractAction {
 
@Override
public JFrame createFrame() {
return new PanelFrame(getPanel(), "Historique des tickets de support");
}
 
public CustomerSupportTicketHistoryListAction() {
super("Historique des tickets de support");
}
 
public JPanel getPanel() {
final SQLElement eltTicket = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
final ListeAddPanel panel = new ListeAddPanel(eltTicket);
final IListFilterDatePanel panelDate = new IListFilterDatePanel(panel.getListe(), eltTicket.getTable().getField("DATE"), IListFilterDatePanel.getDefaultMap());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.gridy = 1;
c.gridwidth = GridBagConstraints.REMAINDER;
c.weightx = 1;
c.weighty = 0;
c.gridy++;
panel.add(panelDate, c);
 
return panel;
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerSupportTicketGroup.java
Nouveau fichier
0,0 → 1,33
package org.openconcerto.modules.customersupport;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class CustomerSupportTicketGroup extends Group {
 
public CustomerSupportTicketGroup() {
super("customersupportticket.ticket.default");
final Group g = new Group("customersupportticket.ticket.identifier");
g.addItem("NUMBER");
g.addItem("DATE");
g.addItem("ID_CLIENT", new LayoutHints(true, false, true, true, false, false));
g.addItem("LABEL", new LayoutHints(true, false, true, true, true, false));
g.addItem("ID_USER_COMMON", new LayoutHints(true, false, true, true, false, false));
this.add(g);
 
final Group gInfos = new Group("customersupportticket.ticket.info");
gInfos.addItem("INFOS", new LayoutHints(true, true, true, true, true, true, true));
this.add(gInfos);
 
final Group gState = new Group("customerrelationship.lead.state");
gState.addItem("RATING");
gState.addItem("TYPE");
gState.addItem("STATUS");
gState.addItem("REMIND_DATE");
gState.addItem("CLOSED_AND_ARCHIVED");
 
this.add(gState);
 
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/CustomerTicketHistorySQLElement.java
Nouveau fichier
0,0 → 1,110
package org.openconcerto.modules.customersupport;
 
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.core.edm.AttachmentAction;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.ui.JDateTime;
 
public class CustomerTicketHistorySQLElement extends ModuleElement {
 
public CustomerTicketHistorySQLElement(AbstractModule module) {
super(module, Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
this.setL18nLocation(CustomerTicketHistorySQLElement.class);
PredicateRowAction actionAttachment = new PredicateRowAction(new AttachmentAction().getAction(), true);
actionAttachment.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(actionAttachment);
}
 
@Override
protected String createCode() {
return "customersupport.ticket.history";
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_USER_COMMON");
l.add("DATE");
l.add("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET);
l.add("INFORMATION");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("INFORMATION");
return l;
}
 
@Override
protected String getParentFFName() {
return "ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET;
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponent(this, new CustomerTicketSupportHistoryGroup()) {
 
@Override
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>(1);
s.add("ID_USER_COMMON");
s.add("DATE");
return s;
}
 
// @Override
// public JComponent getLabel(String id) {
// if (id.equals("customerrelationship.lead.call.content")) {
// return new JLabelBold("Description de l'appel téléphonique");
// } else if (id.equals("customerrelationship.lead.call.next")) {
// return new JLabelBold("Suite à donner");
// }
// return super.getLabel(id);
// }
 
@Override
public JComponent createEditor(String id) {
if (id.equals("INFORMATION")) {
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 150));
jTextArea.setPreferredSize(new Dimension(200, 150));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDateTime(true);
}
return super.createEditor(id);
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
final int idUser = UserManager.getInstance().getCurrentUser().getId();
rowVals.put("ID_USER_COMMON", idUser);
return rowVals;
}
 
};
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/HistoryPanel.java
Nouveau fichier
0,0 → 1,93
package org.openconcerto.modules.customersupport;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
 
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
 
import org.openconcerto.erp.core.edm.AttachmentPanel;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.PanelFrame;
import org.openconcerto.ui.component.ITextArea;
 
public class HistoryPanel extends JPanel {
HistoryPanel(final SQLRowAccessor sqlRowAccessor, final SuiviTicketPanel panelSource) {
 
final SQLRowAccessor foreignUser = sqlRowAccessor.getForeign("ID_USER_COMMON");
final Date date = sqlRowAccessor.getDate("DATE") == null ? new Date() : sqlRowAccessor.getDate("DATE").getTime();
String user = foreignUser.getString("PRENOM") + " " + foreignUser.getString("NOM");
String info = sqlRowAccessor.getString("INFORMATION");
 
this.setOpaque(true);
this.setBackground(Color.WHITE);
this.setLayout(new GridBagLayout());
this.setBorder(BorderFactory.createLineBorder(Color.GRAY));
 
final GridBagConstraints c = new DefaultGridBagConstraints();
final DateFormat format = new SimpleDateFormat("dd/MM/yy HH:mm");
JLabel l1 = new JLabelBold("Le " + format.format(date) + ", créé par " + user);
this.add(l1, c);
String files = "Fichiers liés";
if (sqlRowAccessor.getInt("ATTACHMENTS") > 0) {
files += " (" + sqlRowAccessor.getInt("ATTACHMENTS") + ")";
}
final JButton button = new JButton(files);
button.setOpaque(false);
button.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
AttachmentPanel panel = new AttachmentPanel(sqlRowAccessor);
panel.addListener(new ListDataListener() {
 
@Override
public void intervalRemoved(ListDataEvent e) {
panelSource.fillPanelHistory();
}
 
@Override
public void intervalAdded(ListDataEvent e) {
panelSource.fillPanelHistory();
}
 
@Override
public void contentsChanged(ListDataEvent e) {
panelSource.fillPanelHistory();
}
});
 
PanelFrame frame = new PanelFrame(panel, "Liste des fichiers liés");
FrameUtil.show(frame);
 
}
});
c.gridx++;
c.anchor = GridBagConstraints.EAST;
this.add(button, c);
 
c.gridy++;
c.gridx = 0;
ITextArea text = new ITextArea(3, 50);
text.setEditable(false);
text.setEnabled(false);
text.setBorder(null);
text.setDisabledTextColor(Color.BLACK);
text.setText(info);
c.weightx = 1;
this.add(text, c);
}
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/ModuleResources_fr.properties
Nouveau fichier
0,0 → 1,2
name=Tickets supports clients
description=Gestion du support client
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/SuiviTicketPanel.java
Nouveau fichier
0,0 → 1,205
package org.openconcerto.modules.customersupport;
 
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowListRSH;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSelect.LockStrength;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.component.ITextArea;
 
public class SuiviTicketPanel extends JPanel {
 
private final SQLRowAccessor rowTicket;
private JPanel panelHistory = new JPanel(new GridBagLayout());
private DateFormat format = new SimpleDateFormat("dd/MM/yy HH:mm");
 
public SuiviTicketPanel(SQLRowAccessor rowTicket) {
super(new GridBagLayout());
this.rowTicket = rowTicket;
initUI();
}
 
public void initUI() {
GridBagConstraints c = new DefaultGridBagConstraints();
 
c.gridwidth = GridBagConstraints.REMAINDER;
 
JLabel label1 = new JLabel(
"Ticket N°" + this.rowTicket.getString("NUMBER") + " du " + format.format(this.rowTicket.getDate("DATE").getTime()) + " - Statut : " + this.rowTicket.getString("STATUS"));
JLabel label2 = new JLabel("Client : " + this.rowTicket.getForeign("ID_CLIENT").getString("NOM"));
String type = this.rowTicket.getString("TYPE");
if (type == null || type.trim().isEmpty()) {
type = "non renseigné";
}
JLabel label3 = new JLabel("Type : " + type + " - Intitulé : " + this.rowTicket.getString("LABEL"));
c.gridwidth = GridBagConstraints.REMAINDER;
this.add(label1, c);
c.gridy++;
this.add(label2, c);
c.gridy++;
this.add(label3, c);
 
final ITextArea textInfos = new ITextArea();
textInfos.setEditable(false);
textInfos.setEnabled(false);
textInfos.setBorder(null);
textInfos.setDisabledTextColor(Color.BLACK);
textInfos.setBackground(this.getBackground());
textInfos.setText(this.rowTicket.getString("INFOS"));
c.gridy++;
c.weightx = 1;
c.weighty = 0;
c.fill = GridBagConstraints.HORIZONTAL;
final JScrollPane comp = new JScrollPane(textInfos);
comp.setBorder(null);
DefaultGridBagConstraints.lockMinimumSize(comp);
this.add(comp, c);
 
final JLabelBold intSep = new JLabelBold("Liste des interventions");
c.gridwidth = GridBagConstraints.REMAINDER;
c.gridy++;
c.gridx = 0;
c.weightx = 1;
this.add(intSep, c);
 
c.gridy++;
c.weightx = 0;
c.weighty = 0;
c.fill = GridBagConstraints.NONE;
final JButton addSuivi = new JButton("Ajouter une intervention");
this.add(addSuivi, c);
addSuivi.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final SQLElement element = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
EditFrame frame = new EditFrame(element, EditMode.CREATION);
SQLRowValues rowVals = new SQLRowValues(element.getTable());
rowVals.put("DATE", new Date());
rowVals.put("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET, rowTicket.getID());
frame.getSQLComponent().select(rowVals);
FrameUtil.showPacked(frame);
 
frame.addEditPanelListener(new EditPanelListener() {
 
@Override
public void modified() {
}
 
@Override
public void inserted(int id) {
fillPanelHistory();
}
 
@Override
public void deleted() {
}
 
@Override
public void cancelled() {
}
});
}
});
 
// Historique
 
JScrollPane scrollPane = new JScrollPane(this.panelHistory);
scrollPane.setBorder(null);
fillPanelHistory();
c.gridy++;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1;
c.weighty = 1;
this.add(scrollPane, c);
 
JButton buttonClose = new JButton("Fermer");
c.gridy++;
c.fill = GridBagConstraints.NONE;
c.weightx = 0;
c.weighty = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.EAST;
this.add(buttonClose, c);
buttonClose.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = (JFrame) SwingUtilities.getRoot(SuiviTicketPanel.this);
frame.dispose();
}
});
}
 
public void fillPanelHistory() {
 
this.panelHistory.removeAll();
 
GridBagConstraints cHistory = new DefaultGridBagConstraints();
cHistory.anchor = GridBagConstraints.NORTHWEST;
cHistory.insets = new Insets(4, 1, 4, 1);
final SQLSelect sel = new SQLSelect();
sel.addSelectStar(this.rowTicket.getTable().getTable(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY));
sel.setWhere(new Where(this.rowTicket.getTable().getTable(Module.TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY).getField("ID_" + Module.TABLE_CUSTOMER_SUPPORT_TICKET), "=", this.rowTicket.getID()));
sel.setLockStrength(LockStrength.UPDATE);
List<SQLRow> histoRows = SQLRowListRSH.execute(sel, false, false);
List<SQLRowAccessor> histoRowsOrder = new ArrayList<SQLRowAccessor>();
histoRowsOrder.addAll(histoRows);
Collections.sort(histoRowsOrder, new Comparator<SQLRowAccessor>() {
@Override
public int compare(SQLRowAccessor o1, SQLRowAccessor o2) {
return o2.getDate("DATE").compareTo(o1.getDate("DATE"));
}
});
 
for (SQLRowAccessor sqlRowAccessor : histoRowsOrder) {
HistoryPanel p = new HistoryPanel(sqlRowAccessor, this);
cHistory.gridy++;
cHistory.weightx = 1;
cHistory.weighty = 0;
cHistory.fill = GridBagConstraints.BOTH;
panelHistory.add(p, cHistory);
}
cHistory.gridy++;
cHistory.weightx = 1;
cHistory.weighty = 1;
JPanel spacer = new JPanel();
spacer.setOpaque(false);
panelHistory.add(spacer, cHistory);
this.panelHistory.updateUI();
this.panelHistory.revalidate();
this.panelHistory.repaint();
}
 
}
/trunk/Modules/Module Customer Support/src/org/openconcerto/modules/customersupport/Module.java
Nouveau fichier
0,0 → 1,188
package org.openconcerto.modules.customersupport;
 
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Set;
 
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.DBContext;
import org.openconcerto.erp.modules.MenuContext;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePackager;
import org.openconcerto.erp.modules.RuntimeModuleFactory;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLRequestLog;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.ui.ConnexionPanel;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.sql.view.ListeAddPanel;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.SQLTableModelSourceOnline;
import org.openconcerto.utils.CollectionUtils;
 
public final class Module extends AbstractModule {
 
public static final String TABLE_CUSTOMER_SUPPORT_TICKET = "CUSTOMER_SUPPORT_TICKET";
public static final String TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY = "CUSTOMER_SUPPORT_TICKET_HISTORY";
 
public Module(ModuleFactory f) throws IOException {
super(f);
}
 
@Override
protected void install(DBContext ctxt) {
super.install(ctxt);
// TODO use version to upgrade
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_SUPPORT_TICKET) == null) {
final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET);
 
createTable.addIntegerColumn("NUMBER", 0);
createTable.addVarCharColumn("LABEL", 256);
//
createTable.addForeignColumn("CLIENT");
createTable.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
//
createTable.addVarCharColumn("INFOS", 4096);
//
createTable.addVarCharColumn("RATING", 200);
createTable.addVarCharColumn("TYPE", 128);
createTable.addVarCharColumn("STATUS", 128);
createTable.addDateAndTimeColumn("REMIND_DATE");
createTable.addDateAndTimeColumn("DATE");
createTable.addBooleanColumn("CLOSED_AND_ARCHIVED", Boolean.FALSE, false);
 
// Suivi
final SQLCreateTable createHistory = ctxt.getCreateTable(TABLE_CUSTOMER_SUPPORT_TICKET_HISTORY);
createHistory.addDateAndTimeColumn("DATE");
createHistory.addForeignColumn(createTable);
createHistory.addVarCharColumn("INFORMATION", 10240);
createHistory.addIntegerColumn("ATTACHMENTS", 0);
createHistory.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
 
// STATUT
// NOUVEAU, OUVERT, FERME, REJETE, EN COURS
try {
List<String> status = Arrays.asList("En cours", "Fermé", "Nouveau", "Ouvert", "Rejeté");
for (String s : status) {
 
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".STATUS");
rowVals.put("LABEL", s);
rowVals.insert(true, false);
}
 
List<String> prio = Arrays.asList("Basse", "Normale", "Haute");
for (String p : prio) {
 
SQLRowValues rowVals = new SQLRowValues(ctxt.getRoot().getTable("COMPLETION"));
rowVals.put("CHAMP", TABLE_CUSTOMER_SUPPORT_TICKET + ".RATING");
rowVals.put("LABEL", p);
rowVals.insert(true, false);
}
 
} catch (SQLException e) {
throw new IllegalStateException("erreur lors de l'ajout des status", e);
}
}
}
 
@Override
protected void setupElements(final SQLElementDirectory dir) {
super.setupElements(dir);
final CustomerSupportTicketSQLElement element = new CustomerSupportTicketSQLElement(this);
GlobalMapper.getInstance().map(element.getCode() + ".default", new CustomerSupportTicketGroup());
dir.addSQLElement(element);
dir.addSQLElement(new CustomerTicketHistorySQLElement(this));
}
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
// nothing
}
 
@Override
protected void setupMenu(final MenuContext ctxt) {
ctxt.addMenuItem(new CustomerSupportTicketListAction(), MainFrame.LIST_MENU);
ctxt.addMenuItem(new CustomerSupportTicketHistoryListAction(), MainFrame.LIST_MENU);
}
 
@Override
protected void start() {
 
final SQLElement elt = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_SUPPORT_TICKET);
// Filter
final SQLTableModelSourceOnline source = elt.getTableSource(true);
source.getColumns().remove(source.getColumn(elt.getTable().getField("CLOSED_AND_ARCHIVED")));
Where wAttente = new Where(elt.getTable().getField("CLOSED_AND_ARCHIVED"), "=", Boolean.FALSE);
source.getReq().setWhere(wAttente);
 
// Filter
BaseSQLTableModelColumn dateRemind = new BaseSQLTableModelColumn("Date de rappel", Date.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
Calendar c = r.getDate("REMIND_DATE");
if (c == null) {
return null;
} else {
return new Date(c.getTime().getTime());
}
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(elt.getTable());
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
}
};
 
dateRemind.setRenderer(new RemindDateRenderer());
source.getColumns().add(dateRemind);
 
final ListeAddPanel pane = new ListeAddPanel(elt, new IListe(source), "Open");
pane.getListe().setOpaque(false);
pane.setOpaque(false);
MainFrame.getInstance().getTabbedPane().addTab("Ticket support ouvert", pane);
 
}
 
@Override
protected void stop() {
// nothing to stop
}
 
public static void main(String[] args) throws IOException {
System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
final File propsFile = new File("module.properties");
System.out.println(propsFile.getAbsolutePath());
final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
SQLRequestLog.setEnabled(true);
SQLRequestLog.showFrame();
// uncomment to create and use the jar
final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
ModuleManager.getInstance().addFactoryAndStart(factory, false);
Gestion.main(args);
}
 
}