diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 3db5ef13ef5..5e27f41c47a 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1857,7 +1857,7 @@ if ($step == 5 && $datatoimport) { //dol_syslog("line ".$sourcelinenb.' - '.$nboflines.' - '.$excludefirstline.' - '.$endatlinenb); $arrayrecord = $obj->import_read_record(); if ($arrayrecord === false) { - $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines. Ensure the complete string is delimited correctly when there is a separator character in the text string.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); + $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach the end of file or an empty line at record '.$sourcelinenb.'. This may occurs when some records are split onto several lines and not correctly delimited by the "Char delimiter", or if there is line with no data on all fields.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); $endoffile++; continue; } @@ -2242,7 +2242,7 @@ if ($step == 6 && $datatoimport) { $sourcelinenb++; $arrayrecord = $obj->import_read_record(); if ($arrayrecord === false) { - $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach end of file after record '.$sourcelinenb.'. This may occurs when some records are split onto several lines.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); + $arrayofwarnings[$sourcelinenb][0] = array('lib'=>'File has '.$nboflines.' lines. However we reach the end of file or an empty line at record '.$sourcelinenb.'. This may occurs when some records are split onto several lines and not correctly delimited by the "Char delimiter", or if there is line with no data on all fields.', 'type'=>'EOF_RECORD_ON_SEVERAL_LINES'); $endoffile++; continue; } diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index 84cd1b5665c..874dcb66f1b 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -178,3 +178,8 @@ ALTER TABLE llx_element_categorie ADD UNIQUE INDEX idx_element_categorie_idx (fk ALTER TABLE llx_element_categorie ADD CONSTRAINT fk_element_categorie_fk_categorie FOREIGN KEY (fk_categorie) REFERENCES llx_categorie(rowid); INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('PROJECT_SENTBYMAIL','Project sent by mail','Executed when a project is sent by email','project',144); + +ALTER TABLE llx_socpeople ADD INDEX idx_socpeople_lastname (lastname); + +ALTER TABLE llx_societe ADD INDEX idx_societe_nom(nom); + diff --git a/htdocs/install/mysql/tables/llx_societe.key.sql b/htdocs/install/mysql/tables/llx_societe.key.sql index 3a2c9540229..58701e4a7f9 100644 --- a/htdocs/install/mysql/tables/llx_societe.key.sql +++ b/htdocs/install/mysql/tables/llx_societe.key.sql @@ -23,6 +23,8 @@ ALTER TABLE llx_societe ADD UNIQUE INDEX uk_societe_code_fournisseur(code_fourni ALTER TABLE llx_societe ADD UNIQUE INDEX uk_societe_barcode (barcode, fk_barcode_type, entity); +ALTER TABLE llx_societe ADD INDEX idx_societe_nom(nom); + ALTER TABLE llx_societe ADD INDEX idx_societe_user_creat(fk_user_creat); ALTER TABLE llx_societe ADD INDEX idx_societe_user_modif(fk_user_modif); diff --git a/htdocs/install/mysql/tables/llx_socpeople.key.sql b/htdocs/install/mysql/tables/llx_socpeople.key.sql index 4d2a453e0fa..36e2b7b7d1c 100644 --- a/htdocs/install/mysql/tables/llx_socpeople.key.sql +++ b/htdocs/install/mysql/tables/llx_socpeople.key.sql @@ -20,5 +20,7 @@ ALTER TABLE llx_socpeople ADD INDEX idx_socpeople_fk_soc (fk_soc); ALTER TABLE llx_socpeople ADD INDEX idx_socpeople_fk_user_creat (fk_user_creat); +ALTER TABLE llx_socpeople ADD INDEX idx_socpeople_lastname (lastname); + ALTER TABLE llx_socpeople ADD CONSTRAINT fk_socpeople_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); ALTER TABLE llx_socpeople ADD CONSTRAINT fk_socpeople_user_creat_user_rowid FOREIGN KEY (fk_user_creat) REFERENCES llx_user (rowid); diff --git a/htdocs/knowledgemanagement/knowledgerecord_list.php b/htdocs/knowledgemanagement/knowledgerecord_list.php index daa0d7b148d..d9fc25fa1fe 100644 --- a/htdocs/knowledgemanagement/knowledgerecord_list.php +++ b/htdocs/knowledgemanagement/knowledgerecord_list.php @@ -246,9 +246,6 @@ $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; if (!empty($extrafields->attributes[$object->table_element]['label']) && is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; } -if (!empty($searchCategoryKnowledgemanagementList) || !empty($catid)) { - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_knowledgemanagement as ck ON t.rowid = ck.fk_knowledgemanagement"; // We'll need this table joined to the select in order to filter by categ -} // Add table from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook @@ -287,29 +284,29 @@ foreach ($search as $key => $val) { } } } -//Search for tag/category -$searchCategoryKnowledgemanagementSqlList = array(); -if ($searchCategoryKnowledgemanagementOperator == 1) { + +// Search for tag/category ($searchCategoryKnowledgemanagementList is an array of ID) +if (!empty($searchCategoryKnowledgemanagementList)) { + $searchCategoryKnowledgemanagementSqlList = array(); + $listofcategoryid = ''; foreach ($searchCategoryKnowledgemanagementList as $searchCategoryKnowledgemanagement) { if (intval($searchCategoryKnowledgemanagement) == -2) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie IS NULL"; + $searchCategoryKnowledgemanagementSqlList[] = "NOT EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement)"; } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie = ".$db->escape($searchCategoryKnowledgemanagement); + $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryKnowledgemanagement); } } - if (!empty($searchCategoryKnowledgemanagementSqlList)) { - $sql .= " AND (".implode(' OR ', $searchCategoryKnowledgemanagementSqlList).")"; + if ($listofcategoryid) { + $searchCategoryKnowledgemanagementSqlList[] = " EXISTS (SELECT ck.fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement as ck WHERE t.rowid = ck.fk_knowledgemanagement AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))"; } -} else { - foreach ($searchCategoryKnowledgemanagementList as $searchCategoryKnowledgemanagement) { - if (intval($searchCategoryKnowledgemanagement) == -2) { - $searchCategoryKnowledgemanagementSqlList[] = "ck.fk_categorie IS NULL"; - } elseif (intval($searchCategoryKnowledgemanagement) > 0) { - $searchCategoryKnowledgemanagementSqlList[] = "t.rowid IN (SELECT fk_knowledgemanagement FROM ".MAIN_DB_PREFIX."categorie_knowledgemanagement WHERE fk_categorie = ".((int) $searchCategoryKnowledgemanagement).")"; + if ($searchCategoryKnowledgemanagementOperator == 1) { + if (!empty($searchCategoryKnowledgemanagementSqlList)) { + $sql .= " AND (".implode(' OR ', $searchCategoryKnowledgemanagementSqlList).")"; + } + } else { + if (!empty($searchCategoryKnowledgemanagementSqlList)) { + $sql .= " AND (".implode(' AND ', $searchCategoryKnowledgemanagementSqlList).")"; } - } - if (!empty($searchCategoryKnowledgemanagementSqlList)) { - $sql .= " AND (".implode(' AND ', $searchCategoryKnowledgemanagementSqlList).")"; } }