Beispiel #1
0
 /**
  *	Load an object from its id and create a new one in database
  *
  *	@param  int		$fromid     	Id of object to clone
  *	@param	int		$option1		1=Copy content, 0=Forget content
  *	@param	int		$option2		Not used
  *	@return	int						New id of clone
  */
 function createFromClone($fromid, $option1, $option2)
 {
     global $user, $langs;
     $error = 0;
     $object = new Mailing($this->db);
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     $object->titre = $langs->trans("CopyOf") . ' ' . $object->titre . ' ' . dol_print_date(dol_now());
     // If no option copy content
     if (empty($option1)) {
         // Clear values
         $object->nbemail = 0;
         $object->sujet = '';
         $object->body = '';
         $object->bgcolor = '';
         $object->bgimage = '';
         $object->email_from = '';
         $object->email_replyto = '';
         $object->email_errorsto = '';
         $object->user_creat = $user->id;
         $object->user_valid = '';
         $object->date_creat = '';
         $object->date_valid = '';
         $object->date_envoi = '';
     }
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
     }
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
Beispiel #2
0
    } else {
        dol_print_error($db);
    }
}
if ($_POST["button_removefilter"]) {
    $search_lastname = '';
    $search_firstname = '';
    $search_email = '';
}
/*
 * View
 */
llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing');
$form = new Form($db);
$formmailing = new FormMailing($db);
if ($object->fetch($id) >= 0) {
    $head = emailing_prepare_head($object);
    dol_fiche_head($head, 'targets', $langs->trans("Mailing"), 0, 'email');
    print '<table class="border" width="100%">';
    $linkback = '<a href="' . DOL_URL_ROOT . '/comm/mailing/list.php">' . $langs->trans("BackToList") . '</a>';
    print '<tr><td width="25%">' . $langs->trans("Ref") . '</td>';
    print '<td colspan="3">';
    print $form->showrefnav($object, 'id', $linkback);
    print '</td></tr>';
    print '<tr><td width="25%">' . $langs->trans("MailTitle") . '</td><td colspan="3">' . $object->titre . '</td></tr>';
    print '<tr><td width="25%">' . $langs->trans("MailFrom") . '</td><td colspan="3">' . dol_print_email($object->email_from, 0, 0, 0, 0, 1) . '</td></tr>';
    // Errors to
    print '<tr><td width="25%">' . $langs->trans("MailErrorsTo") . '</td><td colspan="3">' . dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1);
    print '</td></tr>';
    // Status
    print '<tr><td width="25%">' . $langs->trans("Status") . '</td><td colspan="3">' . $object->getLibStatut(4) . '</td></tr>';
Beispiel #3
0
 /**
  *	Load an object from its id and create a new one in database
  *
  *	@param  int		$fromid     	Id of object to clone
  *	@param	int		$option1		1=Copy content, 0=Forget content
  *	@param	int		$option2		Not used
  *	@return	int						New id of clone
  */
 function createFromClone($fromid, $option1, $option2)
 {
     global $user, $langs;
     $error = 0;
     $object = new Mailing($this->db);
     $object->context['createfromclone'] = 'createfromclone';
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     $object->titre = $langs->trans("CopyOf") . ' ' . $object->titre . ' ' . dol_print_date(dol_now());
     // If no option copy content
     if (empty($option1)) {
         // Clear values
         $object->nbemail = 0;
         $object->sujet = '';
         $object->body = '';
         $object->bgcolor = '';
         $object->bgimage = '';
         $object->email_from = '';
         $object->email_replyto = '';
         $object->email_errorsto = '';
         $object->user_creat = $user->id;
         $object->user_valid = '';
         $object->date_creat = '';
         $object->date_valid = '';
         $object->date_envoi = '';
     }
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
         //Clone target
         if (!empty($option2)) {
             require_once DOL_DOCUMENT_ROOT . '/core/modules/mailings/modules_mailings.php';
             $mailing_target = new MailingTargets($this->db);
             $target_array = array();
             $sql = "SELECT fk_contact, ";
             $sql .= " lastname,   ";
             $sql .= " firstname,";
             $sql .= " email,";
             $sql .= " other,";
             $sql .= " source_url,";
             $sql .= " source_id ,";
             $sql .= " source_type ";
             $sql .= " FROM " . MAIN_DB_PREFIX . "mailing_cibles ";
             $sql .= " WHERE fk_mailing = " . $fromid;
             dol_syslog(get_class($this) . "::createFromClone", LOG_DEBUG);
             $result = $this->db->query($sql);
             if ($result) {
                 if ($this->db->num_rows($result)) {
                     while ($obj = $this->db->fetch_object($result)) {
                         $target_array[] = array('fk_contact' => $obj->fk_contact, 'lastname' => $obj->lastname, 'firstname' => $obj->firstname, 'email' => $obj->email, 'other' => $obj->other, 'source_url' => $obj->source_url, 'source_id' => $obj->source_id, 'source_type' => $obj->source_type);
                     }
                 }
             } else {
                 $this->error = $this->db->lasterror();
                 return -1;
             }
             $mailing_target->add_to_target($object->id, $target_array);
         }
     }
     unset($object->context['createfromclone']);
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
$langs->load("mails");
if (!$user->rights->mailing->lire || empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->societe_id > 0) {
    accessforbidden();
}
$id = GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$urlfrom = GETPOST('urlfrom');
$object = new Mailing($db);
$result = $object->fetch($id);
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('mailingcard'));
// Array of possible substitutions (See also file mailing-send.php that should manage same substitutions)
$object->substitutionarray = array('__ID__' => 'IdRecord', '__EMAIL__' => 'EMail', '__LASTNAME__' => 'Lastname', '__FIRSTNAME__' => 'Firstname', '__MAILTOEMAIL__' => 'TagMailtoEmail', '__OTHER1__' => 'Other1', '__OTHER2__' => 'Other2', '__OTHER3__' => 'Other3', '__OTHER4__' => 'Other4', '__OTHER5__' => 'Other5', '__SIGNATURE__' => 'TagSignature', '__CHECK_READ__' => 'TagCheckMail', '__UNSUBSCRIBE__' => 'TagUnsubscribe');
if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_SECURITY_TOKEN)) {
    $object->substitutionarray['__SECUREKEYPAYPAL__'] = 'SecureKeyPaypal';
    if (!empty($conf->global->PAYPAL_SECURITY_TOKEN_UNIQUE)) {
        $object->substitutionarray['__SECUREKEYPAYPAL_MEMBER__'] = 'SecureKeyPaypalUniquePerMember';
    }
}
$object->substitutionarrayfortest = array('__ID__' => 'TESTIdRecord', '__EMAIL__' => 'TESTEMail', '__LASTNAME__' => 'TESTLastname', '__FIRSTNAME__' => 'TESTFirstname', '__MAILTOEMAIL__' => 'TESTMailtoEmail', '__OTHER1__' => 'TESTOther1', '__OTHER2__' => 'TESTOther2', '__OTHER3__' => 'TESTOther3', '__OTHER4__' => 'TESTOther4', '__OTHER5__' => 'TESTOther5', '__SIGNATURE__' => $user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN) ? $user->signature : '', '__CHECK_READ__' => 'TagCheckMail', '__UNSUBSCRIBE__' => 'TagUnsubscribe');
/*
Beispiel #5
0
 *		\brief      Page with log information for emailing
 */
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT . '/comm/mailing/class/mailing.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/emailing.lib.php';
$langs->load("mails");
// Security check
if (!$user->rights->mailing->lire || $user->societe_id > 0) {
    accessforbidden();
}
/*
 * View
 */
llxHeader('', $langs->trans("Mailing"), 'EN:Module_EMailing|FR:Module_Mailing|ES:M&oacute;dulo_Mailing');
$form = new Form($db);
$mil = new Mailing($db);
if ($mil->fetch($_REQUEST["id"]) >= 0) {
    $head = emailing_prepare_head($mil);
    dol_fiche_head($head, 'info', $langs->trans("Mailing"), 0, 'email');
    print '<table width="100%"><tr><td>';
    $mil->user_creation = $mil->user_creat;
    $mil->date_creation = $mil->date_creat;
    $mil->user_validation = $mil->user_valid;
    $mil->date_validation = $mil->date_valid;
    dol_print_object_info($mil);
    print '</td></tr></table>';
    print '</div>';
}
llxFooter();
$db->close();
Beispiel #6
0
	print '</i></td>';
	print '<td>';
	// Editeur wysiwyg
	require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
	$doleditor=new DolEditor('body',$_POST['body'],'',320,'dolibarr_mailings','',true,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING,20,70);
	$doleditor->Create();
	print '</td></tr>';
	print '</table>';

	print '<br><center><input type="submit" class="button" value="'.$langs->trans("CreateMailing").'"></center>';

	print '</form>';
}
else
{
	if ($mil->fetch($_GET["id"]) >= 0)
	{
		$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1);

		$head = emailing_prepare_head($mil);

		dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email');

		if ($message) print $message."<br>";

		// Confirmation de la validation du mailing
		if ($_GET["action"] == 'valid')
		{
			$ret=$html->form_confirm($_SERVER["PHP_SELF"]."?id=".$mil->id,$langs->trans("ValidMailing"),$langs->trans("ConfirmValidMailing"),"confirm_valid",'','',1);
			if ($ret == 'html') print '<br>';
		}