diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php
index 36b9f3a8b93..e70bc39bfd0 100644
--- a/htdocs/accountancy/admin/card.php
+++ b/htdocs/accountancy/admin/card.php
@@ -426,11 +426,9 @@ if ($action == 'create') {
print ''.$langs->trans('Modify').'';
}
- if ($user->hasRight('accounting', 'chartofaccount')) {
- print 'id.'">'.$langs->trans('Delete').'';
- } else {
- print ''.$langs->trans('Delete').'';
- }
+ // Delete
+ $permissiontodelete = $user->hasRight('accounting', 'chartofaccount');
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
print '';
}
diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php
index 89ed7b538ba..38330a37e13 100644
--- a/htdocs/accountancy/admin/fiscalyear_card.php
+++ b/htdocs/accountancy/admin/fiscalyear_card.php
@@ -305,7 +305,7 @@ if ($action == 'create') {
print ''.$langs->trans('Modify').'';
- // print '' . $langs->trans('Delete') . '';
+ //print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
print '';
}
diff --git a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
index 4b0eed154c0..14da758457f 100644
--- a/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
+++ b/htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
@@ -133,7 +133,7 @@ if (empty($user->socid)) {
}
if ($user->rights->adherent->supprimer) {
- echo 'control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas.'">'.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$this->control->tpl['id'].'&action=delete&token='.newToken().'&canvas='.$canvas, 'delete', $user->rights->adherent->supprimer);
}
echo '
';
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index 4c80627d70e..74373d95eda 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -142,31 +142,31 @@ if ($db->type == 'pgsql') {
unset($fieldstosearchall['d.rowid']);
}
$arrayfields = array(
- 'd.ref'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
- 'd.civility'=>array('label'=>$langs->trans("Civility"), 'checked'=>0),
- 'd.lastname'=>array('label'=>$langs->trans("Lastname"), 'checked'=>1),
- 'd.firstname'=>array('label'=>$langs->trans("Firstname"), 'checked'=>1),
- 'd.gender'=>array('label'=>$langs->trans("Gender"), 'checked'=>0),
- 'd.company'=>array('label'=>$langs->trans("Company"), 'checked'=>1),
- 'd.login'=>array('label'=>$langs->trans("Login"), 'checked'=>1),
- 'd.morphy'=>array('label'=>$langs->trans("MemberNature"), 'checked'=>1),
- 't.libelle'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
- 'd.email'=>array('label'=>$langs->trans("Email"), 'checked'=>1),
- 'd.address'=>array('label'=>$langs->trans("Address"), 'checked'=>0),
- 'd.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0),
- 'd.town'=>array('label'=>$langs->trans("Town"), 'checked'=>0),
- 'd.phone'=>array('label'=>$langs->trans("Phone"), 'checked'=>0),
- 'd.phone_perso'=>array('label'=>$langs->trans("PhonePerso"), 'checked'=>0),
- 'd.phone_mobile'=>array('label'=>$langs->trans("PhoneMobile"), 'checked'=>0),
- 'state.nom'=>array('label'=>$langs->trans("State"), 'checked'=>0),
- 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
- /*'d.note_public'=>array('label'=>$langs->trans("NotePublic"), 'checked'=>0),
- 'd.note_private'=>array('label'=>$langs->trans("NotePrivate"), 'checked'=>0),*/
- 'd.datefin'=>array('label'=>$langs->trans("EndSubscription"), 'checked'=>1, 'position'=>500),
- 'd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'd.birth'=>array('label'=>$langs->trans("Birthday"), 'checked'=>0, 'position'=>500),
- 'd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
- 'd.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+ 'd.ref'=>array('label'=>"Ref", 'checked'=>1),
+ 'd.civility'=>array('label'=>"Civility", 'checked'=>0),
+ 'd.lastname'=>array('label'=>"Lastname", 'checked'=>1),
+ 'd.firstname'=>array('label'=>"Firstname", 'checked'=>1),
+ 'd.gender'=>array('label'=>"Gender", 'checked'=>0),
+ 'd.company'=>array('label'=>"Company", 'checked'=>1),
+ 'd.login'=>array('label'=>"Login", 'checked'=>1),
+ 'd.morphy'=>array('label'=>"MemberNature", 'checked'=>1),
+ 't.libelle'=>array('label'=>"Type", 'checked'=>1),
+ 'd.email'=>array('label'=>"Email", 'checked'=>1),
+ 'd.address'=>array('label'=>"Address", 'checked'=>0),
+ 'd.zip'=>array('label'=>"Zip", 'checked'=>0),
+ 'd.town'=>array('label'=>"Town", 'checked'=>0),
+ 'd.phone'=>array('label'=>"Phone", 'checked'=>0),
+ 'd.phone_perso'=>array('label'=>"PhonePerso", 'checked'=>0),
+ 'd.phone_mobile'=>array('label'=>"PhoneMobile", 'checked'=>0),
+ 'state.nom'=>array('label'=>"State", 'checked'=>0),
+ 'country.code_iso'=>array('label'=>"Country", 'checked'=>0),
+ /*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
+ 'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
+ 'd.datefin'=>array('label'=>"EndSubscription", 'checked'=>1, 'position'=>500),
+ 'd.datec'=>array('label'=>"DateCreation", 'checked'=>0, 'position'=>500),
+ 'd.birth'=>array('label'=>"Birthday", 'checked'=>0, 'position'=>500),
+ 'd.tms'=>array('label'=>"DateModificationShort", 'checked'=>0, 'position'=>500),
+ 'd.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
'd.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
);
// Extra fields
@@ -350,27 +350,43 @@ $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d";
if (!empty($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 (d.rowid = ef.fk_object)";
}
-if ((!empty($search_categ) && ($search_categ > 0 || $search_categ == -2)) || !empty($catid)) {
- // We need this table joined to the select in order to filter by categ
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_member as cm ON d.rowid = cm.fk_member";
-}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = d.country)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as state on (state.rowid = d.state_id)";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on (s.rowid = d.fk_soc)";
$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE d.fk_adherent_type = t.rowid";
-if ($catid > 0) {
- $sql .= " AND cm.fk_categorie = ".((int) $catid);
+
+if ($catid && empty($search_categ)) {
+ $search_categ = $catid;
}
-if ($catid == -2) {
- $sql .= " AND cm.fk_categorie IS NULL";
-}
-if ($search_categ > 0) {
- $sql .= " AND cm.fk_categorie = ".((int) $search_categ);
-}
-if ($search_categ == -2) {
- $sql .= " AND cm.fk_categorie IS NULL";
+
+$searchCategoryContactList = $search_categ ? array($search_categ) : array();
+$searchCategoryContactOperator = 0;
+// Search for tag/category ($searchCategoryContactList is an array of ID)
+if (!empty($searchCategoryContactList)) {
+ $searchCategoryContactSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryContactList as $searchCategoryContact) {
+ if (intval($searchCategoryContact) == -2) {
+ $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member)";
+ } elseif (intval($searchCategoryContact) > 0) {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_categorie FROM ".MAIN_DB_PREFIX."categorie_member as ck WHERE d.rowid = ck.fk_member AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryContactOperator == 1) {
+ if (!empty($searchCategoryContactSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryContactSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
+ }
+ }
}
+
$sql .= " AND d.entity IN (".getEntity('adherent').")";
if ($sall) {
$sql .= natural_search(array_keys($fieldstosearchall), $sall);
@@ -391,7 +407,7 @@ if ($search_status != '') {
// Peut valoir un nombre ou liste de nombre separes par virgules
$sql .= " AND d.statut in (".$db->sanitize($db->escape($search_status)).")";
}
-if ($search_morphy != '') {
+if ($search_morphy != '' && $search_morphy != '-1') {
$sql .= natural_search("d.morphy", $search_morphy);
}
if ($search_ref) {
@@ -670,7 +686,7 @@ $moreforfilter = '';
if (isModEnabled('categorie') && $user->rights->categorie->lire) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$moreforfilter .= '
';
- $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1);
+ $moreforfilter .= img_picto($langs->trans('Categories'), 'category', 'class="pictofixedlength"').$formother->select_categories(Categorie::TYPE_MEMBER, $search_categ, 'search_categ', 1, $langs->trans("MembersCategoriesShort"));
$moreforfilter .= '
';
}
$parameters = array();
@@ -741,10 +757,11 @@ if (!empty($arrayfields['d.login']['checked'])) {
print '';
print ' | ';
}
+// Nature
if (!empty($arrayfields['d.morphy']['checked'])) {
- print '';
+ print ' | ';
$arraymorphy = array('mor'=>$langs->trans("Moral"), 'phy'=>$langs->trans("Physical"));
- print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1);
+ print $form->selectarray('search_morphy', $arraymorphy, $search_morphy, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
print ' | ';
}
if (!empty($arrayfields['t.libelle']['checked'])) {
diff --git a/htdocs/admin/bank_extrafields.php b/htdocs/admin/bank_extrafields.php
index 3626eec4455..d01ac5a93e9 100644
--- a/htdocs/admin/bank_extrafields.php
+++ b/htdocs/admin/bank_extrafields.php
@@ -65,18 +65,21 @@ require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
* View
*/
-$textobject = $langs->transnoentitiesnoconv("Bank");
+$help_url = '';
+$page_name = "BankSetupModule";
llxHeader('', $langs->trans("BankSetupModule"), $help_url);
$linkback = ''.$langs->trans("BackToModuleList").'';
-print load_fiche_titre($langs->trans("BankSetupModule"), $linkback, 'title_setup');
+print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup');
$head = bank_admin_prepare_head(null);
-print dol_get_fiche_head($head, 'attributes', $langs->trans("BankSetupModule"), -1, 'account');
+print dol_get_fiche_head($head, 'attributes', $langs->trans($page_name), -1, 'account');
+
+$textobject = $langs->transnoentitiesnoconv("Bank");
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
diff --git a/htdocs/admin/bankline_extrafields.php b/htdocs/admin/bankline_extrafields.php
index 06f1267343a..7e451275f8d 100644
--- a/htdocs/admin/bankline_extrafields.php
+++ b/htdocs/admin/bankline_extrafields.php
@@ -22,7 +22,7 @@
*/
/**
- * \file admin/bankline_extrafields.php
+ * \file htdocs/admin/bankline_extrafields.php
* \ingroup bank
* \brief Page to setup extra fields of bankline
*/
@@ -41,7 +41,7 @@ $form = new Form($db);
// List of supported format
$tmptype2label = ExtraFields::$type2label;
-$type2label = [];
+$type2label = array();
foreach ($tmptype2label as $key => $val) {
$type2label[$key] = $langs->transnoentitiesnoconv($val);
}
@@ -80,6 +80,8 @@ $head = bank_admin_prepare_head(null);
print dol_get_fiche_head($head, 'bankline_extrafields', $langs->trans($page_name), -1, 'account');
+$textobject = $langs->transnoentitiesnoconv("BankTransaction");
+
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
print dol_get_fiche_end();
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index 45f90101adc..5e00c2d2433 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -307,7 +307,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords++;
}*/
/* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
$resql = $db->query($sqlforcount);
$objforcount = $db->fetch_object($resql);
$nbtotalofrecords = $objforcount->nbtotalofrecords;
diff --git a/htdocs/asset/model/list.php b/htdocs/asset/model/list.php
index 1d85a982e5d..aa80b4e5426 100644
--- a/htdocs/asset/model/list.php
+++ b/htdocs/asset/model/list.php
@@ -307,7 +307,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords = $db->num_rows($result);
*/
/* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
$resql = $db->query($sqlforcount);
if ($resql) {
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 09d2b2bcb9d..926797d1f07 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -704,7 +704,7 @@ if (empty($reshook)) {
// Clone
if ($permissiontoadd) {
- print ''.$langs->trans("ToClone").''."\n";
+ print dolGetButtonAction($langs->trans("ToClone"), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=bom', 'clone', $permissiontoadd);
}
// Close / Cancel
@@ -726,11 +726,8 @@ if (empty($reshook)) {
}
*/
- if ($permissiontodelete) {
- print 'id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').''."\n";
- } else {
- print ''.$langs->trans('Delete').''."\n";
- }
+ // Delete
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
}
print ''."\n";
}
diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php
index 797bffa187a..d5258ba26f1 100644
--- a/htdocs/bookmarks/bookmarks.lib.php
+++ b/htdocs/bookmarks/bookmarks.lib.php
@@ -60,7 +60,7 @@ function printDropdownBookmarksList()
if ($sortorder) {
$tmpurl .= ($tmpurl ? '&' : '').'sortorder='.urlencode($sortorder);
}
- if (is_array($_POST)) {
+ if (!empty($_POST) && is_array($_POST)) {
foreach ($_POST as $key => $val) {
if ((preg_match('/^search_/', $key) || in_array($key, $authorized_var))
&& $val != ''
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 2c008202348..590d1bafe17 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -1865,7 +1865,7 @@ if ($id > 0) {
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION)) {
- print '| '.$langs->trans("Location").' | |
';
+ print '| '.$langs->trans("Location").' | |
';
}
// Status
@@ -1997,7 +1997,7 @@ if ($id > 0) {
print '';
// Reminders
- if ($conf->global->AGENDA_REMINDER_EMAIL || $conf->global->AGENDA_REMINDER_BROWSER) {
+ if (getDolGlobalString('AGENDA_REMINDER_EMAIL') || getDolGlobalString('AGENDA_REMINDER_BROWSER')) {
$filteruserid = $user->id;
if ($user->rights->agenda->allactions->read) {
$filteruserid = 0;
diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php
index a5aca966530..4532e49b622 100644
--- a/htdocs/comm/action/list.php
+++ b/htdocs/comm/action/list.php
@@ -573,7 +573,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$nbtotalofrecords++;
}*/
/* The fast and low memory method to get and count full list converts the sql into a sql count */
- $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
$resql = $db->query($sqlforcount);
$objforcount = $db->fetch_object($resql);
$nbtotalofrecords = $objforcount->nbtotalofrecords;
diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php
index 76cc9b23f27..f835ae3ae29 100644
--- a/htdocs/comm/propal/card.php
+++ b/htdocs/comm/propal/card.php
@@ -2933,10 +2933,7 @@ if ($action == 'create') {
}
// Delete
- if ($usercandelete) {
- print 'id.'&action=delete&token='.newToken().'"';
- print '>'.$langs->trans('Delete').'';
- }
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $usercandelete);
}
}
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 9428f76dd8e..2afc01914e0 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -2899,7 +2899,7 @@ if ($action == 'create' && $usercancreate) {
// Delete order
if ($usercandelete) {
if ($numshipping == 0) {
- print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '');
+ print dolGetButtonAction('', $langs->trans('Delete'), 'delete', $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id, '');
} else {
print dolGetButtonAction($langs->trans('ShippingExist'), $langs->trans('Delete'), 'default', $_SERVER['PHP_SELF']. '#', '', false);
}
diff --git a/htdocs/compta/deplacement/card.php b/htdocs/compta/deplacement/card.php
index f8e5f3ba03b..e7929a12697 100644
--- a/htdocs/compta/deplacement/card.php
+++ b/htdocs/compta/deplacement/card.php
@@ -492,11 +492,8 @@ if ($action == 'create') {
}
}
- if ($user->rights->deplacement->supprimer) {
- print ''.$langs->trans('Delete').'';
- } else {
- print ''.$langs->trans('Delete').'';
- }
+ $permissiontodelete = $user->rights->deplacement->supprimer;
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
print '';
}
diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php
index 33b85f707e9..2a15c74c948 100644
--- a/htdocs/compta/facture/card-rec.php
+++ b/htdocs/compta/facture/card-rec.php
@@ -1677,10 +1677,8 @@ if ($action == 'create') {
}
}
- //if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer)
- if ($user->rights->facture->supprimer) {
- print '';
- }
+ // Delete
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->facture->supprimer);
print '';
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index b5e756ebb19..3e3ada6e8cf 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -5744,8 +5744,7 @@ if ($action == 'create') {
}
print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $deleteHref, '', $enableDelete, $params);
} else {
- $params['attr']['title'] = $langs->trans('NotAllowed');
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false, $params);
+ print dolGetButtonAction($langs->trans('Delete'), '', 'delete', '#', '', false);
}
}
print '';
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 1d6dbd9f03b..02517537bdf 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -869,9 +869,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
*/
/* The fast and low memory method to get and count full list converts the sql into a sql count */
if ($sall || $search_product_category > 0 || $search_user > 0) {
- $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(DISTINCT f.rowid) as nbtotalofrecords FROM', $sql);
} else {
- $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(f.rowid) as nbtotalofrecords FROM', $sql);
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON pf.fk_facture = f.rowid/', '', $sqlforcount);
}
$sqlforcount = preg_replace('/GROUP BY.*$/', '', $sqlforcount);
diff --git a/htdocs/compta/paiement/card.php b/htdocs/compta/paiement/card.php
index 89ee368b7d5..58a27c94974 100644
--- a/htdocs/compta/paiement/card.php
+++ b/htdocs/compta/paiement/card.php
@@ -520,13 +520,7 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) {
}
if ($user->socid == 0 && $action == '') {
- if ($user->rights->facture->paiement) {
- if (!$disable_delete) {
- print ''.$langs->trans('Delete').'';
- } else {
- print ''.$langs->trans('Delete').'';
- }
- }
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->rights->facture->paiement && !$disable_delete);
}
print '';
diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php
index 7b3eaceab3a..f28ebf2ebcf 100644
--- a/htdocs/compta/paiement/cheque/card.php
+++ b/htdocs/compta/paiement/cheque/card.php
@@ -82,6 +82,7 @@ $usercanread = $user->rights->banque->cheque;
$usercancreate = $user->rights->banque->cheque;
$usercandelete = $user->rights->banque->cheque;
+$permissiontodelete = $user->rights->banque->cheque;
/*
@@ -750,7 +751,7 @@ if ($user->socid == 0 && !empty($object->id) && $object->statut == 0 && $user->r
}
if ($user->socid == 0 && !empty($object->id) && $user->rights->banque->cheque) {
- print 'id.'&action=delete&token='.newToken().'&sortfield='.$sortfield.'&sortorder='.$sortorder.'">'.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
}
print '';
diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php
index 1d93075bc5b..39bac75ba0c 100644
--- a/htdocs/compta/payment_sc/card.php
+++ b/htdocs/compta/payment_sc/card.php
@@ -253,9 +253,9 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
if ($action == '') {
if ($user->rights->tax->charges->supprimer) {
if (!$disable_delete) {
- print ''.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
} else {
- print ''.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("CantRemovePaymentWithOneInvoicePaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
}
}
}
diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php
index 8beeaa1f229..6089f9dbcb5 100644
--- a/htdocs/compta/payment_vat/card.php
+++ b/htdocs/compta/payment_vat/card.php
@@ -308,9 +308,9 @@ if (!empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
if ($action == '') {
if ($user->rights->tax->charges->supprimer) {
if (!$disable_delete) {
- print ''.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 1);
} else {
- print ''.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("CantRemovePaymentVATPaid"), $langs->trans("Delete"), 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', 0);
}
}
}
diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example
index 05c29459ee2..1cc028ff137 100644
--- a/htdocs/conf/conf.php.example
+++ b/htdocs/conf/conf.php.example
@@ -409,7 +409,6 @@ $dolibarr_cron_allow_cli='0';
//#################################
// Value to overwrite path to use shared libraries instead of embedded one
-//$dolibarr_lib_ADODB_PATH='/usr/share/php/adodb';
//$dolibarr_lib_TCPDF_PATH='/usr/share/php/tcpdf';
//$dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi';
//$dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf';
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 11aebc8fc29..fbe8b4d0c04 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1579,7 +1579,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
// Delete
if ($user->rights->societe->contact->supprimer) {
- print ''.$langs->trans('Delete').'';
+ print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().($backtopage ? '&backtopage='.urlencode($backtopage) : ''), 'delete', $user->rights->societe->contact->supprimer);
}
}
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index d165a0a4cc1..8f4c59bb2f8 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -399,15 +399,6 @@ if (isset($extrafields->attributes[$object->table_element]['label']) && is_array
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
-if (!empty($search_categ) && $search_categ != '-1') {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
-}
-if (!empty($search_categ_thirdparty) && $search_categ_thirdparty != '-1') {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
-}
-if (!empty($search_categ_supplier) && $search_categ_supplier != '-1') {
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
-}
if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
}
@@ -437,23 +428,83 @@ if ($search_priv != '0' && $search_priv != '1') {
}
}
-if ($search_categ > 0) {
- $sql .= " AND cc.fk_categorie = ".((int) $search_categ);
+$searchCategoryContactList = $search_categ ? array($search_categ) : array();
+$searchCategoryContactOperator = 0;
+// Search for tag/category ($searchCategoryContactList is an array of ID)
+if (!empty($searchCategoryContactList)) {
+ $searchCategoryContactSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryContactList as $searchCategoryContact) {
+ if (intval($searchCategoryContact) == -2) {
+ $searchCategoryContactSqlList[] = "NOT EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople)";
+ } elseif (intval($searchCategoryContact) > 0) {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryContact);
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryContactSqlList[] = " EXISTS (SELECT ck.fk_socpeople FROM ".MAIN_DB_PREFIX."categorie_contact as ck WHERE s.rowid = ck.fk_socpeople AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryContactOperator == 1) {
+ if (!empty($searchCategoryContactSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryContactSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryContactSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryContactSqlList).")";
+ }
+ }
}
-if ($search_categ == -2) {
- $sql .= " AND cc.fk_categorie IS NULL";
+$searchCategoryCustomerList = $search_categ_thirdparty ? array($search_categ_thirdparty) : array();
+$searchCategoryCustomerOperator = 0;
+// Search for tag/category ($searchCategoryCustomerList is an array of ID)
+if (!empty($searchCategoryCustomerList)) {
+ $searchCategoryCustomerSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
+ if (intval($searchCategoryCustomer) == -2) {
+ $searchCategoryCustomerSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc)";
+ } elseif (intval($searchCategoryCustomer) > 0) {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryCustomer);
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategoryCustomerSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategoryCustomerOperator == 1) {
+ if (!empty($searchCategoryCustomerSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategoryCustomerSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategoryCustomerSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategoryCustomerSqlList).")";
+ }
+ }
}
-if ($search_categ_thirdparty > 0) {
- $sql .= " AND cs.fk_categorie = ".((int) $search_categ_thirdparty);
-}
-if ($search_categ_thirdparty == -2) {
- $sql .= " AND cs.fk_categorie IS NULL";
-}
-if ($search_categ_supplier > 0) {
- $sql .= " AND cs2.fk_categorie = ".((int) $search_categ_supplier);
-}
-if ($search_categ_supplier == -2) {
- $sql .= " AND cs2.fk_categorie IS NULL";
+$searchCategorySupplierList = $search_categ_supplier ? array($search_categ_supplier) : array();
+$searchCategorySupplierOperator = 0;
+// Search for tag/category ($searchCategorySupplierList is an array of ID)
+if (!empty($searchCategorySupplierList)) {
+ $searchCategorySupplierSqlList = array();
+ $listofcategoryid = '';
+ foreach ($searchCategorySupplierList as $searchCategorySupplier) {
+ if (intval($searchCategorySupplier) == -2) {
+ $searchCategorySupplierSqlList[] = "NOT EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc)";
+ } elseif (intval($searchCategorySupplier) > 0) {
+ $listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategorySupplier);
+ }
+ }
+ if ($listofcategoryid) {
+ $searchCategorySupplierSqlList[] = " EXISTS (SELECT ck.fk_soc FROM ".MAIN_DB_PREFIX."categorie_fournisseur as ck WHERE s.rowid = ck.fk_soc AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
+ }
+ if ($searchCategorySupplierOperator == 1) {
+ if (!empty($searchCategorySupplierSqlList)) {
+ $sql .= " AND (".implode(' OR ', $searchCategorySupplierSqlList).")";
+ }
+ } else {
+ if (!empty($searchCategorySupplierSqlList)) {
+ $sql .= " AND (".implode(' AND ', $searchCategorySupplierSqlList).")";
+ }
+ }
}
if ($sall) {
@@ -1222,7 +1273,7 @@ while ($i < min($num, $limit)) {
if (isModEnabled('socialnetworks')) {
foreach ($socialnetworks as $key => $value) {
if ($value['active'] && !empty($arrayfields['p.'.$key]['checked'])) {
- print ''.dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks).' | ';
+ print ''.(empty($arraysocialnetworks[$key]) ? '' : dol_print_socialnetworks($arraysocialnetworks[$key], $obj->rowid, $obj->socid, $key, $socialnetworks)).' | ';
if (!$i) {
$totalarray['nbfield']++;
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 068feb1645d..4c6c07da2cb 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -97,6 +97,7 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem
$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
+$permissiontodelete = ($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer;
$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontoedit = $permissiontoadd;
$error = 0;
@@ -2203,15 +2204,8 @@ if ($action == 'create') {
print dolGetButtonAction($langs->trans('ToClone'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&token='.newToken(), '', true, $params);
}
- // On peut supprimer entite si
- // - Droit de creer + mode brouillon (erreur creation)
- // - Droit de supprimer
- if (($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer) {
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', true, $params);
- } else {
- $params['attr']['title'] = $langs->trans("NotAllowed");
- print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', false, $params);
- }
+ // Delete
+ print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), '', $permissiontodelete, $params);
}
print "";
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index 8c24c4e65ee..e8267f85d58 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -376,7 +376,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
}
}
} else {
- $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+ $sqlforcount = preg_replace('/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'contratdet as cd ON c.rowid = cd.fk_contrat/', '', $sqlforcount);
$sqlforcount = preg_replace('/LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product/', '', $sqlforcount);
$sqlforcount = preg_replace('/AND cp.fk_categorie = '.((int) $search_product_category).'/', '', $sqlforcount);
diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index de586e80e9f..9a2eda2df8e 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -41,6 +41,9 @@ if (empty($objectclass) || empty($uploaddir)) {
dol_print_error(null, 'include of actions_massactions.inc.php is done but var $objectclass or $uploaddir was not defined');
exit;
}
+if (empty($massaction)) {
+ $massaction = '';
+}
// For backward compatibility
if (!empty($permtoread) && empty($permissiontoread)) {
@@ -53,14 +56,13 @@ if (!empty($permtodelete) && empty($permissiontodelete)) {
$permissiontodelete = $permtodelete;
}
-
// Mass actions. Controls on number of lines checked.
$maxformassaction = (empty($conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS) ? 1000 : $conf->global->MAIN_LIMIT_FOR_MASS_ACTIONS);
-if (!empty($massaction) && is_array($toselect) && count($toselect) < 1) {
+if ($massaction && is_array($toselect) && count($toselect) < 1) {
$error++;
setEventMessages($langs->trans("NoRecordSelected"), null, "warnings");
}
-if (!$error && is_array($toselect) && count($toselect) > $maxformassaction) {
+if (!$error && isset($toselect) && is_array($toselect) && count($toselect) > $maxformassaction) {
setEventMessages($langs->trans('TooManyRecordForMassAction', $maxformassaction), null, 'errors');
$error++;
}
@@ -1564,7 +1566,7 @@ if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday
}
}
-$parameters['toselect'] = $toselect;
+$parameters['toselect'] = (empty($toselect) ? array() : $toselect);
$parameters['uploaddir'] = $uploaddir;
$parameters['massaction'] = $massaction;
$parameters['diroutputmassaction'] = isset($diroutputmassaction) ? $diroutputmassaction : null;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8eb357a3908..7224949a70b 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4345,7 +4345,7 @@ abstract class CommonObject
}
/**
- * Set status of an object
+ * Set status of an object.
*
* @param int $status Status to set
* @param int $elementId Id of element to force (use this->id by default if null)
diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php
index 38ec91ff143..61737ab00f3 100644
--- a/htdocs/core/class/html.formmargin.class.php
+++ b/htdocs/core/class/html.formmargin.class.php
@@ -108,7 +108,7 @@ class FormMargin
// calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
- if ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '1') { // remise globale considérée comme produit
+ if (getDolGlobalString('MARGIN_METHODE_FOR_DISCOUNT') == '1') { // remise globale considérée comme produit
$marginInfos['pa_products'] += $pa;
$marginInfos['pv_products'] += $pv;
$marginInfos['pa_total'] += $pa;
@@ -120,7 +120,7 @@ class FormMargin
//}
//else
$marginInfos['margin_on_products'] += $pv - $pa;
- } elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '2') { // remise globale considérée comme service
+ } elseif (getDolGlobalString('MARGIN_METHODE_FOR_DISCOUNT') == '2') { // remise globale considérée comme service
$marginInfos['pa_services'] += $pa;
$marginInfos['pv_services'] += $pv;
$marginInfos['pa_total'] += $pa;
@@ -130,7 +130,7 @@ class FormMargin
// $marginInfos['margin_on_services'] += -1 * (abs($pv) - $pa);
//else
$marginInfos['margin_on_services'] += $pv - $pa;
- } elseif ($conf->global->MARGIN_METHODE_FOR_DISCOUNT == '3') { // remise globale prise en compte uniqt sur total
+ } elseif (getDolGlobalString('MARGIN_METHODE_FOR_DISCOUNT') == '3') { // remise globale prise en compte uniqt sur total
$marginInfos['pa_total'] += $pa;
$marginInfos['pv_total'] += $pv;
}
diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php
index c6a6826251f..ed4b56be831 100644
--- a/htdocs/core/class/html.formwebsite.class.php
+++ b/htdocs/core/class/html.formwebsite.class.php
@@ -231,6 +231,8 @@ class FormWebsite
*/
public function selectContainer($website, $htmlname = 'pageid', $pageid = 0, $showempty = 0, $action = '', $morecss = 'minwidth200', $excludeids = null)
{
+ global $conf, $langs;
+
$this->num = 0;
$atleastonepage = (is_array($website->lines) && count($website->lines) > 0);
@@ -239,13 +241,18 @@ class FormWebsite
if ($atleastonepage && $action != 'editsource') {
$out .= '