Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Juanjo Menent 2016-12-10 12:28:09 +01:00
commit d5e28fa3d2
5 changed files with 141 additions and 36 deletions

View File

@ -189,6 +189,10 @@ if ($action == 'add') {
}
}
if ($array_query['type_of_target'] == 2 || $array_query['type_of_target'] == 4) {
$user_contact_query = true;
}
if (preg_match("/^type_of_target/", $key)) {
$array_query[$key] = GETPOST($key);
}
@ -203,8 +207,8 @@ if ($action == 'add') {
$advTarget->thirdparty_lines = array ();
}*/
if ($user_contact_query && ($array_query['type_of_target'] == 1 || $array_query['type_of_target'] == 2)) {
$result = $advTarget->query_contact($array_query);
if ($user_contact_query && ($array_query['type_of_target'] == 1 || $array_query['type_of_target'] == 2 || $array_query['type_of_target'] == 4)) {
$result = $advTarget->query_contact($array_query, 1);
if ($result < 0) {
setEventMessage($advTarget->error, 'errors');
}
@ -889,6 +893,11 @@ if ($object->fetch($id) >= 0) {
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 '<tr><td>' . $extrafields->attribute_label[$key];
@ -900,8 +909,8 @@ if ($object->fetch($id) >= 0) {
print '<input type="text" name="options_' . $key . '_cnct"/></td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchTextHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'int') || ($extrafields->attribute_type[$key] == 'double')) {
print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options' . $key . '_min_cnct"/>';
print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options' . $key . '_max_cnct"/>';
print $langs->trans("AdvTgtMinVal") . '<input type="text" name="options_' . $key . '_min_cnct"/>';
print $langs->trans("AdvTgtMaxVal") . '<input type="text" name="options_' . $key . '_max_cnct"/>';
print '</td><td>' . "\n";
print $form->textwithpicto('', $langs->trans("AdvTgtSearchIntHelp"), 1, 'help');
} elseif (($extrafields->attribute_type[$key] == 'date') || ($extrafields->attribute_type[$key] == 'datetime')) {
@ -967,12 +976,6 @@ if ($object->fetch($id) >= 0) {
print '</form>';
print '<br>';
}
if (empty($conf->mailchimp->enabled) || (! empty($conf->mailchimp->enabled) && $object->statut != 3))
{
// List of recipients (TODO Move code of page cibles.php into a .tpl.php file and make an include here to avoid duplicate content)
}
}
llxFooter();

View File

@ -64,16 +64,19 @@ class AdvanceTargetingMailing extends CommonObject
$this->db = $db;
$this->select_target_type = array('2'=>$langs->trans('Contacts'),'1'=>$langs->trans('Contacts').'+'.$langs->trans('ThirdParty'),
'3'=>$langs->trans('ThirdParty'),
);
$this->type_statuscommprospect=array(
-1=>$langs->trans("StatusProspect-1"),
0=>$langs->trans("StatusProspect0"),
1=>$langs->trans("StatusProspect1"),
2=>$langs->trans("StatusProspect2"),
3=>$langs->trans("StatusProspect3"));
$this->select_target_type = array(
'2' => $langs->trans('Contacts'),
'1' => $langs->trans('Contacts') . '+' . $langs->trans('ThirdParty'),
'3' => $langs->trans('ThirdParty'),
'4' => $langs->trans('ContactsWithThirdpartyFilter')
);
$this->type_statuscommprospect = array(
- 1 => $langs->trans("StatusProspect-1"),
0 => $langs->trans("StatusProspect0"),
1 => $langs->trans("StatusProspect1"),
2 => $langs->trans("StatusProspect2"),
3 => $langs->trans("StatusProspect3")
);
return 1;
}
@ -492,7 +495,7 @@ class AdvanceTargetingMailing extends CommonObject
}
if (!empty($arrayquery['cust_mothercompany'])) {
$str=$this->transformToSQL('nom',$arrayquery['cust_mothercompany']);
$sqlwhere[]= " (t.parent IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "societe WHERE ('.$str.')))";
$sqlwhere[]= " (t.parent IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "societe WHERE (".$str.")))";
}
if (!empty($arrayquery['cust_status']) && count($arrayquery['cust_status'])>0) {
$sqlwhere[]= " (t.status IN (".implode(',',$arrayquery['cust_status'])."))";
@ -603,9 +606,10 @@ class AdvanceTargetingMailing extends CommonObject
* Load object in memory from database
*
* @param array $arrayquery All element to Query
* @param int $withThirdpartyFilter add contact with tridparty filter
* @return int <0 if KO, >0 if OK
*/
function query_contact($arrayquery)
function query_contact($arrayquery, $withThirdpartyFilter = 0)
{
global $langs,$conf;
@ -614,6 +618,11 @@ class AdvanceTargetingMailing extends CommonObject
$sql.= " FROM " . MAIN_DB_PREFIX . "socpeople as t";
$sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "socpeople_extrafields as te ON te.fk_object=t.rowid ";
if (! empty($withThirdpartyFilter)) {
$sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe as ts ON ts.rowid=t.fk_soc";
$sql .= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_extrafields as tse ON tse.fk_object=ts.rowid ";
}
$sqlwhere=array();
$sqlwhere[]= 't.entity IN ('.getEntity('socpeople',1).')';
@ -694,14 +703,107 @@ class AdvanceTargetingMailing extends CommonObject
}
if (! empty($withThirdpartyFilter)) {
if (array_key_exists('cust_saleman', $arrayquery)) {
$sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "societe_commerciaux as saleman ON saleman.fk_soc=ts.rowid ";
}
if (array_key_exists('cust_categ', $arrayquery)) {
$sql.= " LEFT OUTER JOIN " . MAIN_DB_PREFIX . "categorie_societe as custcateg ON custcateg.fk_soc=ts.rowid ";
}
if (!empty($arrayquery['cust_name'])) {
$sqlwhere[]= $this->transformToSQL('ts.nom',$arrayquery['cust_name']);
}
if (!empty($arrayquery['cust_code'])) {
$sqlwhere[]= $this->transformToSQL('ts.code_client',$arrayquery['cust_code']);
}
if (!empty($arrayquery['cust_adress'])) {
$sqlwhere[]= $this->transformToSQL('ts.address',$arrayquery['cust_adress']);
}
if (!empty($arrayquery['cust_zip'])) {
$sqlwhere[]= $this->transformToSQL('ts.zip',$arrayquery['cust_zip']);
}
if (!empty($arrayquery['cust_city'])) {
$sqlwhere[]= $this->transformToSQL('ts.town',$arrayquery['cust_city']);
}
if (!empty($arrayquery['cust_mothercompany'])) {
$str=$this->transformToSQL('nom',$arrayquery['cust_mothercompany']);
$sqlwhere[]= " (ts.parent IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "societe WHERE (".$str.")))";
}
if (!empty($arrayquery['cust_status']) && count($arrayquery['cust_status'])>0) {
$sqlwhere[]= " (ts.status IN (".implode(',',$arrayquery['cust_status'])."))";
}
if (!empty($arrayquery['cust_typecust']) && count($arrayquery['cust_typecust'])>0) {
$sqlwhere[]= " (ts.client IN (".implode(',',$arrayquery['cust_typecust'])."))";
}
if (!empty($arrayquery['cust_comm_status']) && count($arrayquery['cust_comm_status']>0)) {
$sqlwhere[]= " (ts.fk_stcomm IN (".implode(',',$arrayquery['cust_comm_status'])."))";
}
if (!empty($arrayquery['cust_prospect_status']) && count($arrayquery['cust_prospect_status'])>0) {
$sqlwhere[]= " (ts.fk_prospectlevel IN ('".implode("','",$arrayquery['cust_prospect_status'])."'))";
}
if (!empty($arrayquery['cust_typeent']) && count($arrayquery['cust_typeent'])>0) {
$sqlwhere[]= " (ts.fk_typent IN (".implode(',',$arrayquery['cust_typeent'])."))";
}
if (!empty($arrayquery['cust_saleman']) && count($arrayquery['cust_saleman'])>0) {
$sqlwhere[]= " (saleman.fk_user IN (".implode(',',$arrayquery['cust_saleman'])."))";
}
if (!empty($arrayquery['cust_country']) && count($arrayquery['cust_country'])>0) {
$sqlwhere[]= " (ts.fk_pays IN (".implode(',',$arrayquery['cust_country'])."))";
}
if (!empty($arrayquery['cust_effectif_id']) && count($arrayquery['cust_effectif_id'])>0) {
$sqlwhere[]= " (ts.fk_effectif IN (".implode(',',$arrayquery['cust_effectif_id'])."))";
}
if (!empty($arrayquery['cust_categ']) && count($arrayquery['cust_categ'])>0) {
$sqlwhere[]= " (custcateg.fk_categorie IN (".implode(',',$arrayquery['cust_categ'])."))";
}
if (!empty($arrayquery['cust_language']) && count($arrayquery['cust_language'])>0) {
$sqlwhere[]= " (ts.default_lang IN ('".implode("','",$arrayquery['cust_language'])."'))";
}
//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($this->db);
$extralabels=$extrafields->fetch_name_optionals_label('societe');
foreach($extralabels as $key=>$val) {
if (($extrafields->attribute_type[$key] == 'varchar') ||
($extrafields->attribute_type[$key] == 'text')) {
if (!empty($arrayquery['options_'.$key])) {
$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
}
} elseif (($extrafields->attribute_type[$key] == 'int') ||
($extrafields->attribute_type[$key] == 'double')) {
if (!empty($arrayquery['options_'.$key.'_max'])) {
$sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")";
}
} else if (($extrafields->attribute_type[$key] == 'date') ||
($extrafields->attribute_type[$key] == 'datetime')) {
if (!empty($arrayquery['options_'.$key.'_end_dt'])){
$sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')";
}
}else if ($extrafields->attribute_type[$key] == 'boolean') {
if ($arrayquery['options_'.$key]!=''){
$sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")";
}
}else{
if (is_array($arrayquery['options_'.$key])) {
$sqlwhere[]= " (tse.".$key." IN ('".implode("','",$arrayquery['options_'.$key])."'))";
} elseif (!empty($arrayquery['options_'.$key])) {
$sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')";
}
}
}
}
}
}
if (count($sqlwhere)>0) $sql.= " WHERE ".implode(" AND ",$sqlwhere);
}
dol_syslog(get_class($this) . "::query_contact sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {

View File

@ -45,16 +45,16 @@ function emailing_prepare_head(Mailing $object)
$head[$h][1] = $langs->trans("MailRecipients");
if ($object->nbemail > 0) $head[$h][1].= ' <span class="badge">'.$object->nbemail.'</span>';
$head[$h][2] = 'targets';
$h++;
if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
{
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
$head[$h][1] = $langs->trans("MailAdvTargetRecipients");
$head[$h][2] = 'advtargets';
$h++;
}
}
if (! empty($conf->global->EMAILING_USE_ADVANCED_SELECTOR))
{
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/advtargetemailing.php?id=".$object->id;
$head[$h][1] = $langs->trans("MailAdvTargetRecipients");
$head[$h][2] = 'advtargets';
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/info.php?id=".$object->id;

View File

@ -507,9 +507,8 @@ function detect_dolibarr_main_document_root()
{
// If PHP is in CGI mode, SCRIPT_FILENAME is PHP's path.
// Since that's not what we want, we suggest $_SERVER["DOCUMENT_ROOT"]
if (preg_match('/php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/[\\/]php$/i',
$_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"])
) {
if ($_SERVER["SCRIPT_FILENAME"] == 'php' || preg_match('/[\\/]php$/i', $_SERVER["SCRIPT_FILENAME"]) || preg_match('/php\.exe$/i', $_SERVER["SCRIPT_FILENAME"]))
{
$dolibarr_main_document_root = $_SERVER["DOCUMENT_ROOT"];
if (!preg_match('/[\\/]dolibarr[\\/]htdocs$/i', $dolibarr_main_document_root)) {

View File

@ -74,6 +74,7 @@ ResultOfMailSending=Result of mass EMail sending
NbSelected=Nb selected
NbIgnored=Nb ignored
NbSent=Nb sent
ContactsWithThirdpartyFilter=Contact with customer filters
# Libelle des modules de liste de destinataires mailing
LineInFile=Line %s in file