diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index 6ad1cdc6974..fb3a1ccf702 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -246,11 +246,14 @@ if ($reshook == 0) { } } +$permissiontoadd = 1; + //asort($elementList); $id = 25; + /* * Actions */ @@ -338,6 +341,7 @@ if (empty($reshook)) { } setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); + $action = 'add'; } } @@ -411,6 +415,7 @@ if (empty($reshook)) { } else { dol_print_error($db); } + $action = 'add'; } } @@ -489,6 +494,7 @@ if (empty($reshook)) { setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); } else { setEventMessages($db->error(), null, 'errors'); + $action = 'edit'; } } } @@ -515,7 +521,7 @@ if (empty($reshook)) { if ($action == $acts[0]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 1 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -527,7 +533,7 @@ if (empty($reshook)) { if ($action == $acts[1]) { $rowidcol = "rowid"; - $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE ".$rowidcol."=".((int) $rowid); + $sql = "UPDATE ".$tabname[$id]." SET active = 0 WHERE rowid = ".((int) $rowid); $result = $db->query($sql); if (!$result) { @@ -545,18 +551,38 @@ $form = new Form($db); $formadmin = new FormAdmin($db); $help_url = ''; -$title = $langs->trans("EMailsSetup"); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $title = $langs->trans("EMailsSetup"); +} else { + $title = $langs->trans("EMailsTemplates"); +} llxHeader('', $title, $help_url); $linkback = ''; $titlepicto = 'title_setup'; -print load_fiche_titre($title, $linkback, $titlepicto); -$head = email_admin_prepare_head(); +$url = DOL_URL_ROOT.'/admin/mails_templates.php?action=add'; +$newcardbutton = dolGetButtonTitle($langs->trans('NewEMailTemplate'), '', 'fa fa-plus-circle', $url, '', $permissiontoadd); + + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre($title, '', $titlepicto); +} else { + print load_fiche_titre($title, $newcardbutton, $titlepicto); +} + +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + $head = email_admin_prepare_head(); + + print dol_get_fiche_head($head, 'templates', '', -1); + + if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print load_fiche_titre('', $newcardbutton, ''); + } +} -print dol_get_fiche_head($head, 'templates', '', -1); // Confirmation de la suppression de la ligne if ($action == 'delete') { @@ -599,7 +625,7 @@ $sql .= $db->plimit($listlimit + 1, $offset); $fieldlist = explode(',', $tabfield[$id]); -if ($action == 'view') { +if ($action == 'add') { // Form to add a new line print '
'; print ''; @@ -750,7 +776,8 @@ if ($action == 'view') { if ($tmpfieldlist == 'topic') { print ''; if ($action != 'edit') { - print ''; + print '
'; + print ''; } print ''; } @@ -1142,7 +1169,10 @@ print ''; print '
'; -print dol_get_fiche_end(); +if (!empty($user->admin) && (empty($_SESSION['leftmenu']) || $_SESSION['leftmenu'] != 'email_templates')) { + print dol_get_fiche_end(); +} + // End of page llxFooter(); diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 340ac1dfc8c..9069b63179f 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -310,6 +310,8 @@ if ($object->fetch($id) >= 0) { print load_fiche_titre($langs->trans("ToAddRecipientsChooseHere"), ($user->admin ?info_admin($langs->trans("YouCanAddYourOwnPredefindedListHere"), 1) : ''), 'generic'); //print ''; + + print '
'; print '
'; //print '
'; @@ -323,7 +325,7 @@ if ($object->fetch($id) >= 0) { //print ''; print '
 
'; //print "\n"; - print ''; + print ''; // End tr clearstatcache(); @@ -424,9 +426,9 @@ if ($object->fetch($id) >= 0) { print '
'; if ($allowaddtarget) { - print ''; + print ''; } else { - print ''; + print ''; //print $langs->trans("MailNoChangePossible"); print " "; } @@ -445,6 +447,7 @@ if ($object->fetch($id) >= 0) { $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print '
'; // End table print ''; print '

'; @@ -535,7 +538,7 @@ if ($object->fetch($id) >= 0) { $morehtmlcenter = ''; if ($allowaddtarget) { - $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").'id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").''; + $morehtmlcenter = ''.$langs->trans("ToClearAllRecipientsClickHere").'id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").''; } $morehtmlcenter .= '   id.'">'.$langs->trans("Download").''; diff --git a/htdocs/compta/facture/index.php b/htdocs/compta/facture/index.php index 0a526e39e1e..1821d4720af 100644 --- a/htdocs/compta/facture/index.php +++ b/htdocs/compta/facture/index.php @@ -43,9 +43,8 @@ if (isset($user->socid) && $user->socid > 0) { $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT; // Maximum elements of the tables -$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; -$maxLatestEditCount = 5; -$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD; +$maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? $max : $conf->global->MAIN_MAXLIST_OVERLOAD; /* @@ -64,7 +63,7 @@ if ($tmp) { print $tmp; print '
'; } -$tmp = getCustomerInvoiceDraftTable($max, $socid); +$tmp = getCustomerInvoiceDraftTable($maxDraftCount, $socid); if ($tmp) { print $tmp; print '
'; @@ -74,13 +73,13 @@ print ''; print '
'; -$tmp = getCustomerInvoiceLatestEditTable($maxLatestEditCount, $socid); +$tmp = getCustomerInvoiceLatestEditTable($max, $socid); if ($tmp) { print $tmp; print '
'; } -$tmp = getCustomerInvoiceUnpaidOpenTable($max, $socid); +$tmp = getCustomerInvoiceUnpaidOpenTable($maxOpenCount, $socid); if ($tmp) { print $tmp; print '
'; diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 0ed0134a944..20d38ed3805 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -575,7 +575,7 @@ class pdf_einstein extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index a901a23cc69..5cf7ce6645b 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -800,7 +800,7 @@ class pdf_eratosthene extends ModelePDFCommandes } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index be42ab002d5..b1ab0f671b9 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -749,9 +749,9 @@ class pdf_crabe extends ModelePDFFactures if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 2def31cbf30..c1413a103f8 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -887,9 +887,9 @@ class pdf_sponge extends ModelePDFFactures if (!isset($this->tva[$vatrate])) { $this->tva[$vatrate] = 0; } - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); $nexY = max($nexY, $posYAfterImage); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index ef43f05b86a..4b928d8af07 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -138,9 +138,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY sp.poste"; $resql = $this->db->query($sql); - $s .= $langs->trans("PostOrFunction").' '; - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); $i = 0; @@ -157,11 +156,10 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_jobposition_contact"); $s .= ' '; // Filter on contact category - $s .= $langs->trans("ContactCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -176,8 +174,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -194,12 +192,11 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_category_contact"); $s .= '
'; // Add prospect of a particular level - $s .= $langs->trans("NatureOfThirdParty").' '; - $s .= ''; $sql = "SELECT code, label"; $sql .= " FROM ".MAIN_DB_PREFIX."c_prospectlevel"; $sql .= " WHERE active > 0"; @@ -208,9 +205,9 @@ class mailing_contacts1 extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); if ($num) { - $s .= ''; + $s .= ''; } else { - $s .= ''; + $s .= ''; } $s .= ''; @@ -231,11 +228,11 @@ class mailing_contacts1 extends MailingTargets //$s.=''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_contact"); $s .= ' '; // Filter on thirdparty category - $s .= $langs->trans("CustomersProspectsCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -250,8 +247,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -268,11 +265,11 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; + $s .= ajax_combobox("filter_category_customer_contact"); $s .= ' '; // Filter on thirdparty category - $s .= $langs->trans("SuppliersCategoriesShort").' '; $sql = "SELECT c.label, count(distinct(sp.email)) AS nb"; $sql .= " FROM "; $sql .= " ".MAIN_DB_PREFIX."socpeople as sp,"; @@ -287,8 +284,8 @@ class mailing_contacts1 extends MailingTargets $sql .= " ORDER BY c.label"; $resql = $this->db->query($sql); - $s .= ''; + $s .= ''; if ($resql) { $num = $this->db->num_rows($resql); if ($num) { @@ -305,7 +302,7 @@ class mailing_contacts1 extends MailingTargets dol_print_error($this->db); } $s .= ''; - + $s .= ajax_combobox("filter_category_supplier_contact"); return $s; } @@ -366,22 +363,16 @@ class mailing_contacts1 extends MailingTargets $sql .= " s.nom as companyname"; $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as sp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = sp.fk_soc"; - if ($filter_category <> 'all') { + if ($filter_category != 'all' && $filter_category != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c"; - } - if ($filter_category <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_contact as cs"; } - if ($filter_category_customer <> 'all') { + if ($filter_category_customer != 'all' && $filter_category_customer != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c2"; - } - if ($filter_category_customer <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_societe as c2s"; } - if ($filter_category_supplier <> 'all') { + if ($filter_category_supplier != 'all' && $filter_category_supplier != '-1') { $sql .= ", ".MAIN_DB_PREFIX."categorie as c3"; - } - if ($filter_category_supplier <> 'all') { $sql .= ", ".MAIN_DB_PREFIX."categorie_fournisseur as c3s"; } $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; @@ -391,34 +382,28 @@ class mailing_contacts1 extends MailingTargets $sql .= " AND sp.statut = 1"; $sql .= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; // Filter on category - if ($filter_category <> 'all') { + if ($filter_category != 'all' && $filter_category != '-1') { $sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_socpeople = sp.rowid"; - } - if ($filter_category <> 'all') { $sql .= " AND c.label = '".$this->db->escape($filter_category)."'"; } - if ($filter_category_customer <> 'all') { + if ($filter_category_customer != 'all' && $filter_category_customer != '-1') { $sql .= " AND c2s.fk_categorie = c2.rowid AND c2s.fk_soc = sp.fk_soc"; - } - if ($filter_category_customer <> 'all') { $sql .= " AND c2.label = '".$this->db->escape($filter_category_customer)."'"; } - if ($filter_category_supplier <> 'all') { + if ($filter_category_supplier != 'all' && $filter_category_supplier != '-1') { $sql .= " AND c3s.fk_categorie = c3.rowid AND c3s.fk_soc = sp.fk_soc"; - } - if ($filter_category_supplier <> 'all') { $sql .= " AND c3.label = '".$this->db->escape($filter_category_supplier)."'"; } // Filter on nature $key = $filter; - { - //print "xx".$key; + + //print "xx".$key; if ($key == 'prospects') { $sql .= " AND s.client=2"; } foreach ($prospectlevel as $codelevel => $valuelevel) { if ($key == 'prospectslevel'.$codelevel) { - $sql .= " AND s.fk_prospectlevel='".$this->db->escape($codelevel)."'"; + $sql .= " AND s.fk_prospectlevel = '".$this->db->escape($codelevel)."'"; } } if ($key == 'customers') { @@ -427,17 +412,18 @@ class mailing_contacts1 extends MailingTargets if ($key == 'suppliers') { $sql .= " AND s.fournisseur=1"; } - } + // Filter on job position - $key = $filter_jobposition; - if (!empty($key) && $key != 'all') { - $sql .= " AND sp.poste ='".$this->db->escape($key)."'"; + $key = $filter_jobposition; + if (!empty($key) && $key != 'all' && $key != '-1') { + $sql .= " AND sp.poste = '".$this->db->escape($key)."'"; } - $sql .= " ORDER BY sp.email"; + + $sql .= " ORDER BY sp.email"; //print "wwwwwwx".$sql; // Stocke destinataires dans cibles - $result = $this->db->query($sql); + $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); $i = 0; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 09445264dc7..aa7c218417b 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -123,16 +123,16 @@ class mailing_fraise extends MailingTargets $s = ''; // Status - $s .= $langs->trans("Status").': '; - $s .= ''; + $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; $s .= ' '; - $s .= $langs->trans("Type").': '; - $s .= ''; $sql = "SELECT rowid, libelle as label, statut"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql .= " WHERE entity IN (".getEntity('member_type').")"; @@ -141,7 +141,7 @@ class mailing_fraise extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - $s .= ''; + $s .= ''; if (!$num) { $s .= ''; } @@ -154,16 +154,17 @@ class mailing_fraise extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_type"); } else { dol_print_error($this->db); } $s .= ''; + $s .= ajax_combobox("filter_type_fraise"); $s .= ' '; - $s .= $langs->trans("Category").': '; - $s .= ''; // Show categories $sql = "SELECT rowid, label, type, visible"; @@ -178,7 +179,7 @@ class mailing_fraise extends MailingTargets if ($resql) { $num = $this->db->num_rows($resql); - $s .= ''; + $s .= ''; if (!$num) { $s .= ''; } @@ -191,6 +192,7 @@ class mailing_fraise extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_category_fraise"); } else { dol_print_error($this->db); } @@ -246,7 +248,7 @@ class mailing_fraise extends MailingTargets $sql .= " a.lastname, a.firstname,"; $sql .= " a.datefin, a.civility as civility_id, a.login, a.societe"; // Other fields $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; - if (GETPOST('filter_category')) { + if (GETPOST('filter_category', 'int') > 0) { $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie_member as cm ON cm.fk_member = a.rowid"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."categorie as c ON c.rowid = cm.fk_categorie AND c.rowid = ".((int) GETPOST('filter_category', 'int')); } @@ -254,16 +256,13 @@ class mailing_fraise extends MailingTargets $sql .= " WHERE a.entity IN (".getEntity('member').") AND a.email <> ''"; // Note that null != '' is false $sql .= " AND a.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; // Filter on status - if (GETPOST("filter") == '-1') { - $sql .= " AND a.statut=-1"; - } - if (GETPOST("filter", 'aZ09') == '1a') { + if (GETPOST("filter", 'aZ09') == 'draft') { + $sql .= " AND a.statut = -1"; + } elseif (GETPOST("filter", 'aZ09') == '1a') { $sql .= " AND a.statut=1 AND (a.datefin >= '".$this->db->idate($now)."' OR ta.subscription = 0)"; - } - if (GETPOST("filter", 'aZ09') == '1b') { + } elseif (GETPOST("filter", 'aZ09') == '1b') { $sql .= " AND a.statut=1 AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND ta.subscription = 1)"; - } - if (GETPOST("filter", 'aZ09') === '0') { + } elseif (GETPOST("filter", 'aZ09') === '0') { $sql .= " AND a.statut=0"; } // Filter on date @@ -276,7 +275,7 @@ class mailing_fraise extends MailingTargets $sql .= " AND a.fk_adherent_type = ta.rowid"; // Filter on type if (GETPOST('filter_type', 'int') > 0) { - $sql .= " AND ta.rowid='".$this->db->escape(GETPOST('filter_type', 'int'))."'"; + $sql .= " AND ta.rowid = ".((int) GETPOST('filter_type', 'int')); } $sql .= " ORDER BY a.email"; //print $sql; diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php new file mode 100644 index 00000000000..b41a5e04c85 --- /dev/null +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -0,0 +1,264 @@ + + * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * This file is an example to follow to add your own email selector inside + * the Dolibarr email tool. + * Follow instructions given in README file to know what to change to build + * your own emailing list selector. + * Code that need to be changed in this file are marked by "CHANGE THIS" tag. + */ + +/** + * \file htdocs/core/modules/mailings/partnership.modules.php + * \ingroup mailing + * \brief Example file to provide a list of recipients for mailing module + */ + +include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; + + +/** + * Class to manage a list of personalised recipients for mailing feature + */ +class mailing_partnership extends MailingTargets +{ + public $name = 'PartnershipThirdartiesOrMembers'; + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + public $desc = "Thirdparties or members included into a partnership program"; + public $require_admin = 0; + + public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'partnership'; + + /** + * @var DoliDB Database handler. + */ + public $db; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $conf, $langs; + $langs->load("companies"); + + $this->db = $db; + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This is the main function that returns the array of emails + * + * @param int $mailing_id Id of mailing. No need to use it. + * @return int <0 if error, number of emails added if ok + */ + public function add_to_target($mailing_id) + { + // phpcs:enable + global $conf, $langs; + + $cibles = array(); + $addDescription = ''; + + $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, pt.label as label, 'thirdparty' as source"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."c_partnership_type as pt"; + $sql .= " WHERE s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; + $sql .= " AND p.fk_soc = s.rowid"; + $sql .= " AND pt.rowid = p.fk_type"; + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); + } + + $sql .= " UNION "; + + $sql .= "SELECT s.rowid as id, s.email as email, s.lastname as name, null as fk_contact, s.firstname as firstname, pt.label as label, 'member' as source"; + $sql .= " FROM ".MAIN_DB_PREFIX."adherent as s, ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."c_partnership_type as pt"; + $sql .= " WHERE s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('member').")"; + $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; + $sql .= " AND p.fk_member = s.rowid"; + $sql .= " AND pt.rowid = p.fk_type"; + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); + } + + $sql .= " ORDER BY email"; + + // Stock recipients emails into targets table + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + $i = 0; + $j = 0; + + dol_syslog(get_class($this)."::add_to_target mailing ".$num." targets found"); + + $old = ''; + while ($i < $num) { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) { + $otherTxt = ($obj->label ? $langs->transnoentities("PartnershipType").'='.$obj->label : ''); + if (strlen($addDescription) > 0 && strlen($otherTxt) > 0) { + $otherTxt .= ";"; + } + $otherTxt .= $addDescription; + $cibles[$j] = array( + 'email' => $obj->email, + 'fk_contact' => $obj->fk_contact, + 'lastname' => $obj->name, // For a thirdparty, we must use name + 'firstname' => '', // For a thirdparty, lastname is '' + 'other' => $otherTxt, + 'source_url' => $this->url($obj->id, $obj->source), + 'source_id' => $obj->id, + 'source_type' => $obj->source + ); + $old = $obj->email; + $j++; + } + + $i++; + } + } else { + dol_syslog($this->db->error()); + $this->error = $this->db->error(); + return -1; + } + + return parent::addTargetsToDatabase($mailing_id, $cibles); + } + + + /** + * On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * + * @return array Array with SQL requests + */ + public function getSqlArrayForStats() + { + // CHANGE THIS: Optionnal + + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + return array(); + } + + + /** + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * + * @param string $sql Requete sql de comptage + * @return int Nb of recipients + */ + public function getNbOfRecipients($sql = '') + { + global $conf; + + $sql = "SELECT count(distinct(s.email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE s.rowid = p.fk_soc AND s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('societe').")"; + + $sql .= " UNION "; + + $sql .= "SELECT count(distinct(s.email)) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."adherent as s"; + $sql .= " WHERE s.rowid = p.fk_member AND s.email <> ''"; + $sql .= " AND s.entity IN (".getEntity('member').")"; + + //print $sql; + + // La requete doit retourner un champ "nb" pour etre comprise + // par parent::getNbOfRecipients + return parent::getNbOfRecipients($sql); + } + + /** + * This is to add a form filter to provide variant of selector + * If used, the HTML select must be called "filter" + * + * @return string A html select zone + */ + public function formFilter() + { + global $conf, $langs; + + $langs->load("companies"); + + $s = ' '; + + return $s; + } + + + /** + * Can include an URL link on each record provided by selector shown on target page. + * + * @param int $id ID + * @param string $sourcetype Source type + * @return string Url link + */ + public function url($id, $sourcetype = 'thirdparty') + { + if ($sourcetype == 'thirparty') { + return ''.img_object('', "societe").''; + } + if ($sourcetype == 'member') { + return ''.img_object('', "member").''; + } + + return ''; + } +} diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 6880452a416..56d62449bcf 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -119,20 +119,20 @@ class mailing_pomme extends MailingTargets $langs->load("users"); $s = ''; - $s .= $langs->trans("Status").' '; - $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_pomme"); $s .= ' '; - $s .= $langs->trans("Employee").' '; - $s .= ''; + $s .= ''; $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filteremployee_pomme"); return $s; } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index ae26dfc19fd..8550440d5d1 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -115,7 +115,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND cs.fk_soc = s.rowid"; $sql .= " AND c.rowid = cs.fk_categorie"; - $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + } $sql .= $addFilter; $sql .= " UNION "; $sql .= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; @@ -125,7 +127,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND cs.fk_soc = s.rowid"; $sql .= " AND c.rowid = cs.fk_categorie"; - $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + if (GETPOST('filter', 'int') > 0) { + $sql .= " AND c.rowid=".((int) GETPOST('filter', 'int')); + } $sql .= $addFilter; } $sql .= " ORDER BY email"; @@ -206,7 +210,7 @@ class mailing_thirdparties extends MailingTargets $sql = "SELECT count(distinct(s.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE s.email != ''"; + $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; // La requete doit retourner un champ "nb" pour etre comprise @@ -226,8 +230,7 @@ class mailing_thirdparties extends MailingTargets $langs->load("companies"); - $s = $langs->trans("Categories").' '; - $s .= ''; // Show categories $sql = "SELECT rowid, label, type, visible"; @@ -247,7 +250,7 @@ class mailing_thirdparties extends MailingTargets } if ($num) { - $s .= ''; + $s .= ''; } else { $s .= ''; } @@ -270,14 +273,15 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $i++; } + $s .= ajax_combobox("filter_thirdparties"); } else { dol_print_error($this->db); } $s .= ' '; - $s .= $langs->trans('ProspectCustomer'); - $s .= ' '; + $s .= ''; if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) { $s .= ''; } @@ -290,13 +294,14 @@ class mailing_thirdparties extends MailingTargets $s .= ''; $s .= ' '; + $s .= ajax_combobox("filter_client_thirdparties"); - $s .= $langs->trans("Status"); - $s .= ' '; + $s .= ''; + $s .= ''; $s .= ''; $s .= ''; + $s .= ajax_combobox("filter_status_thirdparties"); return $s; } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 4c848b69ac0..09f4cf76ae6 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -215,10 +215,9 @@ class mailing_thirdparties_services_expired extends MailingTargets { global $langs; - $s = $langs->trans("ProductOrService"); - $s .= ''; if (count($this->arrayofproducts)) { - $s .= ''; + $s .= ''; } else { $s .= ''; } @@ -226,6 +225,7 @@ class mailing_thirdparties_services_expired extends MailingTargets $s .= ''; } $s .= ''; + $s .= ajax_combobox("filter_services_expired"); return $s; } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index ea2ea8add99..5e5a8ded7c5 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -685,7 +685,7 @@ class pdf_azur extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 9963ecd9527..01cc1eebc9f 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -810,7 +810,7 @@ class pdf_cyan extends ModelePDFPropales } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = max($nexY, $posYAfterImage); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 59f4067cf31..f844a5fad55 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -746,7 +746,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 3f7e6181913..d5003c4b806 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -625,7 +625,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 7539d89167b..4a8598a4d4d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -619,7 +619,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } $this->tva[$vatrate] += $tvaligne; $vatcode = $object->lines[$i]->vat_src_code; - $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=>$tvaligne); + $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne); if ($posYAfterImage > $posYAfterDescription) { $nexY = $posYAfterImage; diff --git a/htdocs/fourn/facture/index.php b/htdocs/fourn/facture/index.php index 21d3e4cfa58..9546d434bb9 100644 --- a/htdocs/fourn/facture/index.php +++ b/htdocs/fourn/facture/index.php @@ -27,9 +27,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php'; -// Security check -restrictedArea($user, 'fournisseur', 0, '', 'facture'); - // Load translation files required by the page $langs->loadLangs(['bills', 'boxes']); @@ -47,9 +44,21 @@ $maxDraftCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->glob $maxLatestEditCount = 5; $maxOpenCount = empty($conf->global->MAIN_MAXLIST_OVERLOAD) ? 500 : $conf->global->MAIN_MAXLIST_OVERLOAD; +// Security check +restrictedArea($user, 'fournisseur', 0, '', 'facture'); + + /* -* View -*/ + * Actions + */ + +// None + + + +/* + * View + */ llxHeader("", $langs->trans("SupplierInvoicesArea"), 'EN:Suppliers_Invoices|FR:FactureFournisseur|ES:Facturas_de_proveedores'); @@ -64,7 +73,7 @@ if ($tmp) { print '
'; } -$tmp = getDraftSupplierTable($maxDraftCount, $socid); +$tmp = getDraftSupplierTable($max, $socid); if ($tmp) { print $tmp; print '
'; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 4981dde2b45..39cf2da2b2f 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -106,7 +106,7 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), - 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20), + 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'notnull'=>1, 'enabled' => 1, 'visible' => 1, 'position' => 20), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -245,6 +245,11 @@ class Partnership extends CommonObject */ public function create(User $user, $notrigger = false) { + if ($this->fk_soc <= 0 && $this->fk_member <= 0) { + $this->error[] = "ErrorThirpdartyOrMemberidIsManadatory"; + return -1; + } + $this->status = 0; return $this->createCommon($user, $notrigger); } @@ -547,6 +552,11 @@ class Partnership extends CommonObject */ public function update(User $user, $notrigger = false) { + if ($this->fk_soc <= 0 && $this->fk_member <= 0) { + $this->error[] = "ErrorThirpdartyOrMemberidIsManadatory"; + return -1; + } + return $this->updateCommon($user, $notrigger); }