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 ''.$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 ''.$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 ''.$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 '
'.$langs->trans('Delete').'
'; - } + // 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 ''.$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 .= ''; + $out .= ''; if (empty($object->records)) { $out .= ''; } - if (!empty($conf->use_javascript_ajax)) { - $valueoption = ''.img_picto('', 'add', 'class="paddingrightonly"').$langs->trans("AddWebsite").''; - $out .= ''; - } + // Loop on each sites $i = 0; foreach ($object->records as $key => $valwebsite) { @@ -2792,16 +2836,40 @@ if (!GETPOST('hide_websitemenu')) { } print $out; - if (empty($conf->use_javascript_ajax)) { - print ''; + print ''; + + // Switch offline/onine + if (!empty($conf->use_javascript_ajax)) { + print ''; + // Do not use ajax, we need a refresh of full page when we change status of a website + //print '
'; + //print ajax_object_onoff($object, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle', 'statuswebsite'); + //print '
'; + if ($website->status == $website::STATUS_DRAFT) { + $text_off = 'Offline'; + print 'ref).'&websitepage='.((int) $websitepage->id).'">'.img_picto($langs->trans($text_off), 'switch_off').''; + } else { + $text_off = 'Online'; + print 'ref).'&websitepage='.((int) $websitepage->id).'">'.img_picto($langs->trans($text_off), 'switch_on').''; + } + print '
'; } + // Refresh / Reload web site (for non javascript browers) + if (empty($conf->use_javascript_ajax)) { + print ''; + print ''; + print ''; + } + + + print ''; + if ($websitekey && $websitekey != '-1' && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite')) { - print '   '; - - //print ''; - print ''.dol_escape_htmltag($langs->trans("EditCss")).''; + // Edit website properties + print ''.dol_escape_htmltag($langs->trans("EditCss")).''; + // Import web site $importlabel = $langs->trans("ImportSite"); $exportlabel = $langs->trans("ExportSite"); if (!empty($conf->dol_optimize_smallscreen)) { @@ -2815,17 +2883,23 @@ if (!GETPOST('hide_websitemenu')) { print ''; } - //print ''; + // Export web site print ''; + // Clone web site print ''; // Delete website if ($website->status == $website::STATUS_VALIDATED) { - print ''; + $disabled = ' disabled="disabled"'; + $title = $langs->trans("WebsiteMustBeDisabled", $langs->transnoentitiesnoconv($website->LibStatut(0, 0))); + $url = '#'; } else { - print ''; + $disabled = ''; + $title = $langs->trans("Delete"); + $url = $_SERVER["PHP_SELF"].'?action=deletesite&token='.newToken().'&website='.urlencode($website->ref); } + print ''.img_picto('', 'delete', 'class=""').''.$langs->trans("Delete").''; // Regenerate all pages print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("RegenerateWebsiteContent")).'">'; @@ -2833,6 +2907,7 @@ if (!GETPOST('hide_websitemenu')) { // Generate site map print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("GenerateSitemaps")).'">'; + // Find / replace tool print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("ReplaceWebsiteContent")).'">'; } @@ -2940,53 +3015,64 @@ if (!GETPOST('hide_websitemenu')) { print ''; print '
'; - print ''; + print '
'; print $langs->trans("PageContainer").': '; + print '
'; + + // Button Add new web page + print ''; + print 'ref).'" class=""'.$disabled.' title="'.dol_escape_htmltag($langs->trans("AddPage")).'">'; print ''; - print ''; - print 'ref).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("AddPage")).'">'; - print ''; - //print ''; + $out = ''; - if ($action != 'addcontainer') { - $out = ''; + $s = $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action, 'minwidth100 maxwidth200onsmartphone'); - $s = $formwebsite->selectContainer($website, 'pageid', $pageid, 0, $action, 'maxwidth200onsmartphone'); + $out .= ''; + $out .= $s; + $out .= ''; - if ($formwebsite->num > 0) { - $out .= ''; - $out .= $s; - $out .= ''; + $urltocreatenewpage = $_SERVER["PHP_SELF"].'?action=createcontainer&token='.newToken().'&website='.urlencode($website->ref); - $urltocreatenewpage = $_SERVER["PHP_SELF"].'?action=createcontainer&token='.newToken().'&website='.urlencode($website->ref); - - if (!empty($conf->use_javascript_ajax)) { - $out .= ''; - } - } - - print $out; - } else { - print $langs->trans("New"); + if (!empty($conf->use_javascript_ajax)) { + $out .= ''; } + print $out; + + + if (!empty($conf->use_javascript_ajax)) { + print ''; + //print '
'; + if ($object->status == $object::STATUS_DRAFT) { // website is off, we do not allow to change status of page + $text_off = 'SetWebsiteOnlineBefore'; + if ($objectpage->status == $objectpage::STATUS_DRAFT) { + print ''.img_picto($langs->trans($text_off), 'switch_off').''; + } else { + print ''.img_picto($langs->trans($text_off), 'switch_on').''; + } + } else { + print ajax_object_onoff($objectpage, 'status', 'status', 'Online', 'Offline', array(), 'valignmiddle', 'statuswebsitepage'); + } + //print '
'; + print '
'; + } print ''; - print ''; + print ''; // Print nav arrows $pagepreviousid = 0; @@ -3015,23 +3101,18 @@ if (!GETPOST('hide_websitemenu')) { } if ($pagepreviousid) { - print ''.img_previous($langs->trans("PreviousContainer")).''; + print ''.img_previous($langs->trans("PreviousContainer")).''; } else { print ''.img_previous($langs->trans("PreviousContainer")).''; } if ($pagenextid) { - print ''.img_next($langs->trans("NextContainer")).''; + print ''.img_next($langs->trans("NextContainer")).''; } else { print ''.img_next($langs->trans("NextContainer")).''; } print ''; - $websitepage = new WebSitePage($db); - if ($pageid > 0 && ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone')) { - $websitepage->fetch($pageid); - } - if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpagefromclone' || $action == 'deletesite') { $disabled = ''; if (empty($user->rights->website->write)) { @@ -3109,15 +3190,15 @@ if (!GETPOST('hide_websitemenu')) { print ''; - print '   '; - - //print ''; + // Edit web page properties print ''.dol_escape_htmltag($langs->trans("EditPageMeta")).''; - //print ''; + // Edit HTML content print ''.dol_escape_htmltag($langs->trans($conf->dol_optimize_smallscreen ? "HTML" : "EditHTMLSource")).''; print ''; + + // Switch include dynamic content / edit inline print ''."\n"; print '
'; @@ -3210,7 +3291,19 @@ if (!GETPOST('hide_websitemenu')) { print 'ref).'&pageid='.((int) $pageid).'" class="button bordertransp"'.$disabled.' title="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'">'; } print ''; - print ''; + + // Delete + //print ''; + if ($websitepage->status == $websitepage::STATUS_DRAFT || !$atleastonepage) { + $disabled = ' disabled="disabled"'; + $title = $langs->trans("WebpageMustBeDisabled", $langs->transnoentitiesnoconv($websitepage->LibStatut(0, 0))); + $url = '#'; + } else { + $disabled = ''; + $title = ''; + $url = $_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&website='.urlencode($website->ref); + } + print ''.img_picto('', 'delete', 'class=""').''.$langs->trans("Delete").''; } } @@ -3466,13 +3559,16 @@ if ($action == 'editcss') { print ''; // Status of web site - print ''."\n"; - print ''; - print $langs->trans('Status'); - print ''; - print ajax_object_onoff($object, 'status', 'status', 'Enabled', 'Disabled'); - //print dol_print_date($pagedatecreation, 'dayhour'); - print ''; + if ($action != 'createcontainer') { + if (empty($conf->use_javascript_ajax)) { + print ''."\n"; + print ''; + print $langs->trans('Status'); + print ''; + print $form->selectyesno('status', $object->status); + print ''; + } + } // Main language print ''; @@ -3851,7 +3947,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties $pageusermodifid = $objectpage->fk_user_modif; $pageauthoralias = $objectpage->author_alias; $pagestatus = $objectpage->status; - } else { + } else { // $action = 'createcontainer' $type_container = 'page'; $pageurl = ''; $pagealiasalt = ''; @@ -3898,13 +3994,14 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties } if ($action != 'createcontainer') { - print ''."\n"; - print ''; - print $langs->trans('Status'); - print ''; - print ajax_object_onoff($objectpage, 'status', 'status', 'Enabled', 'Disabled'); - //print dol_print_date($pagedatecreation, 'dayhour'); - print ''; + if (empty($conf->use_javascript_ajax)) { + print ''."\n"; + print ''; + print $langs->trans('Status'); + print ''; + print $form->selectyesno('status', $objectpage->status); + print ''; + } } // Type of container @@ -3915,6 +4012,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties $formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ? GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container), 0, '', 1); print ''; + // Example/templates of page if ($action == 'createcontainer') { print ''; print $langs->trans('WEBSITE_PAGE_EXAMPLE'); @@ -4149,6 +4247,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties print ''; print ''; + if ($action == 'createcontainer') { print '
'; @@ -4177,7 +4276,10 @@ if ($action == 'editmeta' || $action == 'createcontainer') { // Edit properties $arraygrabimagesinto = array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage")); print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ? GETPOST('grabimagesinto') : 'root', 0, 0, 0, '', 0, 0, 0, '', '', 1); print '
'; - print ''; + + print ''; + print ''; + print ''; print ''; } diff --git a/htdocs/website/websiteaccount_card.php b/htdocs/website/websiteaccount_card.php index 39e6e10e3d7..a9fabffba3c 100644 --- a/htdocs/website/websiteaccount_card.php +++ b/htdocs/website/websiteaccount_card.php @@ -63,19 +63,22 @@ if (empty($action) && empty($id) && empty($ref)) { $action = 'view'; } +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. + // Security check - Protection if external user //if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'website', $id); +if (empty($user->rights->websiteaccount->read)) { + accessforbidden('NotAllowed'); +} // Permissions $permissionnote = $user->rights->websiteaccount->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->websiteaccount->write; // Used by the include of actions_dellink.inc.php $permissiontoadd = $user->rights->websiteaccount->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php - -// Load object -include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. - +$permissiontodelete = $user->rights->websiteaccount->delete; /* @@ -320,8 +323,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } */ - if ($user->rights->website->delete) { - print ''."\n"; + if ($permissiontodelete) { + print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete); } } print '
'."\n"; diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 280478c2977..87ee470dce7 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -451,10 +451,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // 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=workstation', 'clone', $permissiontoadd); } - + // Disable / Enable if ($permissiontoadd) { if ($object->status == $object::STATUS_ENABLED) { print ''.$langs->trans("Disable").''."\n"; @@ -463,13 +463,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - - // Delete (need delete permission, or if draft, just need create/modify permission) - if ($permissiontodelete) { - print ''.$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/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 6af80a304ae..e0f36279437 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -178,6 +178,9 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase if (preg_match('/\/htdocs\/includes\//', $file['fullname'])) { continue; } + if (preg_match('/\/htdocs\/install\/doctemplates\/websites\//', $file['fullname'])) { + continue; + } if (preg_match('/\/htdocs\/custom\//', $file['fullname'])) { continue; } diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 9e7fc91fc7a..6f50e5b3085 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -362,6 +362,12 @@ class DateLibTest extends PHPUnit\Framework\TestCase $langs=$this->savlangs; $db=$this->savdb; + // Check %Y-%m-%d %H:%M:%S format + $result=dol_print_date('1970-01-01', '%Y-%m-%d %H:%M:%S', true); // A case for compatibility check + print __METHOD__." result=".$result."\n"; + $this->assertEquals('1970-01-01 00:00:00', $result); + + // Check %Y-%m-%d %H:%M:%S format $result=dol_print_date(0, '%Y-%m-%d %H:%M:%S', true); print __METHOD__." result=".$result."\n";