From 2d89d9634b7f6cad4f73240efbe02c419f1f92ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 20 Jun 2018 23:16:06 +0200 Subject: [PATCH 1/3] Fix search on extrafields --- htdocs/societe/class/api_contacts.class.php | 1 + htdocs/societe/class/api_thirdparties.class.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 3270bc144c2..208a50631be 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -122,6 +122,7 @@ class Contacts extends DolibarrApi $sql = "SELECT t.rowid"; $sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object = t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) { // We need this table joined to the select in order to filter by sale $sql.= ", " . MAIN_DB_PREFIX . "societe_commerciaux as sc"; diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index fa52c73f597..f6f38eec239 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -123,6 +123,7 @@ class Thirdparties extends DolibarrApi $sql = "SELECT t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."societe as t"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX . "societe_extrafields as te ON te.fk_object = t.rowid"; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; From d53aa7167342c4a1560e66cd0933acc5e8c9ef5a Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 22 Jun 2018 10:54:00 +0200 Subject: [PATCH 2/3] NEW advance target filtering can be used everywhere with tpl and fk_element --- htdocs/comm/mailing/advtargetemailing.php | 522 +----------------- .../mailing/class/advtargetemailing.class.php | 103 +++- .../html.formadvtargetemailing.class.php | 7 +- htdocs/core/tpl/advtarget.tpl.php | 521 +++++++++++++++++ htdocs/filefunc.inc.php | 2 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 11 + .../mysql/tables/llx_advtargetemailing.sql | 3 +- 7 files changed, 636 insertions(+), 533 deletions(-) create mode 100644 htdocs/core/tpl/advtarget.tpl.php diff --git a/htdocs/comm/mailing/advtargetemailing.php b/htdocs/comm/mailing/advtargetemailing.php index cfafdaa725b..40934dc1585 100644 --- a/htdocs/comm/mailing/advtargetemailing.php +++ b/htdocs/comm/mailing/advtargetemailing.php @@ -73,13 +73,13 @@ if (GETPOST('button_removefilter_x','alpha')) { $search_prenom = ''; $search_email = ''; } - $array_query = array (); - $object = new Mailing($db); $advTarget = new AdvanceTargetingMailing($db); + if (empty($template_id)) { - $advTarget->fk_mailing = $id; + $advTarget->fk_element = $id; + $advTarget->type_element = 'mailing'; $result = $advTarget->fetch_by_mailing(); } else { $result = $advTarget->fetch($template_id); @@ -223,7 +223,7 @@ if ($action == 'add') { } else { $advTarget->contact_lines = array (); } - + if ((count($advTarget->thirdparty_lines) > 0) || (count($advTarget->contact_lines) > 0)) { // Add targets into database $obj = new mailing_advthirdparties($db); @@ -356,6 +356,7 @@ if ($action == 'savefilter' || $action == 'createfilter') { setEventMessage($advTarget->error, 'errors'); } } elseif ($action == 'savefilter') { + $result = $advTarget->update($user); if ($result < 0) { setEventMessage($advTarget->error, 'errors'); @@ -409,36 +410,7 @@ if ($_POST["button_removefilter"]) { llxHeader('', $langs->trans("MailAdvTargetRecipients")); -print ''; $form = new Form($db); $formadvtargetemaling = new FormAdvTargetEmailing($db); @@ -490,487 +462,9 @@ if ($object->fetch($id) >= 0) { // Show email selectors if ($object->statut == 0 && $user->rights->mailing->creer) { - print_fiche_titre($langs->trans("AdvTgtTitle")); - - print '
' . "\n"; - print '
' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - - print '' . "\n"; - - print '' . "\n"; - - // Customer name - print '' . "\n"; - - // Code Client - print '' . "\n"; - - // Address Client - print '' . "\n"; - - // Zip Client - print '' . "\n"; - - // City Client - print '' . "\n"; - - // Customer Country - print '' . "\n"; - - // State Customer - print '' . "\n"; - - // Mother Company - print '' . "\n"; - - // Prospect/Customer - $selected = $array_query['cust_typecust']; - print '' . "\n"; - - // Prospection status - print '' . "\n"; - - // Prospection comm status - print '' . "\n"; - - // Customer Type - print '' . "\n"; - - // Staff number - print '' . "\n"; - - // Sales manager - print '' . "\n"; - - // Customer Default Langauge - if (! empty($conf->global->MAIN_MULTILANGS)) { - - print '' . "\n"; - } - - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extralabels = $extrafields->fetch_name_optionals_label('societe'); - foreach ( $extralabels as $key => $val ) { - if ($key != 'ts_nameextra' && $key != 'ts_payeur') { - print '' . "\n"; - } - } - } else { - $std_soc = new Societe($db); - $action_search = 'query'; - - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context - include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; - $hookmanager = new HookManager($db); - $hookmanager->initHooks(array ('thirdpartycard')); - - $parameters=array(); - if (! empty($advTarget->id)) { - $parameters = array('array_query' => $advTarget->filtervalue); - } - // Other attributes - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); - print $hookmanager->resPrint; - } - - // State Contact - print '' . "\n"; - - // Civility - print ''; - - // contact name - print '' . "\n"; - print '' . "\n"; - - // Contact Country - print '' . "\n"; - - // Never send mass mailing - print '' . "\n"; - - // Contact Date Create - print '' . "\n"; - - // Contact update Create - print '' . "\n"; - - if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { - // Customer Categories - print '' . "\n"; - } - - // Standard Extrafield feature - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($db); - $extralabels = $extrafields->fetch_name_optionals_label('socpeople'); - foreach($extrafields->attribute_type as $key=>&$value) { - if($value == 'radio')$value = 'select'; - } - - - foreach ( $extralabels as $key => $val ) { - - print '' . "\n"; - } - } - - print '' . "\n"; - print '' . "\n"; - print '' . "\n"; - print '
' . "\n"; - - print '' . "\n"; - - print '
' . $langs->trans('AdvTgtNameTemplate') . ''; - if (! empty($template_id)) { - $default_template = $template_id; - } else { - $default_template = $advTarget->id; - } - print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template); - print ''; - print ''; - print ''; - print $langs->trans('AdvTgtOrCreateNewFilter'); - print ''; - print ''; - print '' . "\n"; - print '
' . $langs->trans('AdvTgtTypeOfIncude') . ''; - print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); - print '
' . $langs->trans('ThirdPartyName'); - if (! empty($array_query['cust_name'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('CustomerCode'); - if (! empty($array_query['cust_code'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Address'); - if (! empty($array_query['cust_adress'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Zip'); - if (! empty($array_query['cust_zip'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Town'); - if (! empty($array_query['cust_city'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans("Country"); - if (count($array_query['cust_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); - print '' . "\n"; - print '
' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray('cust_status', array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), $array_query['cust_status']); - print '' . "\n"; - print '
' . $langs->trans("Maison mère"); - if (! empty($array_query['cust_mothercompany'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); - if (count($array_query['cust_typecust']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - $options_array = array ( - 2 => $langs->trans('Prospect'), - 3 => $langs->trans('ProspectCustomer'), - 1 => $langs->trans('Customer'), - 0 => $langs->trans('NorProspectNorCustomer') - ); - print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); - print '' . "\n"; - print '
' . $langs->trans('ProspectLevel'); - if (count($array_query['cust_prospect_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); - print '' . "\n"; - print '
' . $langs->trans('StatusProsp'); - if (count($array_query['cust_comm_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); - print '' . "\n"; - print '
' . $langs->trans("ThirdPartyType"); - if (count($array_query['cust_typeent']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); - print '' . "\n"; - print '
' . $langs->trans("Staff"); - if (count($array_query['cust_effectif_id']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); - print '' . "\n"; - print '
' . $langs->trans("SalesRepresentatives"); - if (count($array_query['cust_saleman']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); - print '' . "\n"; - print '
' . $langs->trans("DefaultLang"); - if (count($array_query['cust_language']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); - print '' . "\n"; - print '
' . $langs->trans("CustomersCategoryShort"); - if (count($array_query['cust_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); - print '' . "\n"; - print '
' . $extrafields->attribute_label[$key]; - if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { - - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->select_date('', 'options_' . $key . '_st_dt'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->select_date('', 'options_' . $key . '_end_dt'); - print '
'; - - print '
' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'boolean')) { - print $form->selectarray('options_' . $key, array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), $array_query['options_' . $key]); - print '' . "\n"; - } elseif (($extrafields->attribute_type[$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } elseif (($extrafields->attribute_type[$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); - print '' . "\n"; - } else { - - print ''; - print '
'; - if (is_array($array_query['options_' . $key])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key]); - } - print '
'; - - print '
' . "\n"; - } - print '
' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); - if (count($array_query['contact_status']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->advMultiselectarray('contact_status', array ( - '0' => $langs->trans('ActivityCeased'), - '1' => $langs->trans('InActivity') - ), $array_query['contact_status']); - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); - print '
' . $langs->trans("UserTitle"); - if (count($array_query['contact_civility']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); - if (! empty($array_query['contact_lastname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); - if (! empty($array_query['contact_firstname'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); - if (count($array_query['contact_country']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); - print '' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); - if (! empty($array_query['contact_no_email'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $form->selectarray('contact_no_email', array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), $array_query['contact_no_email']); - print '' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); - if (! empty($array_query['contact_create_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->select_date($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->select_date($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
'; - print '
' . "\n"; - print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); - if (! empty($array_query['contact_update_st_dt'])) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->select_date($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->select_date($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); - print '
'; - print '
' . "\n"; - print '
' . $langs->trans("ContactCategoriesShort"); - if (count($array_query['contact_categ']) > 0) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print '' . "\n"; - print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); - print '' . "\n"; - print '
' . $extrafields->attribute_label[$key]; - if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { - print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); - } - print ''; - if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { - print $langs->trans("AdvTgtMinVal") . ''; - print $langs->trans("AdvTgtMaxVal") . ''; - print '' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { - - print ''; - print '
' . $langs->trans("AdvTgtStartDt") . ''; - print $form->select_date('', 'options_' . $key . '_st_dt' . '_cnct'); - print '' . $langs->trans("AdvTgtEndDt") . ''; - print $form->select_date('', 'options_' . $key . '_end_dt' . '_cnct'); - print '
'; - - print '
' . "\n"; - print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); - } elseif (($extrafields->attribute_type[$key] == 'boolean')) { - print $form->selectarray('options_' . $key . '_cnct', array ( - '' => '', - '1' => $langs->trans('Yes'), - '0' => $langs->trans('No') - ), $array_query['options_' . $key . '_cnct']); - print '' . "\n"; - } elseif (($extrafields->attribute_type[$key] == 'select')) { - print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; - } elseif (($extrafields->attribute_type[$key] == 'sellist')) { - print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); - print '' . "\n"; - } else { - - print ''; - print '
'; - if (is_array($array_query['options_' . $key . '_cnct'])) { - print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); - } else { - print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); - } - print '
'; - - print '
' . "\n"; - } - print '
' . "\n"; - - print '' . "\n"; - - print '
' . "\n"; - print '
' . "\n"; - print '
' . "\n"; - - print '
'; - print ''; - print_titre($langs->trans("ToClearAllRecipientsClickHere")); - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'; - print '
'; + + include DOL_DOCUMENT_ROOT . '/core/tpl/advtarget.tpl.php'; + } } diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 70efeccead3..890f107614d 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -39,7 +39,8 @@ class AdvanceTargetingMailing extends CommonObject var $name; var $entity; - var $fk_mailing; + var $fk_element; + var $type_element; var $filtervalue; var $fk_user_author; var $datec=''; @@ -92,7 +93,9 @@ class AdvanceTargetingMailing extends CommonObject $error=0; // Clean parameters - if (isset($this->fk_mailing)) $this->fk_mailing=trim($this->fk_mailing); + if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); + if (isset($this->type_element)) $this->type_element=trim($this->type_element); + if (isset($this->name)) $this->name=trim($this->name); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); @@ -108,7 +111,8 @@ class AdvanceTargetingMailing extends CommonObject $sql.= "name,"; $sql.= "entity,"; - $sql.= "fk_mailing,"; + $sql.= "fk_element,"; + $sql.= "type_element,"; $sql.= "filtervalue,"; $sql.= "fk_user_author,"; $sql.= "datec,"; @@ -119,7 +123,8 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " ".(! isset($this->name)?'NULL':"'".$this->db->escape($this->name)."'").","; $sql.= " ".$conf->entity.","; - $sql.= " ".(! isset($this->fk_mailing)?'NULL':"'".$this->db->escape($this->fk_mailing)."'").","; + $sql.= " ".(! isset($this->fk_element)?'NULL':"'".$this->db->escape($this->fk_element)."'").","; + $sql.= " ".(! isset($this->type_element)?'NULL':"'".$this->db->escape($this->type_element)."'").","; $sql.= " ".(! isset($this->filtervalue)?'NULL':"'".$this->db->escape($this->filtervalue)."'").","; $sql.= " ".$user->id.","; $sql.= " '".$this->db->idate(dol_now())."',"; @@ -184,7 +189,8 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " t.name,"; $sql.= " t.entity,"; - $sql.= " t.fk_mailing,"; + $sql.= " t.fk_element,"; + $sql.= " t.type_element,"; $sql.= " t.filtervalue,"; $sql.= " t.fk_user_author,"; $sql.= " t.datec,"; @@ -206,7 +212,8 @@ class AdvanceTargetingMailing extends CommonObject $this->name = $obj->name; $this->entity = $obj->entity; - $this->fk_mailing = $obj->fk_mailing; + $this->fk_element = $obj->fk_element; + $this->type_element = $obj->type_element; $this->filtervalue = $obj->filtervalue; $this->fk_user_author = $obj->fk_user_author; $this->datec = $this->db->jdate($obj->datec); @@ -240,7 +247,8 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " t.name,"; $sql.= " t.entity,"; - $sql.= " t.fk_mailing,"; + $sql.= " t.fk_element,"; + $sql.= " t.type_element,"; $sql.= " t.filtervalue,"; $sql.= " t.fk_user_author,"; $sql.= " t.datec,"; @@ -249,9 +257,9 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; if (!empty($id)) { - $sql.= " WHERE t.fk_mailing = ".$id; + $sql.= " WHERE t.fk_element = ".$id." AND type_element='mailing'"; }else { - $sql.= " WHERE t.fk_mailing = ".$this->fk_mailing; + $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='mailing'"; } dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); @@ -266,7 +274,73 @@ class AdvanceTargetingMailing extends CommonObject $this->name = $obj->name; $this->entity = $obj->entity; - $this->fk_mailing = $obj->fk_mailing; + $this->fk_element = $obj->fk_element; + $this->type_element = $obj->type_element; + $this->filtervalue = $obj->filtervalue; + $this->fk_user_author = $obj->fk_user_author; + $this->datec = $this->db->jdate($obj->datec); + $this->fk_user_mod = $obj->fk_user_mod; + $this->tms = $this->db->jdate($obj->tms); + + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + + + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + function fetch_by_element($id=0,$type_element='mailing') + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + + $sql.= " t.name,"; + $sql.= " t.entity,"; + $sql.= " t.fk_element,"; + $sql.= " t.type_element,"; + $sql.= " t.filtervalue,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.datec,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.tms"; + + $sql.= " FROM ".MAIN_DB_PREFIX."advtargetemailing as t"; + if (!empty($id)) { + $sql.= " WHERE t.fk_element = ".$id." AND type_element='$type_element'"; + }else { + $sql.= " WHERE t.fk_element = ".$this->fk_element." AND type_element='$type_element'"; + } + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + + $this->name = $obj->name; + $this->entity = $obj->entity; + $this->fk_element = $obj->fk_element; + $this->type_element = $obj->type_element; $this->filtervalue = $obj->filtervalue; $this->fk_user_author = $obj->fk_user_author; $this->datec = $this->db->jdate($obj->datec); @@ -299,7 +373,8 @@ class AdvanceTargetingMailing extends CommonObject $error=0; // Clean parameters - if (isset($this->fk_mailing)) $this->fk_mailing=trim($this->fk_mailing); + if (isset($this->fk_element)) $this->fk_element=trim($this->fk_element); + if (isset($this->type_element)) $this->type_element=trim($this->type_element); if (isset($this->name)) $this->name=trim($this->name); if (isset($this->filtervalue)) $this->filtervalue=trim($this->filtervalue); if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); @@ -315,14 +390,14 @@ class AdvanceTargetingMailing extends CommonObject $sql.= " name=".(isset($this->name)?"'".$this->db->escape($this->name)."'":"''").","; $sql.= " entity=".$conf->entity.","; - $sql.= " fk_mailing=".(isset($this->fk_mailing)?$this->fk_mailing:"null").","; + $sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").","; + $sql.= " type_element=".(isset($this->type_element)?"'".$this->db->escape($this->type_element)."'":"null").","; $sql.= " filtervalue=".(isset($this->filtervalue)?"'".$this->db->escape($this->filtervalue)."'":"null").","; $sql.= " fk_user_mod=".$user->id; $sql.= " WHERE rowid=".$this->id; $this->db->begin(); - dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } @@ -432,7 +507,7 @@ class AdvanceTargetingMailing extends CommonObject global $langs,$conf; if (!empty($arrayquery)) { - $result=$this->fetch_by_mailing($this->fk_mailing); + $result=$this->fetch_by_mailing($this->fk_element); $this->filtervalue=json_encode($arrayquery); if ($result<0) { return -1; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index c7f425f8f7a..370fe720a6d 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -417,13 +417,14 @@ class FormAdvTargetEmailing extends Form * * @return string HTML combo */ - public function selectAdvtargetemailingTemplate($htmlname='template_id',$selected=0,$showempty=0) { + public function selectAdvtargetemailingTemplate($htmlname='template_id',$selected=0,$showempty=0,$type_element='mailing') { global $conf, $user, $langs; $out = ''; - $sql = "SELECT c.rowid, c.name, c.fk_mailing"; + $sql = "SELECT c.rowid, c.name, c.fk_element"; $sql .= " FROM " . MAIN_DB_PREFIX . "advtargetemailing as c"; + $sql .= " WHERE type_element='$type_element'"; $sql .= " ORDER BY c.name"; dol_syslog ( get_class ( $this ) . "::".__METHOD__, LOG_DEBUG ); @@ -441,7 +442,7 @@ class FormAdvTargetEmailing extends Form $obj = $this->db->fetch_object ( $resql ); $label = $obj->name; if (empty($label)) { - $label=$obj->fk_mailing; + $label=$obj->fk_element; } if ($selected > 0 && $selected == $obj->rowid) { diff --git a/htdocs/core/tpl/advtarget.tpl.php b/htdocs/core/tpl/advtarget.tpl.php new file mode 100644 index 00000000000..e1104ef84f6 --- /dev/null +++ b/htdocs/core/tpl/advtarget.tpl.php @@ -0,0 +1,521 @@ + + $(document).ready(function() { + + // Click Function + $(":button[name=addcontact]").click(function() { + $(":hidden[name=action]").val("add"); + $("#find_customer").submit(); + }); + + $(":button[name=loadfilter]").click(function() { + $(":hidden[name=action]").val("loadfilter"); + $("#find_customer").submit(); + }); + + $(":button[name=deletefilter]").click(function() { + $(":hidden[name=action]").val("deletefilter"); + $("#find_customer").submit(); + }); + + $(":button[name=savefilter]").click(function() { + $(":hidden[name=action]").val("savefilter"); + $("#find_customer").submit(); + }); + + $(":button[name=createfilter]").click(function() { + $(":hidden[name=action]").val("createfilter"); + $("#find_customer").submit(); + }); + }); +'; + + + print_fiche_titre($langs->trans("AdvTgtTitle")); + + print '
' . "\n"; + print '
' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + + print '' . "\n"; + + print '' . "\n"; + + // Customer name + print '' . "\n"; + + // Code Client + print '' . "\n"; + + // Address Client + print '' . "\n"; + + // Zip Client + print '' . "\n"; + + // City Client + print '' . "\n"; + + // Customer Country + print '' . "\n"; + + // State Customer + print '' . "\n"; + + // Mother Company + print '' . "\n"; + + // Prospect/Customer + $selected = $array_query['cust_typecust']; + print '' . "\n"; + + // Prospection status + print '' . "\n"; + + // Prospection comm status + print '' . "\n"; + + // Customer Type + print '' . "\n"; + + // Staff number + print '' . "\n"; + + // Sales manager + print '' . "\n"; + + // Customer Default Langauge + if (! empty($conf->global->MAIN_MULTILANGS)) { + + print '' . "\n"; + } + + if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; + } + + // Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label('societe'); + foreach ( $extralabels as $key => $val ) { + if ($key != 'ts_nameextra' && $key != 'ts_payeur') { + print '' . "\n"; + } + } + } else { + $std_soc = new Societe($db); + $action_search = 'query'; + + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context + include_once DOL_DOCUMENT_ROOT . '/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($db); + $hookmanager->initHooks(array ('thirdpartycard')); + + $parameters=array(); + if (! empty($advTarget->id)) { + $parameters = array('array_query' => $advTarget->filtervalue); + } + // Other attributes + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $std_soc, $action_search); + print $hookmanager->resPrint; + } + + // State Contact + print '' . "\n"; + + // Civility + print ''; + + // contact name + print '' . "\n"; + print '' . "\n"; + + // Contact Country + print '' . "\n"; + + // Never send mass mailing + print '' . "\n"; + + // Contact Date Create + print '' . "\n"; + + // Contact update Create + print '' . "\n"; + + if (! empty($conf->categorie->enabled) && $user->rights->categorie->lire) { + // Customer Categories + print '' . "\n"; + } + + // Standard Extrafield feature + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + // fetch optionals attributes and labels + dol_include_once('/core/class/extrafields.class.php'); + $extrafields = new ExtraFields($db); + $extralabels = $extrafields->fetch_name_optionals_label('socpeople'); + foreach($extrafields->attribute_type as $key=>&$value) { + if($value == 'radio')$value = 'select'; + } + + + foreach ( $extralabels as $key => $val ) { + + print '' . "\n"; + } + } + + print '' . "\n"; + print '' . "\n"; + print '' . "\n"; + print '
' . "\n"; + + print '' . "\n"; + + print '
' . $langs->trans('AdvTgtNameTemplate') . ''; + if (! empty($template_id)) { + $default_template = $template_id; + } else { + $default_template = $advTarget->id; + } + print $formadvtargetemaling->selectAdvtargetemailingTemplate('template_id', $default_template); + print ''; + print ''; + print ''; + print $langs->trans('AdvTgtOrCreateNewFilter'); + print ''; + print ''; + print '' . "\n"; + print '
' . $langs->trans('AdvTgtTypeOfIncude') . ''; + print $form->selectarray('type_of_target', $advTarget->select_target_type, $array_query['type_of_target']); + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtTypeOfIncudeHelp"), 1, 'help'); + print '
' . $langs->trans('ThirdPartyName'); + if (! empty($array_query['cust_name'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('CustomerCode'); + if (! empty($array_query['cust_code'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Address'); + if (! empty($array_query['cust_adress'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Zip'); + if (! empty($array_query['cust_zip'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Town'); + if (! empty($array_query['cust_city'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans("Country"); + if (count($array_query['cust_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCountry('cust_country', $array_query['cust_country']); + print '' . "\n"; + print '
' . $langs->trans('Status') . ' ' . $langs->trans('ThirdParty'); + if (count($array_query['cust_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('cust_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), $array_query['cust_status']); + print '' . "\n"; + print '
' . $langs->trans("Maison mère"); + if (! empty($array_query['cust_mothercompany'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('ProspectCustomer') . ' ' . $langs->trans('ThirdParty'); + if (count($array_query['cust_typecust']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + $options_array = array ( + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer'), + 1 => $langs->trans('Customer'), + 0 => $langs->trans('NorProspectNorCustomer') + ); + print $formadvtargetemaling->advMultiselectarray('cust_typecust', $options_array, $array_query['cust_typecust']); + print '' . "\n"; + print '
' . $langs->trans('ProspectLevel'); + if (count($array_query['cust_prospect_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->multiselectProspectionStatus($array_query['cust_prospect_status'], 'cust_prospect_status', 1); + print '' . "\n"; + print '
' . $langs->trans('StatusProsp'); + if (count($array_query['cust_comm_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('cust_comm_status', $advTarget->type_statuscommprospect, $array_query['cust_comm_status']); + print '' . "\n"; + print '
' . $langs->trans("ThirdPartyType"); + if (count($array_query['cust_typeent']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->advMultiselectarray('cust_typeent', $formcompany->typent_array(0, " AND id <> 0"), $array_query['cust_typeent']); + print '' . "\n"; + print '
' . $langs->trans("Staff"); + if (count($array_query['cust_effectif_id']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray("cust_effectif_id", $formcompany->effectif_array(0, " AND id <> 0"), $array_query['cust_effectif_id']); + print '' . "\n"; + print '
' . $langs->trans("SalesRepresentatives"); + if (count($array_query['cust_saleman']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectSalesRepresentatives('cust_saleman', $array_query['cust_saleman'], $user); + print '' . "\n"; + print '
' . $langs->trans("DefaultLang"); + if (count($array_query['cust_language']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectselectLanguage('cust_language', $array_query['cust_language']); + print '' . "\n"; + print '
' . $langs->trans("CustomersCategoryShort"); + if (count($array_query['cust_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCustomerCategories('cust_categ', $array_query['cust_categ']); + print '' . "\n"; + print '
' . $extrafields->attribute_label[$key]; + if (! empty($array_query['options_' . $key]) || (is_array($array_query['options_' . $key]) && count($array_query['options_' . $key]) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { + + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date('', 'options_' . $key . '_st_dt'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date('', 'options_' . $key . '_end_dt'); + print '
'; + + print '
' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'boolean')) { + print $form->selectarray('options_' . $key, array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key, $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key]); + print '' . "\n"; + } else { + + print ''; + print '
'; + if (is_array($array_query['options_' . $key])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key])); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key]); + } + print '
'; + + print '
' . "\n"; + } + print '
' . $langs->trans('Status') . ' ' . $langs->trans('Contact'); + if (count($array_query['contact_status']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->advMultiselectarray('contact_status', array ( + '0' => $langs->trans('ActivityCeased'), + '1' => $langs->trans('InActivity') + ), $array_query['contact_status']); + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtContactHelp"), 1, 'help'); + print '
' . $langs->trans("UserTitle"); + if (count($array_query['contact_civility']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + print $formadvtargetemaling->multiselectCivility('contact_civility', $array_query['contact_civility']); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Lastname'); + if (! empty($array_query['contact_lastname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans('Firstname'); + if (! empty($array_query['contact_firstname'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("Country"); + if (count($array_query['contact_country']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectCountry('contact_country', $array_query['contact_country']); + print '' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("No_Email"); + if (! empty($array_query['contact_no_email'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $form->selectarray('contact_no_email', array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['contact_no_email']); + print '' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateCreation"); + if (! empty($array_query['contact_create_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date($array_query['contact_create_st_dt'], 'contact_create_st_dt', 0, 0, 1, 'find_customer', 1, 1); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date($array_query['contact_create_end_dt'], 'contact_create_end_dt', 0, 0, 1, 'find_customer', 1, 1); + print '
'; + print '
' . "\n"; + print '
' . $langs->trans('Contact') . ' ' . $langs->trans("DateLastModification"); + if (! empty($array_query['contact_update_st_dt'])) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date($array_query['contact_update_st_dt'], 'contact_update_st_dt', 0, 0, 1, 'find_customer', 1, 1); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date($array_query['contact_update_end_dt'], 'contact_update_end_dt', 0, 0, 1, 'find_customer', 1, 1); + print '
'; + print '
' . "\n"; + print '
' . $langs->trans("ContactCategoriesShort"); + if (count($array_query['contact_categ']) > 0) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print '' . "\n"; + print $formadvtargetemaling->multiselectContactCategories('contact_categ', $array_query['contact_categ']); + print '' . "\n"; + print '
' . $extrafields->attribute_label[$key]; + if ($array_query['options_' . $key . '_cnct'] != '' || (is_array($array_query['options_' . $key . '_cnct']) && count($array_query['options_' . $key . '_cnct']) > 0)) { + print img_picto($langs->trans('AdvTgtUse'), 'ok.png@advtargetemailing'); + } + print ''; + if (($extrafields->attribute_type[$key] == 'varchar') || ($extrafields->attribute_type[$key] == 'text')) { + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) { + print $langs->trans("AdvTgtMinVal") . ''; + print $langs->trans("AdvTgtMaxVal") . ''; + print '' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) { + + print ''; + print '
' . $langs->trans("AdvTgtStartDt") . ''; + print $form->select_date('', 'options_' . $key . '_st_dt' . '_cnct'); + print '' . $langs->trans("AdvTgtEndDt") . ''; + print $form->select_date('', 'options_' . $key . '_end_dt' . '_cnct'); + print '
'; + + print '
' . "\n"; + print $form->textwithpicto('', $langs->trans("AdvTgtSearchDtHelp"), 1, 'help'); + } elseif (($extrafields->attribute_type[$key] == 'boolean')) { + print $form->selectarray('options_' . $key . '_cnct', array ( + '' => '', + '1' => $langs->trans('Yes'), + '0' => $langs->trans('No') + ), $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'select')) { + print $formadvtargetemaling->advMultiselectarray('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } elseif (($extrafields->attribute_type[$key] == 'sellist')) { + print $formadvtargetemaling->advMultiselectarraySelllist('options_' . $key . '_cnct', $extrafields->attribute_param[$key]['options'], $array_query['options_' . $key . '_cnct']); + print '' . "\n"; + } else { + + print ''; + print '
'; + if (is_array($array_query['options_' . $key . '_cnct'])) { + print $extrafields->showInputField($key, implode(',', $array_query['options_' . $key . '_cnct']), '', '_cnct'); + } else { + print $extrafields->showInputField($key, $array_query['options_' . $key . '_cnct'], '', '_cnct'); + } + print '
'; + + print '
' . "\n"; + } + print '
' . "\n"; + + print '' . "\n"; + + print '
' . "\n"; + print '
' . "\n"; + print '
' . "\n"; + + print '
'; + print ''; + print_titre($langs->trans("ToClearAllRecipientsClickHere")); + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'; + print '
'; \ No newline at end of file diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index b8126b4fcc8..adfe8cea7e9 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','7.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','7.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index cf0a8c8cc49..1b56391db18 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -710,3 +710,14 @@ ALTER TABLE llx_facture_rec_extrafields ADD INDEX idx_facture_rec_extrafields (f UPDATE llx_cronjob set entity = 1 where entity = 0 and label in ('RecurringInvoices', 'SendEmailsReminders'); UPDATE llx_cronjob set entity = 0 where entity = 1 and label in ('PurgeDeleteTemporaryFilesShort', 'MakeLocalDatabaseDumpShort'); + + + + +-- advtargetmailing + +ALTER TABLE llx_advtargetemailing ADD COLUMN fk_element integer NOT NULL; +ALTER TABLE llx_advtargetemailing ADD COLUMN type_element varchar(180) NOT NULL; +UPDATE llx_advtargetemailing SET fk_element = fk_mailing, type_element="mailing"; +ALTER TABLE llx_advtargetemailing DROP COLUMN fk_mailing; + diff --git a/htdocs/install/mysql/tables/llx_advtargetemailing.sql b/htdocs/install/mysql/tables/llx_advtargetemailing.sql index 395558c700f..3698e5e6626 100644 --- a/htdocs/install/mysql/tables/llx_advtargetemailing.sql +++ b/htdocs/install/mysql/tables/llx_advtargetemailing.sql @@ -22,7 +22,8 @@ CREATE TABLE llx_advtargetemailing rowid integer NOT NULL auto_increment PRIMARY KEY, name varchar(180) NOT NULL, entity integer NOT NULL DEFAULT 1, - fk_mailing integer NOT NULL, + fk_element integer NOT NULL, + type_element varchar(180) NOT NULL, filtervalue text, fk_user_author integer NOT NULL, datec datetime NOT NULL, From d8ebb5da8d9535b44339908ca61c6a48592ed8aa Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Fri, 22 Jun 2018 11:02:20 +0200 Subject: [PATCH 3/3] FIX trans --- htdocs/langs/fr_FR/mails.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/fr_FR/mails.lang b/htdocs/langs/fr_FR/mails.lang index b4454b00234..c3e377ecf8c 100644 --- a/htdocs/langs/fr_FR/mails.lang +++ b/htdocs/langs/fr_FR/mails.lang @@ -107,7 +107,7 @@ MailingNeedCommand2=Vous pouvez toutefois quand même les envoyer par l'interfac ConfirmSendingEmailing=Si vous souhaitez envoyer l'e-mailing depuis cet écran, veuillez confirmer son envoi maintenant, depuis votre navigateur. LimitSendingEmailing=Remarque: L'envoi d'Emailings à partir de l'interface web se fait en plusieurs fois pour des raisons de sécurité et de timeout, %s bénéficiaires à la fois pour chaque session d'envoi. TargetsReset=Vider liste -ToClearAllRecipientsClickHere=Pour vider la liste des destinataires de cet emailing, cliquez sur le bouton +ToClearAllRecipientsClickHere=Pour vider la liste des destinataires, cliquez sur le bouton ToAddRecipientsChooseHere=Pour ajouter des destinataires, choisir dans les listes ci-dessous NbOfEMailingsReceived=Emailings de masse reçus NbOfEMailingsSend=Emailings de masse envoyés