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 139 → Révision 140

/trunk/Modules/Module Label/.classpath
Nouveau fichier
0,0 → 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"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenConcerto"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/trunk/Modules/Module Label/module.properties
Nouveau fichier
0,0 → 1,6
# [\p{Alnum}_.]{3,}
id=org.openconcerto.modules.label
entryPoint=ModuleLabel
# \p{Digit}(\.\p{Digit}+)?
version=1.0
contact=ILM Informatique
/trunk/Modules/Module Label/.project
Nouveau fichier
0,0 → 1,17
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Module Label</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/SQLElementNames_en.xml
Nouveau fichier
0,0 → 1,2
<translations>
</translations>
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelPanel.java
Nouveau fichier
0,0 → 1,191
package org.openconcerto.modules.label;
 
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.util.List;
 
import javax.swing.JPanel;
 
import org.openconcerto.sql.model.SQLRowAccessor;
 
public class LabelPanel extends JPanel implements Printable {
 
private List<? extends SQLRowAccessor> list;
private int lines;
private int columns;
private Boolean[][] mask;
private final Color VERY_LIGHT_GRAY = new Color(230, 230, 230);
private LabelRenderer renderer;
private boolean ignoreMargins = false;
private int topMargin;
private int leftMargin;
 
public LabelPanel(List<? extends SQLRowAccessor> list, int l, int c, LabelRenderer labelRenderer) {
this.list = list;
this.renderer = labelRenderer;
setSizeLayoutSize(l, c);
this.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int w = getWidth() / columns;
int h = getHeight() / lines;
int j = e.getX() / w;
int i = e.getY() / h;
if (i >= 0 && i < lines && j >= 0 && j < columns) {
mask[i][j] = !mask[i][j];
}
repaint();
}
});
}
 
private void setSizeLayoutSize(int l, int c) {
this.lines = l;
this.columns = c;
this.mask = new Boolean[l][c];
for (int i = 0; i < l; i++) {
for (int j = 0; j < c; j++) {
this.mask[i][j] = Boolean.FALSE;
}
}
}
 
public void setIgnoreMargins(boolean ignoreMargins) {
this.ignoreMargins = ignoreMargins;
}
 
@Override
public void paint(Graphics g) {
g.setColor(Color.WHITE);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
 
int w = (this.getWidth() - leftMargin * 2) / this.columns;
int h = (this.getHeight() - topMargin * 2) / this.lines;
 
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
float dash1[] = { 10.0f };
BasicStroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
BasicStroke n = new BasicStroke(1.0f);
int rowIndex = 0;
 
for (int i = 0; i < this.lines; i++) {
for (int j = 0; j < this.columns; j++) {
boolean mask = this.mask[i][j];
final int x = j * w + leftMargin;
final int y = i * h + topMargin;
if (mask) {
// Disabled
g.setColor(VERY_LIGHT_GRAY);
g.fillRect(x, y, w, h);
// Dashed borders
g.setColor(Color.GRAY);
g2.setStroke(dashed);
g.drawRect(x, y, w, h);
 
} else {
// Dashed borders
g.setColor(Color.WHITE);
g2.setStroke(n);
g.drawRect(x, y, w, h);
g.setColor(Color.GRAY);
g2.setStroke(dashed);
g.drawRect(x, y, w, h);
// Label
if (rowIndex < list.size()) {
SQLRowAccessor row = list.get(rowIndex);
renderer.paintLabel(g, row, x, y, w, h, 10f);
}
rowIndex++;
}
 
}
}
 
}
 
@Override
public Dimension getPreferredSize() {
return new Dimension(210 * 3, 297 * 3);
}
 
public void setLineCount(int l) {
setSizeLayoutSize(l, this.columns);
repaint();
}
 
public void setColumnCount(int c) {
setSizeLayoutSize(this.lines, c);
repaint();
}
 
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
int nbLabelPerPage = 0;
for (int i = 0; i < this.lines; i++) {
for (int j = 0; j < this.columns; j++) {
boolean mask = this.mask[i][j];
if (!mask) {
nbLabelPerPage++;
}
}
}
if (nbLabelPerPage < 1) {
return NO_SUCH_PAGE;
}
int labelCount = this.list.size();
if (nbLabelPerPage * pageIndex > labelCount) {
return NO_SUCH_PAGE;
}
 
int imageableWidth = (int) pageFormat.getImageableWidth();
int imageableHeight = (int) pageFormat.getImageableHeight();
int imageableX = (int) pageFormat.getImageableX();
int imageableY = (int) pageFormat.getImageableY();
if (ignoreMargins) {
imageableWidth = (int) pageFormat.getWidth();
imageableHeight = (int) pageFormat.getHeight();
imageableX = 0;
imageableY = 0;
}
 
int w = (imageableWidth - 2 * leftMargin) / this.columns;
int h = (imageableHeight - 2 * topMargin) / this.lines;
// Margins
imageableX += leftMargin;
imageableY += topMargin;
// print labels
int rowIndex = pageIndex * nbLabelPerPage;
for (int i = 0; i < this.lines; i++) {
for (int j = 0; j < this.columns; j++) {
boolean mask = this.mask[i][j];
if (!mask && rowIndex < list.size()) {
SQLRowAccessor row = list.get(rowIndex);
renderer.paintLabel(g, row, j * w + imageableX, i * h + imageableY, w, h, 10f);
}
rowIndex++;
}
 
}
return PAGE_EXISTS;
}
 
public void setTopMargin(int margin) {
this.topMargin = margin;
repaint();
}
 
public void setLeftMargin(int margin) {
this.leftMargin = margin;
repaint();
}
}
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ModuleResources_fr.properties
Nouveau fichier
0,0 → 1,2
name=Etiquettes de produits
description=Impression des étiquettes des articles
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/SQLElementNames_fr.xml
Nouveau fichier
0,0 → 1,2
<translations>
</translations>
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/labels_en.xml
Nouveau fichier
0,0 → 1,2
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT />
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ModuleLabel.java
Nouveau fichier
0,0 → 1,188
package org.openconcerto.modules.label;
 
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.util.List;
 
import javax.swing.AbstractAction;
import javax.swing.SwingWorker;
 
import org.openconcerto.erp.generationDoc.provider.AdresseFullClientValueProvider;
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ComponentsContext;
import org.openconcerto.erp.modules.ModuleFactory;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.list.IListe;
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
import org.openconcerto.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.GestionDevise;
import org.openconcerto.utils.StringUtils;
 
public final class ModuleLabel extends AbstractModule {
 
public ModuleLabel(ModuleFactory f) throws IOException {
super(f);
}
 
@Override
protected void setupComponents(ComponentsContext ctxt) {
final String actionName = "Imprimer les étiquettes";
final PredicateRowAction aArticle = new PredicateRowAction(new AbstractAction(actionName) {
 
@Override
public void actionPerformed(ActionEvent arg0) {
final IListe list = IListe.get(arg0);
final List<Integer> selectedIDs = list.getSelection().getSelectedIDs();
final SwingWorker<List<SQLRowValues>, String> wworker = new SwingWorker<List<SQLRowValues>, String>() {
 
@Override
protected List<SQLRowValues> doInBackground() throws Exception {
final SQLTable tArticle = list.getSelectedRows().get(0).getTable();
final SQLRowValues graph = new SQLRowValues(tArticle);
graph.putNulls("NOM", "PV_TTC");
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(graph);
final List<SQLRowValues> values = fetcher.fetch(new Where(tArticle.getKey(), selectedIDs));
return values;
}
 
protected void done() {
try {
final List<SQLRowValues> values = get();
 
final LabelFrame f = new LabelFrame(values, new LabelRenderer() {
 
@Override
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize) {
g.setColor(Color.BLACK);
g.setFont(g.getFont().deriveFont(fontSize));
// Labels borders
final int hBorder = 12;
final int vBorder = 8;
// Product name
final String text = row.getString("NOM");
final List<String> l = StringUtils.wrap(text, g.getFontMetrics(), gridWith - 2 * hBorder);
final int lineHeight = g.getFontMetrics().getHeight();
int lineY = y;
final int margin = gridHeight - l.size() * lineHeight;
if (margin > 0) {
lineY += (int) (margin / 2);
}
for (String line : l) {
g.drawString(line, x + hBorder, lineY);
lineY += lineHeight;
}
// Price
g.setFont(g.getFont().deriveFont(fontSize + 2));
final String price = GestionDevise.currencyToString(row.getBigDecimal("PV_TTC")) + " € TTC";
final Rectangle2D r2 = g.getFont().getStringBounds(price, g.getFontMetrics().getFontRenderContext());
g.drawString(price, x + (int) (gridWith - hBorder - r2.getWidth()), y + gridHeight - vBorder);
 
}
});
f.setTitle(actionName);
f.setLocationRelativeTo(null);
f.pack();
f.setResizable(false);
f.setVisible(true);
} catch (Exception e) {
ExceptionHandler.handle("Erreur d'impression", e);
}
};
};
wworker.execute();
 
}
}, true, false);
final PredicateRowAction aClient = new PredicateRowAction(new AbstractAction(actionName) {
 
@Override
public void actionPerformed(ActionEvent arg0) {
final IListe list = IListe.get(arg0);
final List<Integer> selectedIDs = list.getSelection().getSelectedIDs();
final SwingWorker<List<SQLRowValues>, String> wworker = new SwingWorker<List<SQLRowValues>, String>() {
 
@Override
protected List<SQLRowValues> doInBackground() throws Exception {
final SQLTable tClient = list.getSelectedRows().get(0).getTable();
final SQLRowValues graph = new SQLRowValues(tClient);
graph.putNulls("NOM");
final SQLRowValues a1 = graph.putRowValues("ID_ADRESSE");
a1.putNulls(a1.getTable().getFieldsName());
final SQLRowValues a2 = graph.putRowValues("ID_ADRESSE_L");
a2.putNulls(a2.getTable().getFieldsName());
final SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(graph);
final List<SQLRowValues> values = fetcher.fetch(new Where(tClient.getKey(), selectedIDs));
return values;
}
 
protected void done() {
try {
final List<SQLRowValues> values = get();
final LabelFrame f = new LabelFrame(values, new LabelRenderer() {
 
@Override
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize) {
SQLRowAccessor rAddr = row.getForeign("ID_ADRESSE_L");
if (rAddr == null || rAddr.isUndefined()) {
rAddr = row.getForeign("ID_ADRESSE");
}
if (rAddr == null || rAddr.isUndefined()) {
return;
}
 
String text = AdresseFullClientValueProvider.getFormattedAddress(rAddr, row.getString("NOM") + "\n");
 
// Default font at 10pt black
g.setColor(Color.BLACK);
g.setFont(g.getFont().deriveFont(fontSize));
// Labels borders
final int hBorder = 12;
// Product name
final List<String> l = StringUtils.wrap(text, g.getFontMetrics(), gridWith - 2 * hBorder);
final int lineHeight = g.getFontMetrics().getHeight();
int lineY = y + lineHeight + 4;
for (String line : l) {
g.drawString(line, x + hBorder, lineY);
lineY += lineHeight;
}
 
}
});
f.setTitle(actionName);
f.setLocationRelativeTo(null);
f.pack();
f.setResizable(false);
f.setVisible(true);
 
} catch (Exception e) {
ExceptionHandler.handle("Erreur d'impression", e);
}
};
};
wworker.execute();
 
}
}, true, false);
 
aArticle.setPredicate(IListeEvent.createSelectionCountPredicate(1, Integer.MAX_VALUE));
aClient.setPredicate(IListeEvent.createSelectionCountPredicate(1, Integer.MAX_VALUE));
ctxt.getElement("ARTICLE").getRowActions().add(aArticle);
ctxt.getElement("CLIENT").getRowActions().add(aClient);
}
 
@Override
protected void start() {
}
 
@Override
protected void stop() {
}
}
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelRenderer.java
Nouveau fichier
0,0 → 1,9
package org.openconcerto.modules.label;
 
import java.awt.Graphics;
 
import org.openconcerto.sql.model.SQLRowAccessor;
 
public interface LabelRenderer {
public void paintLabel(Graphics g, SQLRowAccessor row, int x, int y, int gridWith, int gridHeight, float fontSize);
}
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/labels_fr.xml
Nouveau fichier
0,0 → 1,2
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT />
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/LabelFrame.java
Nouveau fichier
0,0 → 1,166
package org.openconcerto.modules.label;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.util.List;
 
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.ui.DefaultGridBagConstraints;
import org.openconcerto.utils.ExceptionHandler;
 
public class LabelFrame extends JFrame {
private static final boolean IGNORE_MARGINS = true;
private static final int DEFAULT_LINES = 10;
private static final int DEFAULT_COLS = 4;
final LabelPanel labelPanel;
 
public LabelFrame(List<? extends SQLRowAccessor> list, LabelRenderer labelRenderer) {
final JPanel p = new JPanel();
p.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
p.add(createToolBar(), c);
c.gridy++;
p.add(createToolBar2(), c);
c.gridy++;
c.insets = new Insets(0, 0, 0, 0);
p.add(new JSeparator(JSeparator.HORIZONTAL), c);
c.gridy++;
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
labelPanel = new LabelPanel(list, DEFAULT_LINES, DEFAULT_COLS, labelRenderer);
labelPanel.setIgnoreMargins(IGNORE_MARGINS);
p.add(labelPanel, c);
this.setContentPane(p);
}
 
public JPanel createToolBar() {
final JPanel toolbar = new JPanel();
toolbar.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
toolbar.add(new JLabel("Lignes"), c);
c.gridx++;
final JSpinner sLines = new JSpinner(new SpinnerNumberModel(DEFAULT_LINES, 1, 100, 1));
toolbar.add(sLines, c);
c.gridx++;
toolbar.add(new JLabel("Colonnes"), c);
c.gridx++;
final JSpinner sColums = new JSpinner(new SpinnerNumberModel(DEFAULT_COLS, 1, 50, 1));
toolbar.add(sColums, c);
c.gridx++;
final JCheckBox ck = new JCheckBox("Ignorer les marges de l'imprimante");
ck.setSelected(IGNORE_MARGINS);
 
toolbar.add(ck, c);
 
c.gridx++;
c.weightx = 1;
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.EAST;
final JButton printButton = new JButton("Imprimer");
toolbar.add(printButton, c);
c.gridx++;
 
sLines.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
Number n = (Number) sLines.getValue();
if (n != null) {
labelPanel.setLineCount(n.intValue());
}
}
});
sColums.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
Number n = (Number) sColums.getValue();
if (n != null) {
labelPanel.setColumnCount(n.intValue());
}
}
});
printButton.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
final PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(labelPanel);
boolean ok = job.printDialog();
if (ok) {
try {
job.print();
} catch (PrinterException ex) {
ExceptionHandler.handle("Print error", ex);
}
}
 
}
});
ck.addActionListener(new ActionListener() {
 
@Override
public void actionPerformed(ActionEvent e) {
labelPanel.setIgnoreMargins(ck.isSelected());
 
}
});
return toolbar;
}
 
public JPanel createToolBar2() {
final JPanel toolbar = new JPanel();
toolbar.setLayout(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
toolbar.add(new JLabel("Marge en haut (mm)"), c);
c.gridx++;
final JSpinner sLines = new JSpinner(new SpinnerNumberModel(0, 0, 200, 1));
toolbar.add(sLines, c);
c.gridx++;
toolbar.add(new JLabel("Marge à gauche (mm)"), c);
c.gridx++;
final JSpinner sColums = new JSpinner(new SpinnerNumberModel(0, 0, 200, 1));
toolbar.add(sColums, c);
c.gridx++;
 
sLines.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
Number n = (Number) sLines.getValue();
if (n != null) {
labelPanel.setTopMargin(n.intValue());
}
}
});
sColums.addChangeListener(new ChangeListener() {
 
@Override
public void stateChanged(ChangeEvent e) {
Number n = (Number) sColums.getValue();
if (n != null) {
labelPanel.setLeftMargin(n.intValue());
}
}
});
 
return toolbar;
}
}
/trunk/Modules/Module Label/src/org/openconcerto/modules/label/ModuleResources.properties
Nouveau fichier
0,0 → 1,2
name=Product Label
description=Print products labels
/trunk/Modules/Module OCR/src/org/openconcerto/modules/ocr/parser/ParserUtils.java
44,7 → 44,7
month = day;
day = swap;
}
if (month <= 12 && month > 0 && day <= 31 && day > 0 && year > 2000 && year < 4000) {
if (month < 12 && month >= 0 && day <= 31 && day > 0 && year > 2000 && year < 4000) {
c.set(Calendar.DAY_OF_MONTH, day);
c.set(Calendar.MONTH, month);
c.set(Calendar.YEAR, year);
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/openconcerto_catalog.xml~
Fichier supprimé
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/openconcerto_catalog.xml
2,8 → 2,7
<Schema name="OpenConcerto">
 
<Cube name="Ventes">
<Table name="SAISIE_VENTE_FACTURE_ELEMENT" schema="_SCHEMA_"/>
<Table name="SAISIE_VENTE_FACTURE_ELEMENT" schema="_SCHEMA_"/>
<Dimension name="Articles" foreignKey="ID_ARTICLE">
<Hierarchy hasAll="true" allMemberName="Tous les articles" primaryKey="ID">
<View alias="ARTICLE">
10,7 → 9,7
<SQL dialect="generic"> <![CDATA[select * from "_SCHEMA_"."ARTICLE" where "ARCHIVE" = '0']]>
</SQL>
</View>
<Level name="Désignation" column="NOM" uniqueMembers="true" />
<Level name="Designation" column="NOM" uniqueMembers="true" />
<Level name="Code produit" column="CODE" uniqueMembers="true" />
</Hierarchy>
</Dimension>
31,7 → 30,7
<SQL dialect="generic"> <![CDATA[select * from "_SCHEMA_"."SAISIE_VENTE_FACTURE" where "ARCHIVE" = '0']]>
</SQL>
</View>
<Level name="Année" column="DATE" uniqueMembers="true" levelType="TimeYears" type="Numeric">
<Level name="Annee" column="DATE" uniqueMembers="true" levelType="TimeYears" type="Numeric">
<KeyExpression>
<SQL dialect="generic">
<![CDATA[EXTRACT(YEAR FROM "SAISIE_VENTE_FACTURE"."DATE")]]>
49,18 → 48,18
</Level>
</Hierarchy>
</Dimension>
<Dimension name="Ligne facturées">
<Dimension name="Ligne facturees">
<Hierarchy hasAll="true" primaryKey="ID">
<Table name="SAISIE_VENTE_FACTURE_ELEMENT" schema="_SCHEMA_"/>
<Level name="Quantité" column="QTE" type="Numeric" uniqueMembers="false"/>
<Level name="Quantite" column="QTE" type="Numeric" uniqueMembers="false"/>
<Level name="Code article" column="CODE" type="String" uniqueMembers="false"/>
<Level name="Poids" column="POIDS" type="Numeric" uniqueMembers="false"/>
<Level name="Désignation" column="NOM" type="String" uniqueMembers="false"/>
<Level name="Designation" column="NOM" type="String" uniqueMembers="false"/>
</Hierarchy>
</Dimension>
<Measure name="Nombre vendu" column="ID_ARTICLE" aggregator="count" formatString="Standard" />
<Measure name="Quantité" column="QTE" aggregator="count" formatString="Standard" />
<Measure name="Quantite" column="QTE" aggregator="count" formatString="Standard" />
<Measure name="Prix de vente HT" column="T_PV_HT" aggregator="sum"
formatter="org.openconcerto.modules.reports.olap.formatter.CentsCellFormatter" />
<Measure name="Prix d'achat HT" column="T_PA_HT" aggregator="sum"
/trunk/Modules/Module OLAP/src/org/openconcerto/modules/reports/olap/OLAPPanel.java
32,7 → 32,7
this.removeAll();
this.invalidate();
try {
final File dir = new File(ComptaPropsConfiguration.getConfFile().getParent());
final File dir = new File(ComptaPropsConfiguration.getConfFile(ComptaPropsConfiguration.productInfo).getParent());
final File f = new File(dir, "openconcerto_catalog.xml");
String catalog = "empty";
if (f.exists()) {
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/RemindDateRenderer.java
Nouveau fichier
0,0 → 1,42
/*
* Créé le 14 févr. 2012
*/
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.Color;
import java.awt.Component;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
 
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 final Color couleurOrange = new Color(253, 173, 53);
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
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(couleurOrange);
}
}
return res;
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/SQLElementNames_fr.xml
1,3 → 1,22
<translations>
<element refid="customerrelationship.lead" nameClass="masculine" name="prospect" />
<element refid="org.openconcerto.modules.customerrelationship.lead/CUSTOMER_VISIT" nameClass="masculine"
name="rapport de visite client" namePlural="rapports de visite client" />
<element refid="org.openconcerto.modules.customerrelationship.lead/LEAD_VISIT" nameClass="masculine"
name="rapport de visite prospect" namePlural="rapports de visite prospect" />
<element refid="org.openconcerto.modules.customerrelationship.lead/CUSTOMER_CALL" nameClass="masculine"
name="rapport d'appel client" namePlural="rapports d'appel client" />
<element refid="org.openconcerto.modules.customerrelationship.lead/LEAD_CALL" nameClass="masculine"
name="rapport d'appel prospect" namePlural="rapports d'appel prospect" />
 
<element refid="org.openconcerto.modules.customerrelationship.lead/CUSTOMER_VISIT_SERVICE" nameClass="masculine"
name="service associé à un rapport de visite client" namePlural="services associés à des rapports de visite client" />
<element refid="org.openconcerto.modules.customerrelationship.lead/LEAD_VISIT_SERVICE" nameClass="masculine"
name="service associé à un rapport de visite prospect" namePlural="services associés à des rapports de visite prospect" />
<element refid="org.openconcerto.modules.customerrelationship.lead/CUSTOMER_CALL_SERVICE" nameClass="masculine"
name="service associé à un rapport d'appel client" namePlural="services associés à des rapports d'appel client" />
<element refid="org.openconcerto.modules.customerrelationship.lead/LEAD_CALL_SERVICE" nameClass="masculine"
name="service associé à un rapport d'appel prospect" namePlural="services associés à des rapports d'appel prospect" />
 
<element refid="org.openconcerto.modules.customerrelationship.lead/SERVICE" nameClass="masculine" name="service" />
</translations>
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadCustomerSQLInjector.java
Nouveau fichier
0,0 → 1,40
/*
* Créé le 5 nov. 2012
*/
package org.openconcerto.modules.customerrelationship.lead;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
 
public class LeadCustomerSQLInjector extends SQLInjector {
 
private final static SQLTable customerTable = Configuration.getInstance().getDirectory().getElement("CLIENT").getTable();
private static final SQLTable leadTable = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD).getTable();
 
public LeadCustomerSQLInjector() {
super(leadTable, customerTable, false);
createDefaultMap();
map(leadTable.getField("NAME"), customerTable.getField("RESPONSABLE"));
map(leadTable.getField("COMPANY"), customerTable.getField("NOM"));
map(leadTable.getField("PHONE"), customerTable.getField("TEL"));
map(leadTable.getField("MOBILE"), customerTable.getField("TEL_P"));
map(leadTable.getField("FAX"), customerTable.getField("FAX"));
map(leadTable.getField("EMAIL"), customerTable.getField("MAIL"));
map(leadTable.getField("MOBILE"), customerTable.getField("TEL_P"));
// map(leadTable.getField("INFORMATION"), customerTable.getField("INFOS"));
map(getSource().getField("INFOS"), getDestination().getField("INFOS"));
remove(leadTable.getField("ID_ADRESSE"), customerTable.getField("ID_ADRESSE"));
}
 
@Override
protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
// TODO Auto-generated method stub
super.merge(srcRow, rowVals);
if (rowVals.getString("NOM") == null || rowVals.getString("NOM").trim().length() == 0) {
rowVals.put("NOM", srcRow.getString("NAME"));
}
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/labels_fr.xml
1,8 → 1,13
<?xml version="1.0" encoding="UTF-8" ?>
<ROOT>
<TABLE name="LEAD">
<FIELD name="DISPO" label="Disponibilité" />
<FIELD name="REMIND_DATE" label="Date de rappel" />
<FIELD name="ROLE" label="Fonction" />
<FIELD name="LOCALISATION" label="Localisation" />
<FIELD name="INFOS" label="Informations complémentaires" />
<FIELD name="NAME" label="Nom" />
<FIELD name="NUMBER" label="Numéro" titlelabel="N°" />
<FIELD name="NAME" label="Nom" />
<FIELD name="DATE" label="Date" titlelabel="Date" />
<FIELD name="COMPANY" label="Entreprise" titlelabel="Entreprise" />
<FIELD name="FIRSTNAME" label="Prénom" titlelabel="Prénom" />
18,7 → 23,46
<FIELD name="EMPLOYEES" label="Nombre de salariés" titlelabel="Salariés" />
<FIELD name="RATING" label="Évaluation" titlelabel="Évaluation" />
<FIELD name="SOURCE" label="Origine du contact" titlelabel="Origine" />
<FIELD name="STATUS" label="Status" titlelabel="Status" />
<FIELD name="STATUS" label="Statut" titlelabel="Statut" />
<FIELD name="ID_COMMERCIAL" label="Assigné à" titlelabel="Assigné à" />
<FIELD name="ID_CLIENT" label="Client" titlelabel="Client" />
<FIELD name="ID_TITRE_PERSONNEL" label="Civilité" titlelabel="Civilité" />
</TABLE>
 
<TABLE name="DEVIS">
<FIELD name="REMIND_DATE" label="Date de rappel" />
</TABLE>
 
<TABLE name="LEAD_CALL">
<FIELD name="DATE" label="Date de l'appel" />
<FIELD name="ID_LEAD" label="Entreprise" />
<FIELD name="INFORMATION" label="Résumé de l'appel" />
<FIELD name="NEXTCONTACT_DATE" label="Date de prochain contact" />
<FIELD name="NEXTCONTACT_INFO" label="Motif de prochain contact" />
</TABLE>
<TABLE name="CUSTOMER_CALL">
<FIELD name="DATE" label="Date de l'appel" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="INFORMATION" label="Résumé de l'appel" />
<FIELD name="NEXTCONTACT_DATE" label="Date de prochain contact" />
<FIELD name="NEXTCONTACT_INFO" label="Motif de prochain contact" />
</TABLE>
<TABLE name="LEAD_VISIT">
<FIELD name="DATE" label="Date de visite" />
<FIELD name="ID_LEAD" label="Entreprise" />
<FIELD name="INFORMATION" label="Compte rendu de visite" />
<FIELD name="NEXTCONTACT_DATE" label="Date de prochain contact" />
<FIELD name="NEXTCONTACT_INFO" label="Motif de prochain contact" />
</TABLE>
<TABLE name="CUSTOMER_VISIT">
<FIELD name="DATE" label="Date de visite" />
<FIELD name="ID_CLIENT" label="Client" />
<FIELD name="INFORMATION" label="Compte rendu de visite" />
<FIELD name="NEXTCONTACT_DATE" label="Date de prochain contact" />
<FIELD name="NEXTCONTACT_INFO" label="Motif de prochain contact" />
</TABLE>
<TABLE name="SERVICE">
<FIELD name="NAME" label="Libellé" />
</TABLE>
 
</ROOT>
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/SuiviClientProspectListAction.java
Nouveau fichier
0,0 → 1,58
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.Arrays;
import java.util.List;
 
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
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 SuiviClientProspectListAction extends CreateFrameAbstractAction {
 
private SQLElement eltCustomerCall = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_CALL);
private SQLElement eltCustomerVisit = Configuration.getInstance().getDirectory().getElement(Module.TABLE_CUSTOMER_VISIT);
private SQLElement eltLeadCall = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD_CALL);
private SQLElement eltLeadVisit = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD_VISIT);
 
@Override
public JFrame createFrame() {
PanelFrame frame = new PanelFrame(getPanel(), "Suivi Prospects-Clients");
return frame;
}
 
public SuiviClientProspectListAction() {
super("Suivi Prospects-Clients");
}
 
public JPanel getPanel() {
final JPanel panel = new JPanel(new GridBagLayout());
final GridBagConstraints c = new DefaultGridBagConstraints();
c.fill = GridBagConstraints.NONE;
final JTabbedPane tabbedPane = new JTabbedPane();
final List<SQLElement> elts = Arrays.asList(this.eltLeadCall, this.eltCustomerCall, this.eltLeadVisit, this.eltCustomerVisit);
for (SQLElement sqlElement : elts) {
final ListeAddPanel pane = new ListeAddPanel(sqlElement);
pane.getListe().setOpaque(false);
pane.setOpaque(false);
tabbedPane.add(sqlElement.getPluralName(), pane);
}
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy++;
c.gridwidth = GridBagConstraints.REMAINDER;
panel.add(tabbedPane, c);
return panel;
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadSQLComponent.java
5,14 → 5,19
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLBackgroundTableCache;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.ui.component.ComboLockedMode;
import org.openconcerto.ui.component.ITextArea;
import org.openconcerto.ui.group.Group;
 
public class LeadSQLComponent extends GroupSQLComponent {
24,16 → 29,31
protected Set<String> createRequiredNames() {
final Set<String> s = new HashSet<String>(1);
s.add("ID_ADRESSE");
s.add("NOM");
return s;
}
 
@Override
public JComponent getLabel(String id) {
if (id.equals("customerrelationship.lead.person")) {
return new JLabelBold("Contact");
} else if (id.equals("customerrelationship.lead.contact")) {
return new JLabel();
} else if (id.equals("customerrelationship.lead.address")) {
return new JLabelBold("Adresse");
} else {
return super.getLabel(id);
}
}
 
@Override
public JComponent createEditor(String id) {
if (id.equals("INFORMATION")) {
final JTextArea jTextArea = new JTextArea();
 
if (id.equals("INFORMATION") || id.equals("INFOS")) {
final ITextArea jTextArea = new ITextArea();
jTextArea.setFont(new JLabel().getFont());
return new JScrollPane(jTextArea);
} else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE")) {
return jTextArea;
} else if (id.equals("INDUSTRY") || id.equals("STATUS") || id.equals("RATING") || id.equals("SOURCE") || id.equals("DISPO")) {
return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
} else if (id.equals("DATE")) {
return new JDate(true);
40,4 → 60,19
}
return super.createEditor(id);
}
 
@Override
protected SQLRowValues createDefaults() {
SQLRowValues rowVals = new SQLRowValues(getTable());
rowVals.put("STATUS", "Nouveau");
 
final int idUser = UserManager.getInstance().getCurrentUser().getId();
final SQLTable foreignTableComm = getTable().getForeignTable("ID_COMMERCIAL");
SQLRow rowsComm = SQLBackgroundTableCache.getInstance().getCacheForTable(foreignTableComm).getFirstRowContains(idUser, foreignTableComm.getField("ID_USER_COMMON"));
 
if (rowsComm != null) {
rowVals.put("ID_COMMERCIAL", rowsComm.getID());
}
return rowVals;
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/JoinServiceSQLElement.java
Nouveau fichier
0,0 → 1,38
package org.openconcerto.modules.customerrelationship.lead;
 
import java.util.ArrayList;
import java.util.List;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.SQLComponent;
 
public abstract class JoinServiceSQLElement extends ModuleElement {
 
private final String joinField;
 
protected JoinServiceSQLElement(AbstractModule module, final String joinTable) {
super(module, joinTable + "_SERVICE");
this.joinField = "ID_" + joinTable;
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add(this.joinField);
l.add("ID_SERVICE");
return l;
}
 
@Override
protected final void ffInited() {
super.ffInited();
this.setAction(this.joinField, ReferenceAction.CASCADE);
this.setAction("ID_SERVICE", ReferenceAction.CASCADE);
}
 
@Override
protected final SQLComponent createComponent() {
return null;
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/GroupSQLComponentWithService.java
Nouveau fichier
0,0 → 1,150
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.Dimension;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
 
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.view.QuickAssignPanel;
import org.openconcerto.sql.view.list.RowValuesTableModel;
import org.openconcerto.sql.view.list.SQLTableElement;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.cc.ITransformer;
 
public class GroupSQLComponentWithService extends GroupSQLComponent {
 
public GroupSQLComponentWithService(ModuleElement element, Group group) {
super(element, group);
}
 
@Override
public JComponent getLabel(String id) {
if (id.equals("ibd.services")) {
return new JLabel("Services proposés");
}
return super.getLabel(id);
}
 
@Override
public JComponent createEditor(String id) {
if (id.equals("ibd.services")) {
final SQLElement serviceElement = this.getElement().getDirectory().getElement(Module.TABLE_SERVICE);
final List<SQLTableElement> tableElements = new ArrayList<SQLTableElement>();
tableElements.add(new SQLTableElement(serviceElement.getTable().getField("NAME")));
final RowValuesTableModel model = new RowValuesTableModel(serviceElement, tableElements, serviceElement.getTable().getKey(), false);
QuickAssignPanel table = new QuickAssignPanel(serviceElement, "ID", model);
table.setMinimumSize(new Dimension(200, 150));
table.setPreferredSize(new Dimension(200, 150));
return table;
}
return super.createEditor(id);
}
 
QuickAssignPanel getQuickAssignPanel() {
return (QuickAssignPanel) getEditor("ibd.services");
}
 
@Override
public void select(final SQLRowAccessor row) {
final QuickAssignPanel panel = getQuickAssignPanel();
panel.getModel().clearRows();
if (row != null) {
final SQLTable associationTable = getServiceAssociationTable();
SQLRowValues graph = new SQLRowValues(associationTable);
graph.put("ID", null);
graph.putRowValues("ID_SERVICE").put("NAME", null);
final String tableName = this.getElement().getTable().getName();
SQLRowValuesListFetcher f = new SQLRowValuesListFetcher(graph);
f.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
@Override
public SQLSelect transformChecked(SQLSelect input) {
input.setWhere(new Where(associationTable.getField("ID_" + tableName), "=", row.getID()));
return input;
}
});
List<SQLRowValues> associations = f.fetch();
for (SQLRowValues r : associations) {
panel.getModel().addRow(r.getForeign("ID_SERVICE").asRowValues());
}
 
}
super.select(row);
}
 
@Override
public int insert(SQLRow order) {
int id = super.insert(order);
insertAssociatedServiceTo(id);
SQLRow row = getTable().getRow(id);
String field = "ID_LEAD";
if (getTable().contains("ID_CLIENT")) {
field = "ID_CLIENT";
}
SQLRowValues rowVals = row.getForeign(field).createEmptyUpdateRow();
rowVals.put("REMIND_DATE", row.getObject("NEXTCONTACT_DATE"));
try {
rowVals.update();
} catch (SQLException e) {
e.printStackTrace();
}
return id;
}
 
@Override
public void update() {
super.update();
final SQLTable associationTable = getServiceAssociationTable();
String query = "DELETE FROM " + associationTable.getSQL() + " WHERE \"ID_" + this.getElement().getTable().getName() + "\" = " + getSelectedID();
associationTable.getDBSystemRoot().getDataSource().execute(query);
insertAssociatedServiceTo(getSelectedID());
SQLRow row = getTable().getRow(getSelectedID());
String field = "ID_LEAD";
if (getTable().contains("ID_CLIENT")) {
field = "ID_CLIENT";
}
SQLRowValues rowVals = row.getForeign(field).createEmptyUpdateRow();
rowVals.put("REMIND_DATE", row.getObject("NEXTCONTACT_DATE"));
try {
rowVals.update();
} catch (SQLException e) {
e.printStackTrace();
}
}
 
private void insertAssociatedServiceTo(int id) {
final SQLTable associationTable = getServiceAssociationTable();
final QuickAssignPanel panel = getQuickAssignPanel();
final String tableName = this.getElement().getTable().getName();
final int stop = panel.getModel().getRowCount();
for (int i = 0; i < stop; i++) {
SQLRowValues rService = panel.getModel().getRowValuesAt(i);
SQLRowValues rAccess = new SQLRowValues(associationTable);
rAccess.put("ID_" + tableName, id);
rAccess.put("ID_SERVICE", rService.getID());
try {
rAccess.commit();
} catch (SQLException e) {
ExceptionHandler.handle("Unable to store service assocation", e);
}
}
}
 
SQLTable getServiceAssociationTable() {
final SQLTable table = this.getElement().getTable();
return table.getTable(table.getName() + "_SERVICE");
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/ServiceGroup.java
Nouveau fichier
0,0 → 1,12
package org.openconcerto.modules.customerrelationship.lead;
 
import org.openconcerto.ui.group.Group;
 
public class ServiceGroup extends Group {
 
public ServiceGroup() {
super("sales.service");
this.addItem("NAME");
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/CustomerVisitGroup.java
Nouveau fichier
0,0 → 1,26
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class CustomerVisitGroup extends Group {
 
public CustomerVisitGroup() {
super("customerrelationship.customer.visit");
final Group g = new Group("customerrelationship.customer.visit.identifier");
g.addItem("DATE");
g.addItem("ID_CLIENT", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gContent = new Group("customerrelationship.customer.visit.content", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gContent.addItem("ibd.services", new LayoutHints(true, false, true, true, true, false, true, true));
gContent.addItem("INFORMATION", new LayoutHints(true, true, true, true, true, true));
this.add(gContent);
 
final Group gNext = new Group("customerrelationship.customer.visit.next", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gNext.addItem("NEXTCONTACT_DATE", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
gNext.addItem("NEXTCONTACT_INFO", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gNext);
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/LeadVisitSQLElement.java
Nouveau fichier
0,0 → 1,85
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.modules.customerrelationship.lead.GroupSQLComponentWithService;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ListMap;
 
public class LeadVisitSQLElement extends ModuleElement {
 
public LeadVisitSQLElement(AbstractModule module) {
super(module, "LEAD_VISIT");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
l.add("NEXTCONTACT_DATE");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, getComboFields());
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponentWithService(this, new LeadVisitGroup()) {
 
@Override
public JComponent getLabel(String id) {
if (id.equals("customerrelationship.lead.visit.content")) {
return new JLabelBold("Description de la visite");
} else if (id.equals("customerrelationship.lead.visit.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("NEXTCONTACT_INFO")) {
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 50));
jTextArea.setPreferredSize(new Dimension(200, 50));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDate(true);
}
return super.createEditor(id);
}
 
};
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/LeadVisitServiceSQLElement.java
Nouveau fichier
0,0 → 1,10
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.modules.customerrelationship.lead.JoinServiceSQLElement;
 
public class LeadVisitServiceSQLElement extends JoinServiceSQLElement {
public LeadVisitServiceSQLElement(AbstractModule module) {
super(module, "LEAD_VISIT");
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/LeadVisitGroup.java
Nouveau fichier
0,0 → 1,27
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class LeadVisitGroup extends Group {
 
public LeadVisitGroup() {
super("customerrelationship.lead.visit");
final Group g = new Group("customerrelationship.lead.visit.identifier");
g.addItem("DATE");
g.addItem("ID_LEAD", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gContent = new Group("customerrelationship.lead.visit.content", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gContent.addItem("ibd.services", new LayoutHints(true, false, true, true, true, false, true, true));
gContent.addItem("INFORMATION", new LayoutHints(true, true, true, true, true, true));
this.add(gContent);
 
final Group gNext = new Group("customerrelationship.lead.visit.next", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gNext.addItem("NEXTCONTACT_DATE", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
gNext.addItem("NEXTCONTACT_INFO", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gNext);
 
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/CustomerVisitSQLElement.java
Nouveau fichier
0,0 → 1,84
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.modules.customerrelationship.lead.GroupSQLComponentWithService;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
import org.openconcerto.utils.ListMap;
 
public class CustomerVisitSQLElement extends ModuleElement {
 
public CustomerVisitSQLElement(AbstractModule module) {
super(module, "CUSTOMER_VISIT");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
l.add("NEXTCONTACT_DATE");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
return l;
}
 
@Override
public ListMap<String, String> getShowAs() {
return ListMap.singleton(null, getComboFields());
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponentWithService(this, new CustomerVisitGroup()) {
 
@Override
public JComponent getLabel(String id) {
if (id.equals("customerrelationship.customer.visit.content")) {
return new JLabelBold("Description de la visite");
} else if (id.equals("customerrelationship.customer.visit.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("NEXTCONTACT_INFO")) {
final JTextArea jTextArea = new JTextArea();
jTextArea.setFont(new JLabel().getFont());
jTextArea.setMinimumSize(new Dimension(200, 50));
jTextArea.setPreferredSize(new Dimension(200, 50));
return new JScrollPane(jTextArea);
} else if (id.equals("DATE")) {
return new JDate(true);
}
return super.createEditor(id);
}
 
};
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/visit/CustomerVisitServiceSQLElement.java
Nouveau fichier
0,0 → 1,10
package org.openconcerto.modules.customerrelationship.lead.visit;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.modules.customerrelationship.lead.JoinServiceSQLElement;
 
public class CustomerVisitServiceSQLElement extends JoinServiceSQLElement {
public CustomerVisitServiceSQLElement(AbstractModule module) {
super(module, "CUSTOMER_VISIT");
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/importer/LeadCSV.java
Nouveau fichier
0,0 → 1,411
package org.openconcerto.modules.customerrelationship.lead.importer;
 
import java.util.Arrays;
import java.util.Date;
import java.util.Map;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRowValues;
 
public class LeadCSV extends LineCSV {
 
public final static int ID = 0;
public final static int CODE = 1;
public final static int NAME = 2;
public final static int ID_ADR = 3;
public final static int LOCALISATION = 4;
public final static int PHONE = 5;
public final static int MAIL = 6;
public final static int CELL = 7;
public final static int FAX = 8;
public final static int CONTACT = 9;
public final static int SECTEUR = 10;
public final static int EFFECTIF = 11;
public final static int ORIGINE = 12;
public final static int SIRET = 13;
public final static int APE = 14;
public final static int COM = 15;
public final static int STATUT = 16;
public final static int PRENOM = 17;
public final static int NOM = 18;
public final static int CIVILITE = 19;
public final static int DESC = 20;
public final static int CONVERTI = 21;
public final static int BUDGET = 22;
public final static int DISPO = 23;
public final static int CATEGORIE = 24;
public final static int TYPE_TRAVAUX = 25;
public final static int INFOS = 26;
public final static int SIZE = 27;
 
private Object idAdr;
private String code, name, localisation, contact, phone, cell, mail, fax, com, origine, secteur, effectif, siret, ape;
private String statut, prenom, nom, civilite, desc, converti, budget, dispo, categorie, typeT, infos;
 
public LeadCSV(Object id, String name, String loc) {
 
this.id = id;
this.localisation = loc;
this.name = name;
}
 
public void setInfos(String infos) {
this.infos = infos;
}
 
public String getInfos() {
return infos;
}
 
public void setBudget(String budget) {
this.budget = budget;
}
 
public String getBudget() {
return budget;
}
 
public void setCategorie(String categorie) {
this.categorie = categorie;
}
 
public String getCategorie() {
return categorie;
}
 
public void setCivilite(String civilite) {
this.civilite = civilite;
}
 
public String getCivilite() {
return civilite;
}
 
public String getConverti() {
return converti;
}
 
public void setConverti(String converti) {
this.converti = converti;
}
 
public String getDesc() {
return desc;
}
 
public void setDesc(String desc) {
this.desc = desc;
}
 
public String getDispo() {
return dispo;
}
 
public void setDispo(String dispo) {
this.dispo = dispo;
}
 
public String getNom() {
return nom;
}
 
public void setNom(String nom) {
this.nom = nom;
}
 
public String getPrenom() {
return prenom;
}
 
public void setPrenom(String prenom) {
this.prenom = prenom;
}
 
public String getStatut() {
return statut;
}
 
public void setStatut(String statut) {
this.statut = statut;
}
 
public String getTypeT() {
return typeT;
}
 
public void setTypeT(String typeT) {
this.typeT = typeT;
}
 
public String getSiret() {
return this.siret;
}
 
public void setSiret(String siret) {
this.siret = siret;
}
 
public String getApe() {
return ape;
}
 
public void setApe(String ape) {
this.ape = ape;
}
 
public String getCell() {
return cell;
}
 
public String getCom() {
return com;
}
 
public void setCom(String com) {
this.com = com;
}
 
public String getEffectif() {
return effectif;
}
 
public void setEffectif(String effectif) {
this.effectif = effectif;
}
 
public String getLocalisation() {
return localisation;
}
 
public void setLocalisation(String localisation) {
this.localisation = localisation;
}
 
public String getOrigine() {
return origine;
}
 
public void setOrigine(String origine) {
this.origine = origine;
}
 
public String getSecteur() {
return secteur;
}
 
public void setSecteur(String secteur) {
this.secteur = secteur;
}
 
public void setCell(String cell) {
this.cell = cell;
}
 
public String getCode() {
return code;
}
 
public void setCode(String code) {
this.code = code;
}
 
public String getContact() {
return contact;
}
 
public void setContact(String contact) {
this.contact = contact;
}
 
public String getPhone() {
return phone;
}
 
public void setPhone(String phone) {
this.phone = phone;
}
 
public String getFax() {
return fax;
}
 
public void setFax(String fax) {
this.fax = fax;
}
 
public String getMail() {
return mail;
}
 
public void setMail(String mail) {
this.mail = mail;
}
 
public String getName() {
return name;
}
 
public void setName(String name) {
this.name = name;
}
 
public Object getIdAdr() {
return idAdr;
}
 
public void setIdAdr(Object idAdr) {
this.idAdr = idAdr;
}
 
public String[] toCSVLine() {
String[] values = new String[SIZE];
 
values[ID] = this.id.toString();
values[CODE] = this.code;
values[NAME] = this.name;
values[ID_ADR] = String.valueOf(this.idAdr);
values[PHONE] = this.phone;
values[MAIL] = this.mail;
values[CELL] = this.cell;
values[FAX] = this.fax;
values[CONTACT] = this.contact;
 
values[LOCALISATION] = this.localisation;
values[SECTEUR] = this.secteur;
values[EFFECTIF] = this.effectif;
values[ORIGINE] = this.origine;
values[COM] = this.com;
values[APE] = this.ape;
values[SIRET] = this.siret;
 
values[STATUT] = this.statut;
values[PRENOM] = this.prenom;
values[NOM] = this.nom;
values[CIVILITE] = this.civilite;
values[DESC] = this.desc;
values[CONVERTI] = this.converti;
values[BUDGET] = this.budget;
values[DISPO] = this.dispo;
values[CATEGORIE] = this.categorie;
values[TYPE_TRAVAUX] = this.typeT;
values[INFOS] = this.infos;
return values;
}
 
public SQLRowValues toSQLRowValues(DBRoot root, Map<Object, SQLRowValues> adresse) {
SQLRowValues rowVals = new SQLRowValues(root.getTable("LEAD"));
 
// rowVals.put("CODE", getCode());
rowVals.put("COMPANY", getName());
rowVals.put("ID_ADRESSE", adresse.get(getIdAdr()));
 
rowVals.put("PHONE", getPhone());
rowVals.put("EMAIL", getMail());
rowVals.put("MOBILE", getCell());
rowVals.put("FAX", getFax());
rowVals.put("NAME", getContact());
 
rowVals.put("LOCALISATION", getLocalisation());
rowVals.put("INDUSTRY", getSecteur());
try {
rowVals.put("EMPLOYEES", Integer.valueOf(getEffectif()));
} catch (Exception e) {
System.err.println("Unable to parse " + getEffectif());
}
rowVals.put("SOURCE", getOrigine());
int idCom = -1;
if (getCom() != null) {
if (getCom().toUpperCase().contains("YANN")) {
idCom = 3;
} else if (getCom().toUpperCase().contains("ERIC")) {
idCom = 4;
} else if (getCom().toUpperCase().contains("MARC")) {
idCom = 2;
}
}
if (idCom != -1) {
rowVals.put("ID_COMMERCIAL", idCom);
}
rowVals.put("SIRET", getSiret());
rowVals.put("APE", getApe());
rowVals.put("DATE", new Date());
 
int idCiv = 1;
if (getCivilite() != null) {
if (getCivilite().equalsIgnoreCase("Mr.")) {
idCiv = 2;
} else if (getCivilite().equalsIgnoreCase("Mrs.")) {
idCiv = 3;
}
}
if (idCiv != -1) {
rowVals.put("ID_TITRE_PERSONNEL", idCiv);
}
rowVals.put("NAME", getNom());
rowVals.put("FIRSTNAME", getPrenom());
rowVals.put("INFORMATION", getDesc());
// rowVals.put("REVENUE", (getBudget().trim().length()==0?0:Integer);
rowVals.put("DISPO", getDispo());
rowVals.put("INDUSTRY", getTypeT());
rowVals.put("STATUS", getStatut());
rowVals.put("INFOS", getInfos());
 
if (getConverti().equalsIgnoreCase("1")) {
SQLInjector inj = SQLInjector.getInjector(root.getTable("LEAD"), root.getTable("CLIENT"));
SQLRowValues rowValsCli = inj.createRowValuesFrom(Arrays.asList(rowVals));
 
SQLRowValues rowValsAdr = new SQLRowValues(rowVals.getForeign("ID_ADRESSE").asRowValues());
// rowValsAdr.clearPrimaryKeys();
rowValsCli.put("ID_ADRESSE", rowValsAdr);
 
// Contact
SQLRowValues rowValsContact = SQLInjector.getInjector(root.getTable("LEAD"), root.getTable("CONTACT")).createRowValuesFrom(Arrays.asList(rowVals));
rowValsContact.put("ID_CLIENT", rowValsCli);
rowVals.put("ID_CLIENT", rowValsCli);
}
 
return rowVals;
}
 
public boolean isDigitsOrChar(String s) {
boolean ok = true;
for (int i = 0; i < s.length(); i++) {
final char charAt = s.charAt(i);
ok &= ((charAt == ' ') || (charAt >= '0' && charAt <= '9') || (charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z'));
}
return ok;
}
 
public static LeadCSV fromCSVLine(String[] line) {
LeadCSV cli = new LeadCSV(line[ID], line[NAME], line[LOCALISATION]);
cli.setCell(line[CELL]);
cli.setContact(line[CONTACT]);
cli.setFax(line[FAX]);
cli.setIdAdr(line[ID_ADR]);
cli.setMail(line[MAIL]);
cli.setPhone(line[PHONE]);
 
// cli.setLocalisation(line[LOCALISATION]);
cli.setSecteur(line[SECTEUR]);
cli.setEffectif(line[EFFECTIF]);
cli.setOrigine(line[ORIGINE]);
cli.setCom(line[COM]);
 
cli.setSiret(line[SIRET]);
cli.setApe(line[APE]);
 
cli.setPrenom(line[PRENOM]);
cli.setNom(line[NOM]);
cli.setCivilite(line[CIVILITE]);
cli.setDesc(line[DESC]);
cli.setConverti(line[CONVERTI]);
cli.setBudget(line[BUDGET]);
cli.setDispo(line[DISPO]);
cli.setCategorie(line[CATEGORIE]);
cli.setTypeT(line[TYPE_TRAVAUX]);
cli.setStatut(line[STATUT]);
cli.setInfos(line[INFOS]);
return cli;
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/importer/AdresseCSV.java
Nouveau fichier
0,0 → 1,71
package org.openconcerto.modules.customerrelationship.lead.importer;
 
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowValues;
 
public class AdresseCSV extends LineCSV {
 
public final static int ID = 0;
public final static int STREET = 1;
public final static int CITY = 2;
public final static int CODE = 3;
public final static int ID_LEAD = 4;
 
private String code, city, street;
 
public AdresseCSV(Object id, String street, String city, String code) {
this.id = id;
this.code = code;
this.city = city;
this.street = street;
}
 
public String getCode() {
return code;
}
 
public void setCode(String code) {
this.code = code;
}
 
public String getStreet() {
return street;
}
 
public void setStreet(String street) {
this.street = street;
}
 
public String getCity() {
return city;
}
 
public void setCity(String city) {
this.city = city;
}
 
public String[] toCSVLine() {
String[] values = new String[10];
 
values[ID] = this.id.toString();
values[CODE] = this.code;
values[CITY] = this.city;
values[STREET] = String.valueOf(this.street);
 
return values;
}
 
public static AdresseCSV fromCSVLine(String[] line) {
AdresseCSV adr = new AdresseCSV(line[ID], line[STREET], line[CITY], line[CODE]);
return adr;
}
 
public SQLRowValues toSQLRowValues(DBRoot root) {
SQLRowValues rowVals = new SQLRowValues(root.getTable("ADRESSE"));
rowVals.put("RUE", getStreet());
rowVals.put("VILLE", getCity());
rowVals.put("CODE_POSTAL", getCode());
rowVals.put("PAYS", "France");
return rowVals;
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/importer/LineCSV.java
Nouveau fichier
0,0 → 1,16
package org.openconcerto.modules.customerrelationship.lead.importer;
 
 
public abstract class LineCSV {
 
public Object id;
 
public Object getId() {
return id;
}
 
public void setId(Object id) {
this.id = id;
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/importer/LeadImporter.java
Nouveau fichier
0,0 → 1,304
package org.openconcerto.modules.customerrelationship.lead.importer;
 
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
 
import org.openconcerto.erp.importer.DataImporter;
import org.openconcerto.openoffice.ContentType;
import org.openconcerto.openoffice.ODPackage;
import org.openconcerto.openoffice.spreadsheet.Cell;
import org.openconcerto.openoffice.spreadsheet.Sheet;
import org.openconcerto.openoffice.spreadsheet.SpreadSheet;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLRowValuesCluster;
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
import org.openconcerto.sql.model.SQLRowValuesCluster.StoreMode;
import org.openconcerto.utils.cc.IdentityHashSet;
import org.openconcerto.utils.text.CSVReader;
import org.openconcerto.utils.text.CharsetHelper;
 
public class LeadImporter {
 
abstract class CSVImporter<T extends LineCSV> {
 
public Map<Object, T> importFrom(File csvFile) throws IOException {
 
Map<Object, T> map = new HashMap<Object, T>();
 
Charset cs = CharsetHelper.guessEncoding(csvFile, 4096, Charset.forName("Cp1252"));
 
BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(csvFile), cs));
String l = r.readLine();
if (l == null) {
r.close();
return null;
}
char separator = ',';
int cCount = 0;
int scCount = 0;
for (int i = 0; i < l.length(); i++) {
char c = l.charAt(i);
if (c == ',') {
cCount++;
} else if (c == ';') {
scCount++;
}
}
r.close();
if (scCount > cCount) {
separator = ';';
}
 
final CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(csvFile), cs), separator);
final List<String[]> lines = csvReader.readAll();
final int rowCount = lines.size();
int start = 0;
 
for (int i = start; i < rowCount; i++) {
final String[] values = lines.get(i);
final T convertedLine = convert(values);
map.put(convertedLine.getId(), convertedLine);
}
csvReader.close();
return map;
}
 
public abstract T convert(String[] line);
}
 
public LeadCSV createLead(int i, Sheet sheet, int idAdr, int id) {
final Cell<SpreadSheet> cell0 = sheet.getImmutableCellAt(0, i);
final String societeName = cell0.getValue().toString().trim();
final Cell<SpreadSheet> cell1 = sheet.getImmutableCellAt(1, i);
final String loc = cell1.getValue().toString().trim();
 
LeadCSV leadLine = new LeadCSV(id, societeName, loc);
leadLine.setIdAdr(idAdr);
 
final Cell<SpreadSheet> cell2 = sheet.getImmutableCellAt(2, i);
final String siret = cell2.getValue().toString().trim();
leadLine.setSiret(siret);
 
final Cell<SpreadSheet> cell3 = sheet.getImmutableCellAt(3, i);
final String ape = cell3.getValue().toString().trim();
leadLine.setApe(ape);
 
final Cell<SpreadSheet> cell4 = sheet.getImmutableCellAt(4, i);
final String tel = cell4.getValue().toString().trim();
leadLine.setPhone(tel);
 
final Cell<SpreadSheet> cell5 = sheet.getImmutableCellAt(5, i);
final String fax = cell5.getValue().toString().trim();
leadLine.setFax(fax);
 
final Cell<SpreadSheet> cell10 = sheet.getImmutableCellAt(10, i);
final String secteur = cell10.getValue().toString().trim();
leadLine.setSecteur(secteur);
 
final Cell<SpreadSheet> cell11 = sheet.getImmutableCellAt(11, i);
final String effectif = cell11.getValue().toString().trim();
leadLine.setEffectif(effectif);
 
final Cell<SpreadSheet> cell12 = sheet.getImmutableCellAt(12, i);
final String origine = cell12.getValue().toString().trim();
leadLine.setOrigine(origine);
 
// final Cell<SpreadSheet> cell13 = sheet.getImmutableCellAt(13, i);
// final String com = cell13.getValue().toString().trim();
// leadLine.setCom(com);
//
final Cell<SpreadSheet> cell14 = sheet.getImmutableCellAt(14, i);
final String statut = cell14.getValue().toString().trim();
leadLine.setStatut(statut);
 
final Cell<SpreadSheet> cell15 = sheet.getImmutableCellAt(15, i);
final String prenom = cell15.getValue().toString().trim();
leadLine.setPrenom(prenom);
 
final Cell<SpreadSheet> cell16 = sheet.getImmutableCellAt(16, i);
final String nom = cell16.getValue().toString().trim();
leadLine.setNom(nom);
 
final Cell<SpreadSheet> cell17 = sheet.getImmutableCellAt(17, i);
final String civi = cell17.getValue().toString().trim();
leadLine.setCivilite(civi);
 
final Cell<SpreadSheet> cell18 = sheet.getImmutableCellAt(18, i);
final String mail = cell18.getValue().toString().trim();
leadLine.setMail(mail);
 
final Cell<SpreadSheet> cell19 = sheet.getImmutableCellAt(19, i);
final String cell = cell19.getValue().toString().trim();
leadLine.setCell(cell);
 
final Cell<SpreadSheet> cell20 = sheet.getImmutableCellAt(20, i);
final String infos = cell20.getValue().toString().trim();
leadLine.setInfos(infos);
 
final Cell<SpreadSheet> cell21 = sheet.getImmutableCellAt(21, i);
final String desc = cell21.getValue().toString().trim();
leadLine.setDesc(desc);
 
final Cell<SpreadSheet> cell22 = sheet.getImmutableCellAt(22, i);
final String conv = cell22.getValue().toString().trim();
leadLine.setConverti(conv);
 
final Cell<SpreadSheet> cell23 = sheet.getImmutableCellAt(23, i);
final String budget = cell23.getValue().toString().trim();
leadLine.setBudget(budget);
 
final Cell<SpreadSheet> cell24 = sheet.getImmutableCellAt(24, i);
final String com = cell24.getValue().toString().trim();
leadLine.setCom(com);
 
final Cell<SpreadSheet> cell25 = sheet.getImmutableCellAt(25, i);
final String dispo = cell25.getValue().toString().trim();
leadLine.setDispo(dispo);
 
final Cell<SpreadSheet> cell26 = sheet.getImmutableCellAt(26, i);
final String cat = cell26.getValue().toString().trim();
leadLine.setCategorie(cat);
 
final Cell<SpreadSheet> cell27 = sheet.getImmutableCellAt(27, i);
final String type = cell27.getValue().toString().trim();
leadLine.setTypeT(type);
 
return leadLine;
}
 
public AdresseCSV createAdresse(int i, Sheet sheet, int id) {
final Cell<SpreadSheet> cell6 = sheet.getImmutableCellAt(6, i);
String street = cell6.getValue().toString().trim();
 
final Cell<SpreadSheet> cell7 = sheet.getImmutableCellAt(7, i);
final String street2 = cell7.getValue().toString().trim();
if (street2 != null && street2.trim().length() > 0) {
street += "\n" + street2;
}
 
final Cell<SpreadSheet> cell8 = sheet.getImmutableCellAt(8, i);
final String ville = cell8.getValue().toString().trim();
final Cell<SpreadSheet> cell9 = sheet.getImmutableCellAt(9, i);
final String cp = cell9.getValue().toString().trim();
 
AdresseCSV adrLine = new AdresseCSV(id, street, ville, cp);
 
return adrLine;
}
 
public Map<Object, LeadCSV> exportLead(DBRoot root, File dir2save, File sheetFile) throws Exception {
 
List<String[]> adresse = new ArrayList<String[]>();
List<String[]> leadList = new ArrayList<String[]>();
 
Map<Object, LeadCSV> leadMap = new HashMap<Object, LeadCSV>();
 
final ODPackage pkg = new ODPackage(sheetFile);
if (pkg.getContentType().getType() != ContentType.SPREADSHEET)
throw new IOException("Pas un tableur");
final SpreadSheet calc = pkg.getSpreadSheet();
final Sheet commandesSheet = calc.getSheet(0);
int sheetCount = commandesSheet.getRowCount();
for (int s = 1; s < sheetCount; s++) {
 
final Cell<SpreadSheet> cell0 = commandesSheet.getImmutableCellAt(0, s);
final String societeName = cell0.getValue().toString().trim();
final Cell<SpreadSheet> cell16 = commandesSheet.getImmutableCellAt(16, s);
final String name = cell16.getValue().toString().trim();
if (societeName.trim().length() == 0 && name.trim().length() == 0) {
break;
}
// Adresse principale
int idAdr = adresse.size();
AdresseCSV adr = createAdresse(s, commandesSheet, idAdr);
adresse.add(adr.toCSVLine());
LeadCSV lead = createLead(s, commandesSheet, idAdr, leadList.size());
leadList.add(lead.toCSVLine());
leadMap.put(lead.getId(), lead);
}
 
DataImporter importer = new DataImporter(root.getTable("LEAD"));
final File csvFile = new File(dir2save, "Lead.csv");
csvFile.createNewFile();
importer.exportModelToCSV(csvFile, leadList);
DataImporter importerAdr = new DataImporter(root.getTable("ADRESSE"));
final File csvFile2 = new File(dir2save, "Address.csv");
csvFile2.createNewFile();
importerAdr.exportModelToCSV(csvFile2, adresse);
 
return leadMap;
}
 
public void importFromFile(File csvFileDir, DBRoot root) throws Exception {
 
SQLRowValues rowValsLead = new SQLRowValues(root.getTable("LEAD"));
rowValsLead.put("COMPANY", null);
rowValsLead.put("APE", null);
rowValsLead.putRowValues("ID_ADRESSE").putNulls("VILLE", "RUE");
SQLRowValuesListFetcher fecther = SQLRowValuesListFetcher.create(rowValsLead);
List<SQLRowValues> existingLeads = fecther.fetch();
List<String> existingHashLead = new ArrayList<String>(existingLeads.size());
 
for (SQLRowValues sqlRowValues : existingLeads) {
existingHashLead.add(sqlRowValues.getString("APE") + "----" + sqlRowValues.getString("COMPANY") + "----" + sqlRowValues.getForeign("ID_ADRESSE").getString("RUE") + "----"
+ sqlRowValues.getForeign("ID_ADRESSE").getString("VILLE"));
}
 
// Adresse
CSVImporter<AdresseCSV> adr = new CSVImporter<AdresseCSV>() {
@Override
public AdresseCSV convert(String[] line) {
return AdresseCSV.fromCSVLine(line);
}
};
final Map<Object, AdresseCSV> mapAdr = adr.importFrom(new File(csvFileDir, "Address.csv"));
 
Map<Object, SQLRowValues> mapAdrRows = new HashMap<Object, SQLRowValues>();
for (Object o : mapAdr.keySet()) {
AdresseCSV c = mapAdr.get(o);
mapAdrRows.put(c.getId(), c.toSQLRowValues(root));
}
 
// Client
CSVImporter<LeadCSV> client = new CSVImporter<LeadCSV>() {
@Override
public LeadCSV convert(String[] line) {
return LeadCSV.fromCSVLine(line);
}
};
 
Map<Object, LeadCSV> mapClient = client.importFrom(new File(csvFileDir, "Lead.csv"));
 
Map<Object, SQLRowValues> mapCliRows = new HashMap<Object, SQLRowValues>();
for (Object o : mapClient.keySet()) {
LeadCSV c = mapClient.get(o);
 
String hashLead = c.getApe() + "----" + c.getName() + "----" + mapAdr.get(c.getIdAdr()).getStreet() + "----" + mapAdr.get(c.getIdAdr()).getCity();
if (!existingHashLead.contains(hashLead)) {
mapCliRows.put(c.getId(), c.toSQLRowValues(root, mapAdrRows));
} else {
System.err.println("Prospect déjà existant " + c.getName() + " --> Non importé");
}
}
 
final Set<SQLRowValuesCluster> graphs = new IdentityHashSet<SQLRowValuesCluster>();
for (Object c : mapCliRows.keySet()) {
graphs.add(mapCliRows.get(c).getGraph());
}
 
for (final SQLRowValuesCluster graph : graphs) {
graph.store(StoreMode.COMMIT);
}
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadGroup.java
1,5 → 1,7
package org.openconcerto.modules.customerrelationship.lead;
 
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.users.rights.UserRights;
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
16,9 → 18,11
final Group gContact = new Group("customerrelationship.lead.person", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gContact.addItem("NAME");
gContact.addItem("FIRSTNAME");
gContact.addItem("ID_TITRE_PERSONNEL");
this.add(gContact);
 
final Group gCustomer = new Group("customerrelationship.lead.contact", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gCustomer.addItem("ROLE", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
gCustomer.addItem("PHONE");
gCustomer.addItem("MOBILE");
gCustomer.addItem("FAX");
35,6 → 39,7
gInfos.addItem("INDUSTRY");
gInfos.addItem("REVENUE");
gInfos.addItem("EMPLOYEES");
gInfos.addItem("INFOS", new LayoutHints(true, true, true, true, true, true));
this.add(gInfos);
 
final Group gState = new Group("customerrelationship.lead.state");
42,6 → 47,13
gState.addItem("SOURCE");
gState.addItem("STATUS");
gState.addItem("ID_COMMERCIAL");
gState.addItem("REMIND_DATE");
UserRights rights = UserManager.getInstance().getCurrentUser().getRights();
if (rights.haveRight("CLIENT_PROSPECT")) {
gState.addItem("ID_CLIENT");
}
gState.addItem("DISPO");
this.add(gState);
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/Module.java
1,8 → 1,19
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.Component;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.sql.SQLException;
 
import javax.swing.AbstractAction;
import javax.swing.JFrame;
 
import org.openconcerto.erp.action.CreateFrameAbstractAction;
import org.openconcerto.erp.config.ComptaPropsConfiguration;
import org.openconcerto.erp.config.Gestion;
import org.openconcerto.erp.config.MainFrame;
import org.openconcerto.erp.modules.AbstractModule;
13,15 → 24,51
import org.openconcerto.erp.modules.ModuleManager;
import org.openconcerto.erp.modules.ModulePackager;
import org.openconcerto.erp.modules.RuntimeModuleFactory;
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallSQLElement;
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallServiceSQLElement;
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallSQLElement;
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallServiceSQLElement;
import org.openconcerto.modules.customerrelationship.lead.importer.LeadImporter;
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitSQLElement;
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitServiceSQLElement;
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitSQLElement;
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitServiceSQLElement;
import org.openconcerto.openoffice.ContentTypeVersioned;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.element.SQLElementDirectory;
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.SQLDataSource;
import org.openconcerto.sql.model.SQLRequestLog;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.ui.ConnexionPanel;
import org.openconcerto.sql.utils.SQLCreateTable;
import org.openconcerto.sql.utils.SQLUtils;
import org.openconcerto.sql.view.EditFrame;
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.FrameUtil;
import org.openconcerto.ui.SwingThreadUtils;
import org.openconcerto.utils.ExceptionHandler;
 
public final class Module extends AbstractModule {
 
public static final String TABLE_LEAD = "LEAD";
public static final String TABLE_LEAD_CALL = "LEAD_CALL";
public static final String TABLE_CUSTOMER_CALL = "CUSTOMER_CALL";
public static final String TABLE_LEAD_VISIT = "LEAD_VISIT";
public static final String TABLE_CUSTOMER_VISIT = "CUSTOMER_VISIT";
public static final String TABLE_SERVICE = "SERVICE";
//
public static final String TABLE_LEAD_CALL_SERVICE = "LEAD_CALL_SERVICE";
public static final String TABLE_CUSTOMER_CALL_SERVICE = "CUSTOMER_CALL_SERVICE";
public static final String TABLE_LEAD_VISIT_SERVICE = "LEAD_VISIT_SERVICE";
public static final String TABLE_CUSTOMER_VISIT_SERVICE = "CUSTOMER_VISIT_SERVICE";
 
public Module(ModuleFactory f) throws IOException {
super(f);
60,15 → 107,134
createTable.addIntegerColumn("REVENUE", 0);
createTable.addIntegerColumn("EMPLOYEES", 0);
 
createTable.addVarCharColumn("ROLE", 128);
createTable.addForeignColumn("CLIENT");
createTable.addVarCharColumn("LOCALISATION", 256);
createTable.addVarCharColumn("INFOS", 128);
createTable.addForeignColumn("TITRE_PERSONNEL");
createTable.addDateAndTimeColumn("REMIND_DATE");
createTable.addVarCharColumn("APE", 128);
createTable.addVarCharColumn("SIRET", 256);
createTable.addVarCharColumn("DISPO", 256);
createTable.addBooleanColumn("MAILING", Boolean.FALSE, false);
 
// V2
 
// Appel à un prospect
final SQLCreateTable createLCall = ctxt.getCreateTable(TABLE_LEAD_CALL);
createLCall.addDateAndTimeColumn("DATE");
createLCall.addForeignColumn(createTable);
createLCall.addVarCharColumn("INFORMATION", 10240);
createLCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
createLCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
 
// Appel à un client
final SQLCreateTable createCCall = ctxt.getCreateTable(TABLE_CUSTOMER_CALL);
createCCall.addDateAndTimeColumn("DATE");
createCCall.addForeignColumn("CLIENT");
createCCall.addVarCharColumn("INFORMATION", 10240);
createCCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
createCCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
 
// Visites chez un prospect
final SQLCreateTable createLV = ctxt.getCreateTable(TABLE_LEAD_VISIT);
createLV.addDateAndTimeColumn("DATE");
createLV.addForeignColumn(createTable);
createLV.addVarCharColumn("INFORMATION", 10240);
createLV.addDateAndTimeColumn("NEXTCONTACT_DATE");
createLV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
// Visites chez un client
final SQLCreateTable createCV = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT);
createCV.addDateAndTimeColumn("DATE");
createCV.addForeignColumn("CLIENT");
createCV.addVarCharColumn("INFORMATION", 10240);
createCV.addDateAndTimeColumn("NEXTCONTACT_DATE");
createCV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
 
// Services
final SQLCreateTable createService = ctxt.getCreateTable(TABLE_SERVICE);
createService.addVarCharColumn("NAME", 256);
 
//
if (ctxt.getRoot().getTable(TABLE_LEAD_CALL_SERVICE) == null) {
final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_CALL_SERVICE);
createTable1.addForeignColumn(createLCall);
createTable1.addForeignColumn(createService);
}
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_CALL_SERVICE) == null) {
final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_CALL_SERVICE);
createTable1.addForeignColumn(createCCall);
createTable1.addForeignColumn(createService);
}
if (ctxt.getRoot().getTable(TABLE_LEAD_VISIT_SERVICE) == null) {
final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_VISIT_SERVICE);
createTable1.addForeignColumn(createLV);
createTable1.addForeignColumn(createService);
}
if (ctxt.getRoot().getTable(TABLE_CUSTOMER_VISIT_SERVICE) == null) {
final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT_SERVICE);
createTable1.addForeignColumn(createCV);
createTable1.addForeignColumn(createService);
}
}
}
 
@Override
protected void setupElements(SQLElementDirectory dir) {
protected void setupElements(final SQLElementDirectory dir) {
super.setupElements(dir);
 
final LeadSQLElement element = new LeadSQLElement(this);
GlobalMapper.getInstance().map(element.getCode() + ".default", new LeadGroup());
dir.addSQLElement(element);
 
dir.addSQLElement(new LeadCallSQLElement(this));
dir.addSQLElement(new CustomerCallSQLElement(this));
dir.addSQLElement(new LeadVisitSQLElement(this));
dir.addSQLElement(new CustomerVisitSQLElement(this));
dir.addSQLElement(new ServiceSQLElement(this));
// Services
dir.addSQLElement(new LeadCallServiceSQLElement(this));
dir.addSQLElement(new CustomerCallServiceSQLElement(this));
dir.addSQLElement(new LeadVisitServiceSQLElement(this));
dir.addSQLElement(new CustomerVisitServiceSQLElement(this));
 
// Call
final RowAction.PredicateRowAction addCallAction = new RowAction.PredicateRowAction(new AbstractAction("Appeler") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_CALL);
final SQLTable table = eCall.getTable();
EditFrame editFrame = new EditFrame(eCall);
final SQLRowValues sqlRowValues = new SQLRowValues(table);
sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
editFrame.getSQLComponent().select(sqlRowValues);
FrameUtil.show(editFrame);
}
}, true) {
};
addCallAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
dir.getElement("CLIENT").getRowActions().add(addCallAction);
// Visit
final RowAction.PredicateRowAction addVisitAction = new RowAction.PredicateRowAction(new AbstractAction("Enregister une visite") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_VISIT);
final SQLTable table = eCall.getTable();
EditFrame editFrame = new EditFrame(eCall);
final SQLRowValues sqlRowValues = new SQLRowValues(table);
sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
editFrame.getSQLComponent().select(sqlRowValues);
FrameUtil.show(editFrame);
}
}, true) {
};
addVisitAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
dir.getElement("CLIENT").getRowActions().add(addVisitAction);
 
}
 
@Override
77,12 → 243,68
}
 
@Override
protected void setupMenu(MenuContext ctxt) {
ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD), MainFrame.LIST_MENU);
protected void setupMenu(final MenuContext ctxt) {
ctxt.addMenuItem(new LeadListAction(), MainFrame.LIST_MENU);
 
ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des services") {
@Override
public JFrame createFrame() {
final JFrame frame = new JFrame("Services proposés");
frame.setContentPane(new ListeAddPanel(ctxt.getElement(TABLE_SERVICE)));
return frame;
}
}, MainFrame.STRUCTURE_MENU);
ctxt.addMenuItem(new SuiviClientProspectListAction(), MainFrame.LIST_MENU);
// ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_CALL), MainFrame.LIST_MENU);
// ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_VISIT), MainFrame.LIST_MENU);
// ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_CALL), MainFrame.LIST_MENU);
// ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_VISIT), MainFrame.LIST_MENU);
 
ctxt.addMenuItem(new AbstractAction("Import de prospects") {
@Override
public void actionPerformed(ActionEvent e) {
final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
final FileDialog fd = new FileDialog(frame, "Import de prospects", FileDialog.LOAD);
fd.setFilenameFilter(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith("." + ContentTypeVersioned.SPREADSHEET.getExtension());
}
});
fd.setVisible(true);
if (fd.getFile() != null) {
final DBRoot rootSociete = ((ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance()).getRootSociete();
try {
SQLUtils.executeAtomic(rootSociete.getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
@Override
public Object handle(final SQLDataSource ds) throws SQLException, IOException {
File f = new File(fd.getDirectory());
 
LeadImporter imp = new LeadImporter();
try {
imp.exportLead(rootSociete, f, new File(fd.getDirectory(), fd.getFile()));
imp.importFromFile(f, rootSociete);
} catch (Exception exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
return null;
}
});
} catch (IOException exn) {
ExceptionHandler.handle(frame, "Erreur lors de la lecture du fichier", exn);
} catch (SQLException exn) {
ExceptionHandler.handle(frame, "Erreur lors de l'insertion dans la base", exn);
}
}
}
}, MainFrame.FILE_MENU);
}
 
@Override
protected void start() {
new LeadCustomerSQLInjector();
new LeadContactSQLInjector();
}
 
@Override
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/ServiceSQLElement.java
Nouveau fichier
0,0 → 1,28
package org.openconcerto.modules.customerrelationship.lead;
 
import java.util.ArrayList;
import java.util.List;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.element.SQLComponent;
 
public class ServiceSQLElement extends ModuleElement {
 
public ServiceSQLElement(AbstractModule module) {
super(module, "SERVICE");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("NAME");
return l;
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponent(this, new ServiceGroup());
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/CustomerCallSQLElement.java
Nouveau fichier
0,0 → 1,70
package org.openconcerto.modules.customerrelationship.lead.call;
 
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.modules.customerrelationship.lead.GroupSQLComponentWithService;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
 
public class CustomerCallSQLElement extends ModuleElement {
 
public CustomerCallSQLElement(AbstractModule module) {
super(module, "CUSTOMER_CALL");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_CLIENT");
return l;
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponentWithService(this, new CustomerCallGroup()) {
@Override
public JComponent getLabel(String id) {
if (id.equals("customerrelationship.customer.call.content")) {
return new JLabelBold("Description de l'appel téléphonique");
}else if (id.equals("customerrelationship.customer.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 JDate(true);
}
return super.createEditor(id);
}
 
};
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/CustomerCallServiceSQLElement.java
Nouveau fichier
0,0 → 1,10
package org.openconcerto.modules.customerrelationship.lead.call;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.modules.customerrelationship.lead.JoinServiceSQLElement;
 
public class CustomerCallServiceSQLElement extends JoinServiceSQLElement {
public CustomerCallServiceSQLElement(AbstractModule module) {
super(module, "CUSTOMER_CALL");
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/CustomerCallGroup.java
Nouveau fichier
0,0 → 1,26
package org.openconcerto.modules.customerrelationship.lead.call;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class CustomerCallGroup extends Group {
 
public CustomerCallGroup() {
super("customerrelationship.customer.call");
final Group g = new Group("customerrelationship.customer.call.identifier");
g.addItem("DATE");
g.addItem("ID_CLIENT", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gAddress = new Group("customerrelationship.customer.call.content", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("ibd.services", new LayoutHints(true, false, true, true, true, false, true, true));
gAddress.addItem("INFORMATION", new LayoutHints(true, true, true, true, true, true));
this.add(gAddress);
 
final Group gNext = new Group("customerrelationship.customer.call.next", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gNext.addItem("NEXTCONTACT_DATE", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
gNext.addItem("NEXTCONTACT_INFO", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gNext);
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/LeadCallSQLElement.java
Nouveau fichier
0,0 → 1,71
package org.openconcerto.modules.customerrelationship.lead.call;
 
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.modules.customerrelationship.lead.GroupSQLComponentWithService;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.ui.JDate;
import org.openconcerto.ui.JLabelBold;
 
public class LeadCallSQLElement extends ModuleElement {
 
public LeadCallSQLElement(AbstractModule module) {
super(module, "LEAD_CALL");
}
 
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
return l;
}
 
@Override
protected List<String> getComboFields() {
final List<String> l = new ArrayList<String>();
l.add("DATE");
l.add("ID_LEAD");
return l;
}
 
@Override
public SQLComponent createComponent() {
return new GroupSQLComponentWithService(this, new LeadCallGroup()) {
@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 JDate(true);
}
return super.createEditor(id);
}
 
};
}
 
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/LeadCallServiceSQLElement.java
Nouveau fichier
0,0 → 1,10
package org.openconcerto.modules.customerrelationship.lead.call;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.modules.customerrelationship.lead.JoinServiceSQLElement;
 
public class LeadCallServiceSQLElement extends JoinServiceSQLElement {
public LeadCallServiceSQLElement(AbstractModule module) {
super(module, "LEAD_CALL");
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/call/LeadCallGroup.java
Nouveau fichier
0,0 → 1,25
package org.openconcerto.modules.customerrelationship.lead.call;
 
import org.openconcerto.ui.group.Group;
import org.openconcerto.ui.group.LayoutHints;
 
public class LeadCallGroup extends Group {
 
public LeadCallGroup() {
super("customerrelationship.lead.call");
final Group g = new Group("customerrelationship.lead.call.identifier");
g.addItem("DATE");
g.addItem("ID_LEAD", LayoutHints.DEFAULT_LARGE_FIELD_HINTS);
this.add(g);
 
final Group gAddress = new Group("customerrelationship.lead.call.content", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gAddress.addItem("ibd.services", new LayoutHints(true, false, true, true, true, false, true, true));
gAddress.addItem("INFORMATION", new LayoutHints(true, true, true, true, true, true));
this.add(gAddress);
 
final Group gNext = new Group("customerrelationship.lead.call.next", LayoutHints.DEFAULT_SEPARATED_GROUP_HINTS);
gNext.addItem("NEXTCONTACT_DATE", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
gNext.addItem("NEXTCONTACT_INFO", LayoutHints.DEFAULT_VERY_LARGE_TEXT_HINTS);
this.add(gNext);
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadSQLElement.java
1,23 → 1,327
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.event.ActionEvent;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Set;
 
import javax.swing.AbstractAction;
import javax.swing.JOptionPane;
 
import org.openconcerto.erp.modules.AbstractModule;
import org.openconcerto.erp.modules.ModuleElement;
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.element.GlobalMapper;
import org.openconcerto.sql.element.SQLComponent;
import org.openconcerto.sql.element.SQLElement;
import org.openconcerto.sql.model.FieldPath;
import org.openconcerto.sql.model.SQLField;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLRow;
import org.openconcerto.sql.model.SQLRowAccessor;
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.model.Where;
import org.openconcerto.sql.model.graph.Path;
import org.openconcerto.sql.users.User;
import org.openconcerto.sql.users.UserManager;
import org.openconcerto.sql.view.EditFrame;
import org.openconcerto.sql.view.EditPanel.EditMode;
import org.openconcerto.sql.view.EditPanelListener;
import org.openconcerto.sql.view.list.BaseSQLTableModelColumn;
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.sql.view.list.RowAction.PredicateRowAction;
import org.openconcerto.sql.view.list.SQLTableModelSource;
import org.openconcerto.ui.EmailComposer;
import org.openconcerto.ui.FrameUtil;
import org.openconcerto.ui.group.Group;
import org.openconcerto.utils.CollectionUtils;
import org.openconcerto.utils.ExceptionHandler;
import org.openconcerto.utils.ListMap;
import org.openconcerto.utils.cc.ITransformer;
 
public class LeadSQLElement extends ModuleElement {
public static final String ELEMENT_CODE = "customerrelationship.lead";
public static String CODE_NOT_RESTRICT = "VIEW_ALL_LEADS";
 
public LeadSQLElement(final AbstractModule module) {
super(module, Module.TABLE_LEAD);
this.setL18nLocation(LeadSQLElement.class);
 
// Call
final RowAction.PredicateRowAction addCallAction = new RowAction.PredicateRowAction(new AbstractAction("Appeler") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
final SQLTable table = LeadSQLElement.this.getTable().getTable(Module.TABLE_LEAD_CALL);
final SQLElement eCall = LeadSQLElement.this.getDirectory().getElement(table);
EditFrame editFrame = new EditFrame(eCall);
final SQLRowValues sqlRowValues = new SQLRowValues(table);
sqlRowValues.put("ID_LEAD", sRow.getIDNumber());
editFrame.getSQLComponent().select(sqlRowValues);
FrameUtil.show(editFrame);
}
}, true) {
};
addCallAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(addCallAction);
// Visit
final RowAction.PredicateRowAction addVisitAction = new RowAction.PredicateRowAction(new AbstractAction("Enregister une visite") {
 
@Override
public void actionPerformed(ActionEvent e) {
SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
final SQLTable table = LeadSQLElement.this.getTable().getTable(Module.TABLE_LEAD_VISIT);
final SQLElement eCall = LeadSQLElement.this.getDirectory().getElement(table);
EditFrame editFrame = new EditFrame(eCall);
final SQLRowValues sqlRowValues = new SQLRowValues(table);
sqlRowValues.put("ID_LEAD", sRow.getIDNumber());
editFrame.getSQLComponent().select(sqlRowValues);
FrameUtil.show(editFrame);
}
}, true) {
};
addVisitAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
getRowActions().add(addVisitAction);
 
setRowActions();
}
 
@Override
protected void _initTableSource(SQLTableModelSource source) {
 
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"));
final List<Integer> listComm = new ArrayList<Integer>();
for (SQLRow sqlRow : rows) {
listComm.add(sqlRow.getID());
}
if (listComm != null && listComm.size() > 0) {
source.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
 
@Override
public SQLSelect transformChecked(SQLSelect input) {
 
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()));
input.setWhere(w);
return input;
}
});
}
}
 
BaseSQLTableModelColumn adresse = new BaseSQLTableModelColumn("Adresse", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
SQLRowAccessor rAdr = r.getForeign("ID_ADRESSE");
if (rAdr != null && !rAdr.isUndefined()) {
 
return rAdr.getString("RUE");
}
return "";
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ADRESSE"));
return CollectionUtils.createSet(new FieldPath(p, "RUE"));
}
};
source.getColumns().add(adresse);
 
BaseSQLTableModelColumn cp = new BaseSQLTableModelColumn("Code Postal", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
SQLRowAccessor rAdr = r.getForeign("ID_ADRESSE");
if (rAdr != null && !rAdr.isUndefined()) {
 
return rAdr.getString("CODE_POSTAL");
}
 
return "";
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ADRESSE"));
 
return CollectionUtils.createSet(new FieldPath(p, "CODE_POSTAL"));
}
};
source.getColumns().add(cp);
 
BaseSQLTableModelColumn ville = new BaseSQLTableModelColumn("Ville", String.class) {
 
@Override
protected Object show_(SQLRowAccessor r) {
 
SQLRowAccessor rAdr = r.getForeign("ID_ADRESSE");
if (rAdr != null && !rAdr.isUndefined()) {
 
return rAdr.getString("VILLE");
}
return "";
 
}
 
@Override
public Set<FieldPath> getPaths() {
Path p = new Path(getTable());
p = p.add(getTable().getTable("ADRESSE"));
 
return CollectionUtils.createSet(new FieldPath(p, "VILLE"));
}
};
source.getColumns().add(ville);
 
if (getTable().contains("REMIND_DATE")) {
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(getTable());
return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
}
};
 
dateRemind.setRenderer(new RemindDateRenderer());
source.getColumns().add(dateRemind);
 
}
}
 
private void setRowActions() {
 
AbstractAction action = new AbstractAction("Transférer en client") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
final SQLRow row = IListe.get(e).getSelectedRow().asRow();
 
SQLRowAccessor foreign = row.getForeign("ID_CLIENT");
if (foreign == null || foreign.isUndefined()) {
 
// Client
SQLRowValues rowVals = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("CLIENT")).createRowValuesFrom(row);
 
SQLRowAccessor adresse = row.getForeign("ID_ADRESSE");
if (adresse != null && !adresse.isUndefined()) {
SQLRowValues rowValsAdr = new SQLRowValues(adresse.asRowValues());
// rowValsAdr.clearPrimaryKeys();
rowVals.put("ID_ADRESSE", rowValsAdr);
}
 
// Contact
SQLRowValues rowValsContact = SQLInjector.getInjector(row.getTable(), row.getTable().getTable("CONTACT")).createRowValuesFrom(row);
rowValsContact.put("ID_CLIENT", rowVals);
 
EditFrame frame = new EditFrame(Configuration.getInstance().getDirectory().getElement("CLIENT"), EditMode.CREATION);
frame.getSQLComponent().select(rowVals);
frame.setVisible(true);
 
frame.addEditPanelListener(new EditPanelListener() {
 
@Override
public void modified() {
}
 
@Override
public void inserted(int id) {
SQLRowValues rowVals = row.asRowValues();
rowVals.put("ID_CLIENT", id);
rowVals.put("STATUS", "Acquis");
try {
rowVals.commit();
} catch (SQLException exn) {
// TODO Bloc catch auto-généré
exn.printStackTrace();
}
}
 
@Override
public void deleted() {
}
 
@Override
public void cancelled() {
}
});
} else {
JOptionPane.showMessageDialog(null, "Ce prospect a déjà été transféré en client!");
}
}
};
PredicateRowAction transfertClient = new PredicateRowAction(action, true);
transfertClient.setPredicate(IListeEvent.getSingleSelectionPredicate());
this.getRowActions().add(transfertClient);
 
AbstractAction actionMail = new AbstractAction("Envoyer un e-mail") {
 
@Override
public void actionPerformed(ActionEvent e) {
 
sendMail(IListe.get(e).getSelectedRows());
 
}
};
PredicateRowAction mail = new PredicateRowAction(actionMail, true);
mail.setPredicate(IListeEvent.getNonEmptySelectionPredicate());
this.getRowActions().add(mail);
}
 
protected void sendMail(List<SQLRowValues> l) {
 
String mail = "";
 
// #endif
for (SQLRowAccessor rowCli : l) {
String string = rowCli.getString("EMAIL");
if (string != null && string.trim().length() > 0) {
mail += string + ";";
}
}
 
try {
EmailComposer.getInstance().compose(mail, "", "");
} catch (Exception exn) {
ExceptionHandler.handle(null, "Impossible de créer le courriel", exn);
}
 
}
 
@Override
protected String createCode() {
return ELEMENT_CODE;
}
25,9 → 329,20
@Override
protected List<String> getListFields() {
final List<String> l = new ArrayList<String>();
l.add("ID_COMMERCIAL");
l.add("DATE");
l.add("COMPANY");
l.add("LOCALISATION");
l.add("ID_TITRE_PERSONNEL");
l.add("NAME");
l.add("FIRSTNAME");
l.add("NAME");
l.add("PHONE");
l.add("MOBILE");
l.add("EMAIL");
l.add("SOURCE");
l.add("INFORMATION");
l.add("INFOS");
// l.add("REMIND_DATE");
return l;
}
 
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadListAction.java
Nouveau fichier
0,0 → 1,226
/*
* Créé le 6 nov. 2012
*/
package org.openconcerto.modules.customerrelationship.lead;
 
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
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 LeadListAction extends CreateFrameAbstractAction {
 
private SQLElement eltProspect = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD);
 
@Override
public JFrame createFrame() {
PanelFrame frame = new PanelFrame(getPanel(), "Liste des prospects");
return frame;
}
 
public LeadListAction() {
super("Liste des propects");
}
 
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.eltProspect.getTable().getField("STATUS"));
selStatus.addGroupBy(this.eltProspect.getTable().getField("STATUS"));
selStatus.addFieldOrder(this.eltProspect.getTable().getField("STATUS"));
 
System.err.println(selStatus.asString());
 
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);
}
}
 
// final SQLElement eltDevis =
// Configuration.getInstance().getDirectory().getElement(this.eltProspect.getTable().getTable("DEVIS"));
// if (eltDevis.getTable().getTable("CLIENT").contains("PROSPECT")) {
// // Filter
// final SQLTableModelSourceOnline lAttente = eltDevis.getTableSource(true);
// if (eltDevis.getTable().contains("REMIND_DATE")) {
// 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(eltDevis.getTable());
// return CollectionUtils.createSet(new FieldPath(p, "REMIND_DATE"));
// }
// };
//
// dateRemind.setRenderer(new RemindDateRenderer());
// lAttente.getColumns().add(dateRemind);
//
// }
// lAttente.getReq().setSelectTransf(new ITransformer<SQLSelect, SQLSelect>() {
//
// @Override
// public SQLSelect transformChecked(SQLSelect input) {
// Where wAttente = new Where(input.getTable("DEVIS").getField("ID_ETAT_DEVIS"), "=",
// EtatDevisSQLElement.EN_ATTENTE);
// wAttente = wAttente.and(new
// Where(input.getAlias(eltDevis.getTable().getTable("CLIENT")).getField("PROSPECT"), "=",
// Boolean.TRUE));
//
// 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"));
// final List<Integer> listComm = new ArrayList<Integer>();
// for (SQLRow sqlRow : rows) {
// listComm.add(sqlRow.getID());
// }
// if (listComm != null && listComm.size() > 0) {
// SQLField field = input.getTable("DEVIS").getField("ID_COMMERCIAL");
// Where w = new Where(field, listComm);
// w = w.or(new Where(field, "IS", (Object) null));
// w = w.or(new Where(field, "=",
// eltDevis.getTable().getTable("COMMERCIAL").getUndefinedID()));
// wAttente = wAttente.and(w);
// }
// }
//
// input.setWhere(wAttente);
// return input;
// }
// });
//
// BaseSQLTableModelColumn mb = new BaseSQLTableModelColumn("Informations commerciales",
// String.class) {
//
// @Override
// protected Object show_(SQLRowAccessor r) {
//
// return r.getString("INFOS_COM");
// }
//
// @Override
// public Set<FieldPath> getPaths() {
//
// Path p = new Path(eltDevis.getTable());
//
// return Collections.singleton(new FieldPath(p, "INFOS_COM"));
// }
// };
//
// lAttente.getColumns().add(mb);
//
// final ListeAddPanel paneDevis = new ListeAddPanel(eltDevis, new IListe(lAttente),
// "Prospect");
// tabbedPane.add("Devis en attente", paneDevis);
// }
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.eltProspect.getTableSource(true);
 
if (status != null) {
Where wAttente = new Where(this.eltProspect.getTable().getField("STATUS"), "=", status);
source.getReq().setWhere(wAttente);
} else {
source.getColumns().add(new BaseSQLTableModelColumn("Transférer en client", Boolean.class) {
@Override
protected Object show_(SQLRowAccessor r) {
return (r.getForeign("ID_CLIENT") != null && !r.isForeignEmpty("ID_CLIENT"));
}
 
@Override
public Set<FieldPath> getPaths() {
 
Path p = new Path(eltProspect.getTable());
return CollectionUtils.createSet(new FieldPath(p, "ID_CLIENT"));
}
});
}
final ListeAddPanel pane = new ListeAddPanel(this.eltProspect, new IListe(source), "Status" + status);
pane.getListe().setOpaque(false);
pane.setOpaque(false);
return pane;
}
}
/trunk/Modules/Module Lead/src/org/openconcerto/modules/customerrelationship/lead/LeadContactSQLInjector.java
Nouveau fichier
0,0 → 1,25
/*
* Créé le 5 nov. 2012
*/
package org.openconcerto.modules.customerrelationship.lead;
 
import org.openconcerto.sql.Configuration;
import org.openconcerto.sql.model.SQLInjector;
import org.openconcerto.sql.model.SQLTable;
 
public class LeadContactSQLInjector extends SQLInjector {
 
private final static SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
private static final SQLTable leadTable = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD).getTable();
 
public LeadContactSQLInjector() {
super(leadTable, contactTable, false);
createDefaultMap();
map(leadTable.getField("NAME"), contactTable.getField("NOM"));
map(leadTable.getField("FIRSTNAME"), contactTable.getField("PRENOM"));
map(leadTable.getField("PHONE"), contactTable.getField("TEL_DIRECT"));
map(leadTable.getField("MOBILE"), contactTable.getField("TEL_MOBILE"));
map(leadTable.getField("FAX"), contactTable.getField("FAX"));
map(leadTable.getField("ROLE"), contactTable.getField("FONCTION"));
}
}
/trunk/Modules/Module Lead/module.properties
1,6 → 1,6
# [\p{Alnum}_.]{3,}
id=org.openconcerto.modules.customerrelationship.lead
# \p{Digit}(\.\p{Digit}+)?
version=1.0
version=1.1
contact=ILM Informatique