| '.$langs->trans("Group").' / '.$langs->trans("Company").' | '.$langs->trans("EMail").' | '.$langs->trans("Name").' | '.$langs->trans("Lastname").' | '.$langs->trans("Status").' |
';
- foreach($tab_soc as $idp)
+ print $langs->trans("MailingResult")."';
+ print '| '.$langs->trans("Group").' / '.$langs->trans("Company").' | '.$langs->trans("EMail").' | '.$langs->trans("Name").' | '.$langs->trans("Lastname").' | '.$langs->trans("Status").' |
';
+ foreach($tab_soc as $idp)
+ {
+ $h=0;
+ if($cible=="dolusers") {
+ $all_peop_req="SELECT rowid idp, name, firstname, email FROM llx_user";
+ }
+ else {
+ $all_peop_req="SELECT idp, name, firstname, email FROM llx_socpeople WHERE fk_soc=$idp";
+ }
+
+ $all_peop_res = $db->query($all_peop_req);
+ if (! $all_peop_res) {
+ dolibarr_print_error($db);
+ exit;
+ }
+
+ $num_socpeop = $db->num_rows();
+ $j=0;
+ while($j < $num_socpeop)
{
- $h=0;
- if($cible=="dolusers") {
- $all_peop_req="SELECT rowid idp, name, firstname, email FROM llx_user";
- }
- else {
- $all_peop_req="SELECT idp, name, firstname, email FROM llx_socpeople WHERE fk_soc=$idp";
- }
-
- $all_peop_res = $db->query($all_peop_req);
- if (! $all_peop_res) {
- dolibarr_print_error($db);
- exit;
- }
-
- $num_socpeop = $db->num_rows();
- $j=0;
- while($j < $num_socpeop)
+
+ $obj_target = $db->fetch_object($all_peop_res);
+
+ if($obj_target->email!="")
+ {
+ $headers = "MIME-Version: 1.0\r\n";
+ $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
+ $headers .= "From: ".$user->fullname." <".MAILING_EMAIL.">\r\n";
+ $headers .= "Reply-to:".$user->fullname." <".MAILING_EMAIL.">\r\n";
+ $headers .= "X-Priority: 3\r\n";
+ $headers .= "X-Mailer: Dolibarr ".DOL_VERSION."\r\n";
+
+ $m=mail($obj_target->name." ".$obj_target->firstname."<".$obj_target->email.">", $subject, $body, $headers);
+
+ print "| $h | $tab_soc_nom[$h] | $obj_target->email | $obj_target->name | $obj_target->firstname | ";
+ if($m)
{
-
- $obj_target = $db->fetch_object($all_peop_res);
-
- if($obj_target->email!="")
- {
- $headers = "MIME-Version: 1.0\r\n";
- $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
- $headers .= "From: ".$user->fullname." <".MAILING_EMAIL.">\r\n";
- $headers .= "Reply-to:".$user->fullname." <".MAILING_EMAIL.">\r\n";
- $headers .= "X-Priority: 3\r\n";
- $headers .= "X-Mailer: Dolibarr ".DOL_VERSION."\r\n";
-
- $m=mail($obj_target->name." ".$obj_target->firstname."<".$obj_target->email.">", $subject, $body, $headers);
-
- print "
| $h | $tab_soc_nom[$h] | $obj_target->email | $obj_target->name | $obj_target->firstname | ";
- if($m)
- {
- if($cible!="dolusers") {
- print ''.$langs->trans("ResultOk").' | ';
- $sql="INSERT INTO llx_actioncomm (datea, fk_action, fk_soc, fk_user_author, fk_user_action, fk_contact, percent, note,priority,propalrowid) VALUES (NOW(),4, $idp,$user->id,$user->id,$obj_target->idp, '100%', '', 0, 0)";
- $res= $db->query($sql);
- }
- }
- else
- {
- if($cible!="dolusers") {
- print ''.$langs->trans("ResultKo").' | ';
- $sql="INSERT INTO llx_actioncomm (datea, fk_action, fk_soc, fk_user_author, fk_user_action, fk_contact, percent, note,priority,propalrowid) VALUES (NOW(),4, $idp,$user->id,$user->id,$obj_target->idp, '0%', '', 0, 0)";
- $res= $db->query($sql);
- }
- }
- print '
';
- }
- $j++;
+ if($cible!="dolusers") {
+ print ''.$langs->trans("ResultOk").' | ';
+ $sql="INSERT INTO llx_actioncomm (datea, fk_action, fk_soc, fk_user_author, fk_user_action, fk_contact, percent, note,priority,propalrowid) VALUES (NOW(),4, $idp,$user->id,$user->id,$obj_target->idp, '100%', '', 0, 0)";
+ $res= $db->query($sql);
+ }
}
- $h++;
+ else
+ {
+ if($cible!="dolusers") {
+ print ''.$langs->trans("ResultKo").' | ';
+ $sql="INSERT INTO llx_actioncomm (datea, fk_action, fk_soc, fk_user_author, fk_user_action, fk_contact, percent, note,priority,propalrowid) VALUES (NOW(),4, $idp,$user->id,$user->id,$obj_target->idp, '0%', '', 0, 0)";
+ $res= $db->query($sql);
+ }
+ }
+ print '';
+ }
+ $j++;
}
- print '
';
+ $h++;
+ }
+ print '