Fix: Solve performance problems when having a lot of products

This commit is contained in:
Laurent Destailleur 2010-07-01 21:57:06 +00:00
parent 35f634837c
commit dd464ca055
6 changed files with 27 additions and 6 deletions

View File

@ -882,7 +882,15 @@ class Form
$sql.= " AND p.envente = ".$status;
}
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
// Add criteria on ref/label
if (empty($conf->global->PRODUCT_SEARCH_ANYWHERE))
{
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '".$ajaxkeysearch."%' OR p.label like '".$ajaxkeysearch."%')";
}
else
{
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
}
$sql.= $db->order("p.ref");
$sql.= $db->plimit($limit);
@ -1089,7 +1097,15 @@ class Form
if ($socid) $sql.= " AND pf.fk_soc = ".$socid;
if (strval($filtertype) != '') $sql.=" AND p.fk_product_type=".$filtertype;
if (! empty($filtre)) $sql.=" ".$filtre;
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (pf.ref_fourn like '%".$ajaxkeysearch."%' OR p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
// Add criteria on ref/label
if (empty($conf->global->PRODUCT_SEARCH_ANYWHERE))
{
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (pf.ref_fourn like '%".$ajaxkeysearch."%' OR p.ref like '%".$ajaxkeysearch."%' OR p.label like '%".$ajaxkeysearch."%')";
}
else
{
if ($ajaxkeysearch && $ajaxkeysearch != '') $sql.=" AND (pf.ref_fourn like '".$ajaxkeysearch."%' OR p.ref like '".$ajaxkeysearch."%' OR p.label like '".$ajaxkeysearch."%')";
}
$sql.= " ORDER BY pf.ref_fourn DESC";
dol_syslog("Form::select_produits_fournisseurs_do sql=".$sql,LOG_DEBUG);

View File

@ -7,6 +7,8 @@
--
ALTER TABLE llx_product ADD INDEX idx_product_label (label);
-- V4.1 DELETE FROM llx_projet_task WHERE fk_projet NOT IN (SELECT rowid from llx_projet);
-- V4.1 UPDATE llx_projet_task set fk_user_creat=NULL WHERE fk_user_creat IS NOT NULL AND fk_user_creat NOT IN (SELECT rowid from llx_user);
-- V4.1 UPDATE llx_projet_task set fk_user_valid=NULL WHERE fk_user_valid IS NOT NULL AND fk_user_valid NOT IN (SELECT rowid from llx_user);
@ -117,6 +119,8 @@ ALTER TABLE llx_expedition ADD COLUMN date_delivery date DEFAULT NULL AFTER date
ALTER TABLE llx_livraison change ref_client ref_customer varchar(30);
ALTER TABLE llx_livraison change date_livraison date_delivery date DEFAULT NULL;
ALTER TABLE llx_c_actioncomm MODIFY libelle varchar(48) NOT NULL;
ALTER TABLE llx_facture MODIFY tva double(24,8) DEFAULT 0;
ALTER TABLE llx_facture MODIFY total double(24,8) DEFAULT 0;
ALTER TABLE llx_facture MODIFY total_ttc double(24,8) DEFAULT 0;

View File

@ -1,6 +1,6 @@
-- ========================================================================
-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
-- Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
-- Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -24,7 +24,7 @@ create table llx_c_actioncomm
id integer PRIMARY KEY,
code varchar(12) UNIQUE NOT NULL,
type varchar(10) DEFAULT 'system' NOT NULL,
libelle varchar(30) NOT NULL,
libelle varchar(48) NOT NULL,
module varchar(16) DEFAULT NULL,
active tinyint DEFAULT 1 NOT NULL,
todo tinyint

View File

@ -23,5 +23,6 @@
ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_ref (ref, entity);
ALTER TABLE llx_product ADD INDEX idx_product_label (label);
ALTER TABLE llx_product ADD INDEX idx_product_barcode (barcode);
ALTER TABLE llx_product ADD INDEX idx_product_import_key (import_key);

View File

@ -598,7 +598,7 @@ BackToModuleList=Back to modules list
BackToDictionnaryList=Back to dictionaries list
VATReceivedOnly=Special rate not charged
VATManagement=VAT Management
VATIsUsedDesc=The VAT rate by default when creating prospects, invoices, orders etc follow the active standard rule:<br>If the seller is subjected to VAT, then VAT by default=0. End of rule.<br>If the (selling country= buying country), then the VAT by default=VAT of the product in the selling country. End of rule. <br>If seller and buyer in the European Community and goods are sold having new means of transport (car, ship, plane), the default VAT=0 ( The VAT should be paid by the buyer at the customoffice of his country and not at the seller). End of rule.<br>If seller and buyer in the European Community and goods sold by other means rather than new means of transport, then the VAT by default=VAT of product sold. End of rule.<br>Else the proposed default VAT=1. End of rule.
VATIsUsedDesc=The VAT rate by default when creating prospects, invoices, orders etc follow the active standard rule:<br>If the seller is subjected to VAT, then VAT by default=0. End of rule.<br>If the (selling country= buying country), then the VAT by default=VAT of the product in the selling country. End of rule. <br>If seller and buyer in the European Community and goods are transport products (car, ship, plane), the default VAT=0 ( The VAT should be paid by the buyer at the customoffice of his country and not at the seller). End of rule.<br>If seller and buyer in the European Community and buyer is not a company, then the VAT by default=VAT of product sold. End of rule.<br>If seller and buyer in the European Community and buyer is a company, then the VAT by default=0. End of rule.<br>Else the proposed default VAT=0. End of rule.
VATIsNotUsedDesc=By default the proposed VAT is 0 which can be used for cases like associations, individuals ou small companies.
VATIsUsedExampleFR=In France, it means companies or organisations having a real fiscal system (Simplified real or normal real). A system in which VAT is declared.
VATIsNotUsedExampleFR=In France, it means associations that are non VAT declared or companies, organisations or liberal professions that have chosen the micro enterprise fiscal system (VAT in franchise) and paid a franchise VAT without any VAT declaration. This choice will display the reference "Non applicable VAT - art-293B of CGI" on invoices.

View File

@ -609,7 +609,7 @@ BackToModuleList= Retour liste des modules
BackToDictionnaryList= Retour liste des dictionnaires
VATReceivedOnly= Taux spécial non facturé
VATManagement= Gestion TVA
VATIsUsedDesc= Le taux de TVA proposé par défaut lors de la création de propale, facture, commande, etc... répond à la règle standard suivante:<br>Si vendeur non assujetti à TVA, TVA par défaut=0. Fin de règle.<br>Si le (pays vendeur= pays acheteur) alors TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= particulier ou entreprise sans num TVA intra alors TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise avec num TVA intra alors TVA par défaut=0. Fin de règle.<br>Sinon TVA proposée par défaut=0. Fin de règle.<br>
VATIsUsedDesc= Le taux de TVA proposé par défaut lors de la création de propale, facture, commande, etc... répond à la règle standard suivante:<br>Si vendeur non assujetti à TVA, TVA par défaut=0. Fin de règle.<br>Si le (pays vendeur= pays acheteur) alors TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et bien vendu= moyen de transport neuf (auto, bateau, avion), TVA par défaut=0 (La TVA doit être payée par acheteur au centre d'impôts de son pays et non au vendeur). Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= particulier alors TVA par défaut=TVA du produit vendu. Fin de règle.<br>Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.<br>Sinon TVA proposée par défaut=0. Fin de règle.<br>
VATIsNotUsedDesc= Le taux de TVA proposé par défaut est 0. C'est le cas d'associations, particuliers ou certaines petites sociétés.
VATIsUsedExampleFR= En France, il s'agit des sociétés ou organismes ayant choisi un régime fiscale réel (Réel simplifié ou Réel normal), régime dans lequel la TVA est déclarée.
VATIsNotUsedExampleFR= En France, il s'agit des associations ne déclarant pas de TVA ou sociétés, organismes ou professions libérales ayant choisi le régime fiscal micro entreprise (TVA en franchise) et payant une TVA en franchise sans faire de déclaration de TVA. Ce choix fait de plus apparaitre la mention "TVA non applicable - art-293B du CGI" sur les factures.