Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
f98f9504f0
@ -123,7 +123,7 @@ print '</td></tr>';
|
|||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $langs->trans("MailingDelay").'</td><td>';
|
print $langs->trans("MailingDelay").'</td><td>';
|
||||||
print '<input size="32" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
|
print '<input class="width75" type="text" name="MAILING_DELAY" value="'.$conf->global->MAILING_DELAY.'">';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -331,10 +331,9 @@ if (empty($reshook))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAILING_DELAY))
|
if (!empty($conf->global->MAILING_DELAY)) {
|
||||||
{
|
|
||||||
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
|
dol_syslog("Wait a delay of MAILING_DELAY=".$conf->global->MAILING_DELAY);
|
||||||
sleep($conf->global->MAILING_DELAY);
|
usleep((float) $conf->global->MAILING_DELAY * 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
//test if CHECK READ change statut prospect contact
|
//test if CHECK READ change statut prospect contact
|
||||||
|
|||||||
@ -463,11 +463,27 @@ if ($object->fetch($id) >= 0)
|
|||||||
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
|
$sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc";
|
||||||
$sql .= " WHERE mc.fk_mailing=".$object->id;
|
$sql .= " WHERE mc.fk_mailing=".$object->id;
|
||||||
if ($search_lastname) $sql .= natural_search("mc.lastname", $search_lastname);
|
$asearchcriteriahasbeenset = 0;
|
||||||
if ($search_firstname) $sql .= natural_search("mc.firstname", $search_firstname);
|
if ($search_lastname) {
|
||||||
if ($search_email) $sql .= natural_search("mc.email", $search_email);
|
$sql .= natural_search("mc.lastname", $search_lastname);
|
||||||
if ($search_other) $sql .= natural_search("mc.other", $search_other);
|
$asearchcriteriahasbeenset++;
|
||||||
if ($search_dest_status != '' && $search_dest_status >= -1) $sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
}
|
||||||
|
if ($search_firstname) {
|
||||||
|
$sql .= natural_search("mc.firstname", $search_firstname);
|
||||||
|
$asearchcriteriahasbeenset++;
|
||||||
|
}
|
||||||
|
if ($search_email) {
|
||||||
|
$sql .= natural_search("mc.email", $search_email);
|
||||||
|
$asearchcriteriahasbeenset++;
|
||||||
|
}
|
||||||
|
if ($search_other) {
|
||||||
|
$sql .= natural_search("mc.other", $search_other);
|
||||||
|
$asearchcriteriahasbeenset++;
|
||||||
|
}
|
||||||
|
if ($search_dest_status != '' && $search_dest_status >= -1) {
|
||||||
|
$sql .= " AND mc.statut=".$db->escape($search_dest_status)." ";
|
||||||
|
$asearchcriteriahasbeenset++;
|
||||||
|
}
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
// Count total nb of records
|
// Count total nb of records
|
||||||
@ -476,11 +492,22 @@ if ($object->fetch($id) >= 0)
|
|||||||
{
|
{
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($result);
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
{
|
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix/update nbemail on emailing record if it differs (may happen if user edit lines from database directly)
|
||||||
|
if (empty($asearchcriteriahasbeenset)) {
|
||||||
|
if ($nbtotalofrecords != $object->email) {
|
||||||
|
dol_syslog("We found a difference in nb of record in target table and the property ->nbemail, we fix ->nbemail");
|
||||||
|
//print "nbemail=".$object->nbemail." nbtotalofrecords=".$nbtotalofrecords;
|
||||||
|
$resultrefresh = $object->refreshNbOfTargets();
|
||||||
|
if ($resultrefresh < 0) {
|
||||||
|
dol_print_error($db, $object->error, $object->errors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
|
//$nbtotalofrecords=$object->nbemail; // nbemail is a denormalized field storing nb of targets
|
||||||
|
|||||||
@ -510,6 +510,8 @@ class Mailing extends CommonObject
|
|||||||
dol_syslog("Mailing::delete_targets", LOG_DEBUG);
|
dol_syslog("Mailing::delete_targets", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
|
$this->refreshNbOfTargets();
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->lasterror();
|
$this->error = $this->db->lasterror();
|
||||||
@ -577,6 +579,38 @@ class Mailing extends CommonObject
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh denormalized value ->nbemail into emailing record
|
||||||
|
* Note: There is also the method update_nb into modules_mailings that is used for this.
|
||||||
|
*
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
public function refreshNbOfTargets()
|
||||||
|
{
|
||||||
|
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles";
|
||||||
|
$sql .= " WHERE fk_mailing = ".$this->id;
|
||||||
|
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql) {
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
if ($obj) {
|
||||||
|
$nbforupdate = $obj->nb;
|
||||||
|
|
||||||
|
$sql = 'UPDATE '.MAIN_DB_PREFIX.'mailing SET nbemail = '.((int) $nbforupdate);
|
||||||
|
$sql .= ' WHERE rowid = '.$this->id;
|
||||||
|
|
||||||
|
$resqlupdate = $this->db->query($sql);
|
||||||
|
if (! $resqlupdate) {
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->error = $this->db->lasterror();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a link to the object card (with optionally the picto)
|
* Return a link to the object card (with optionally the picto)
|
||||||
|
|||||||
@ -74,6 +74,10 @@ if (empty($conf->global->MAILING_LIMIT_SENDBYCLI))
|
|||||||
@set_time_limit(0);
|
@set_time_limit(0);
|
||||||
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
print "***** ".$script_file." (".$version.") pid=".dol_getmypid()." *****\n";
|
||||||
|
|
||||||
|
if (!empty($conf->global->MAILING_DELAY)) {
|
||||||
|
print 'A delay of '.((float) $conf->global->MAILING_DELAY * 1000000).' millisecond has been set between each email'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {}
|
if ($conf->global->MAILING_LIMIT_SENDBYCLI == '-1') {}
|
||||||
|
|
||||||
$user = new User($db);
|
$user = new User($db);
|
||||||
@ -332,7 +336,7 @@ if ($resql) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->global->MAILING_DELAY)) {
|
if (!empty($conf->global->MAILING_DELAY)) {
|
||||||
sleep($conf->global->MAILING_DELAY);
|
usleep((float) $conf->global->MAILING_DELAY * 1000000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user