Skip to content

Commit

Permalink
Fix bug on double Customers in Tree during search #237
Browse files Browse the repository at this point in the history
  • Loading branch information
KraTuX31 committed Apr 13, 2015
1 parent ca111c7 commit 4881efe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
34 changes: 18 additions & 16 deletions src/database/customerdatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ WdgModels::CustomersTableModel*
q.prepare( "SELECT DISTINCT c.idCustomer as cidcustomer, "
"c.firstnameReferent as cfirstnameReferent, "
"UPPER(c.lastnameReferent) as clastnameReferent, "
"c.company as ccompany, c.complementAddress as ccomplement, c.website as cwebsite, "
"c.company as ccompany, c.complementAddress as ccomplement, "
"c.website as cwebsite, "
"c.address as caddress, c.postalCode as cpostalcode, "
"c.city as ccity, c.country as ccountry, c.email as cemail, "
"c.phone as cphone, c.mobilephone as cmobilephone, c.fax as cfax, "
Expand Down Expand Up @@ -64,18 +65,18 @@ throw(DbException*)

QSqlQuery q;

q.prepare( "SELECT DISTINCT c.idCustomer as cidcustomer, "
"c.firstnameReferent as cfirstnameReferent, "
"UPPER(c.lastnameReferent) as clastnameReferent, "
"c.company as ccompany, "
"c.address as caddress, c.postalCode as cpostalcode, "
"c.city as ccity, c.country as ccountry, c.email as cemail, "
"c.phone as cphone, c.mobilephone as cmobilephone, c.fax as cfax, "
"c.complementAddress as ccomplement, c.website as cwebsite,"
"c.isArchived as cisArchived "
"FROM Customer c "+filter+" "
"ORDER BY 4, 3 "
);
q.prepare( "SELECT DISTINCT c.idCustomer as cidcustomer, "
"c.firstnameReferent as cfirstnameReferent, "
"UPPER(c.lastnameReferent) as clastnameReferent, "
"c.company as ccompany, c.complementAddress as ccomplement, "
"c.website as cwebsite, "
"c.address as caddress, c.postalCode as cpostalcode, "
"c.city as ccity, c.country as ccountry, c.email as cemail, "
"c.phone as cphone, c.mobilephone as cmobilephone, c.fax as cfax, "
"c.isArchived as cisArchived "
"FROM Customer c "+filter+" "
"ORDER BY 4, 3"
);

if(!q.exec()) {
throw new DbException(
Expand Down Expand Up @@ -148,7 +149,7 @@ throw(DbException*)

QStandardItem *CustomerDatabase::getItemRoot() {
QStandardItem* itemRoot = new QStandardItem("Tous les clients");
itemRoot->setIcon(QIcon(":icons/img/all_customers.png"));
itemRoot->setIcon(QIcon(":/icons/all_customers"));
return itemRoot;
}

Expand Down Expand Up @@ -263,11 +264,12 @@ QSharedPointer<Models::Customer> CustomerDatabase::getCustomer(const int pId) {

q.prepare("SELECT DISTINCT c.idCustomer as cidcustomer, "
"c.firstnameReferent as cfirstnameReferent, "
"c.lastnameReferent as clastnameReferent, c.company as ccompany, "
"UPPER(c.lastnameReferent) as clastnameReferent, "
"c.company as ccompany, "
"c.address as caddress, c.postalCode as cpostalcode, "
"c.city as ccity, c.country as ccountry, c.email as cemail, "
"c.phone as cphone, c.mobilephone as cmobilephone, c.fax as cfax, "
"c.complementAddress as ccomplement, c.website as cwebsite, "
"c.complementAddress as ccomplement, c.website as cwebsite,"
"c.isArchived as cisArchived "
"FROM Customer c "
"WHERE idCustomer = :pId");
Expand Down
5 changes: 3 additions & 2 deletions src/models/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ void Search::filterOnCustomersWithoutProject(
QString &filter, const QStringList list)
{
filter +=
" UNION "
" UNION "
"SELECT DISTINCT c.idCustomer as cidcustomer, "
"c.firstnameReferent as cfirstnameReferent, "
"UPPER(c.lastnameReferent) as clastnameReferent, "
"c.company as ccompany, c.complementAddress as ccomplement, c.website as cwebsite, "
"c.company as ccompany, c.complementAddress as ccomplement, "
"c.website as cwebsite, "
"c.address as caddress, c.postalCode as cpostalcode, "
"c.city as ccity, c.country as ccountry, c.email as cemail, "
"c.phone as cphone, c.mobilephone as cmobilephone, c.fax as cfax, "
Expand Down

0 comments on commit 4881efe

Please sign in to comment.