diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index dda893c5350..20aa084760e 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -170,6 +170,7 @@ if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$la if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty'); if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember'); if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract'); +$elementList['user']=$langs->trans('MailToUser'); $elementList['all'] =$langs->trans('VisibleEverywhere'); $elementList['none']=$langs->trans('VisibleNowhere'); @@ -227,7 +228,7 @@ if (empty($reshook)) if ($value == 'content') continue; if ($value == 'content_lines') continue; - if ($value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; + if (GETPOST('actionmodify') && $value == 'topic') $_POST['topic']=$_POST['topic-'.$rowid]; if ((! isset($_POST[$value]) || $_POST[$value]=='' || $_POST[$value]=='-1') && $value != 'lang' && $value != 'fk_user' && $value != 'position') { @@ -857,6 +858,8 @@ if ($resql) if ($value == 'joinfiles') { $align="center"; + if ($valuetoshow) $valuetoshow=1; + else $valuetoshow=''; } $class='tddict'; diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 4439f0034ce..7b1db834d22 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -113,14 +113,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $result=$object->fetch($id); $sendtosocid=0; // Thirdparty on object - if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member'))) + if (method_exists($object,"fetch_thirdparty") && ! in_array($object->element, array('societe','member','user'))) { $result=$object->fetch_thirdparty(); if ($object->element == 'user' && $result == 0) $result=1; // Even if not found, we consider ok $thirdparty=$object->thirdparty; $sendtosocid=$thirdparty->id; } - else if ($object->element == 'member') + else if ($object->element == 'member' || $object->element == 'user') { $thirdparty=$object; if ($thirdparty->id > 0) $sendtosocid=$thirdparty->id; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 0621e1d21f4..788fa723cdb 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -271,16 +271,6 @@ class FormMail extends Form $disablebademails=1; - // Define list of attached files - $listofpaths=array(); - $listofnames=array(); - $listofmimes=array(); - $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined - - if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); - if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); - if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); - // Define output language $outputlangs = $langs; $newlang = ''; @@ -307,6 +297,30 @@ class FormMail extends Form //var_dump($model_id); //var_dump($arraydefaultmessage); + + // Define list of attached files + $listofpaths=array(); + $listofnames=array(); + $listofmimes=array(); + $keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined + + if (GETPOST('mode','alpha') == 'init' || (GETPOST('modelmailselected','alpha') && GETPOST('modelmailselected','alpha') != '-1')) + { + $this->clear_attached_files(); + if (! empty($arraydefaultmessage['joinfiles']) && is_array($this->param['fileinit'])) + { + foreach($this->param['fileinit'] as $file) + { + $this->add_attached_files($file, basename($file), dol_mimetype($file)); + } + } + } + + if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';',$_SESSION["listofpaths".$keytoavoidconflict]); + if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';',$_SESSION["listofnames".$keytoavoidconflict]); + if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';',$_SESSION["listofmimes".$keytoavoidconflict]); + + $out.= "\n".'
'."\n"; if ($this->withform == 1) { @@ -369,7 +383,7 @@ class FormMail extends Form elseif (! empty($this->param['models']) && in_array($this->param['models'], array( 'propal_send','order_send','facture_send', 'shipping_send','fichinter_send','supplier_proposal_send','order_supplier_send', - 'invoice_supplier_send','thirdparty','contract','all' + 'invoice_supplier_send','thirdparty','contract','user','all' ))) { // If list of template is empty @@ -922,7 +936,7 @@ class FormMail extends Form { $ret=array(); - $sql = "SELECT label, topic, content, content_lines, lang"; + $sql = "SELECT label, topic, joinfiles, content, content_lines, lang"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; $sql.= " WHERE (type_template='".$db->escape($type_template)."' OR type_template='all')"; $sql.= " AND entity IN (".getEntity('c_email_templates', 0).")"; @@ -942,10 +956,11 @@ class FormMail extends Form if ($obj) { $ret['label']=$obj->label; + $ret['lang']=$obj->lang; $ret['topic']=$obj->topic; + $ret['joinfiles']=$obj->joinfiles; $ret['content']=$obj->content; $ret['content_lines']=$obj->content_lines; - $ret['lang']=$obj->lang; } else // If there is no template at all { @@ -963,10 +978,11 @@ class FormMail extends Form elseif ($type_template=='user') { $defaultmessage=$outputlangs->transnoentities("PredefinedMailContentUser"); } $ret['label']='default'; + $ret['lang']=$outputlangs->defaultlang; $ret['topic']=''; + $ret['joinfiles']=1; $ret['content']=$defaultmessage; $ret['content_lines']=''; - $ret['lang']=$outputlangs->defaultlang; } $db->free($resql); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c364875044a..41716d5d78a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5296,6 +5296,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__SECUREKEYPAYMENT_ORDER__'] = 'Security key for payment on an order'; $substitutionarray['__SECUREKEYPAYMENT_INVOICE__'] = 'Security key for payment on an invoice'; $substitutionarray['__SECUREKEYPAYMENT_CONTRACTLINE__'] = 'Security key for payment on a a service'; + + $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number'; + $substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url'; + } else { @@ -5340,15 +5344,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__PROJECT_NAME__'] = (is_object($object->projet)?$object->projet->title:''); } - // Create dynamic tags for __EXTRAFIELD_FIELD__ - if ($object->table_element && $object->id > 0) + if (is_object($object) && $object->element == 'shipping') { - $extrafieldstmp = new ExtraFields($db); - $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); - $object->fetch_optionals($object->id, $extralabels); - foreach ($extrafieldstmp->attribute_label as $key => $label) { - $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; - } + $substitutionarray['__SHIPPINGTRACKNUM__']=$object->tracking_number; + $substitutionarray['__SHIPPINGTRACKNUMURL__']=$object->tracking_url; } if (is_object($object) && $object->element == 'contrat' && is_array($object->lines)) @@ -5366,6 +5365,17 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard'); } + // Create dynamic tags for __EXTRAFIELD_FIELD__ + if ($object->table_element && $object->id > 0) + { + $extrafieldstmp = new ExtraFields($db); + $extralabels = $extrafieldstmp->fetch_name_optionals_label($object->table_element, true); + $object->fetch_optionals($object->id, $extralabels); + foreach ($extrafieldstmp->attribute_label as $key => $label) { + $substitutionarray['__EXTRAFIELD_' . strtoupper($key) . '__'] = $object->array_options['options_' . $key]; + } + } + $substitutionarray['__ONLINE_PAYMENT_URL__'] = 'TODO'; } } diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php index aa9353201cf..6e653372148 100644 --- a/htdocs/core/tpl/card_presend.tpl.php +++ b/htdocs/core/tpl/card_presend.tpl.php @@ -129,7 +129,7 @@ if ($action == 'presend') $liste[$key] = $value; } } - elseif ($object->element == 'member') + elseif ($object->element == 'user' || $object->element == 'member') { $liste['thirdparty'] = $object->getFullName($langs)." <".$object->email.">"; } @@ -169,12 +169,15 @@ if ($action == 'presend') $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id'] = $object->id; $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; + $formmail->param['fileinit'] = array($file); // Init list of files - if (GETPOST("mode") == 'init') { + /*if (GETPOST('mode','alpha') == 'init') + { $formmail->clear_attached_files(); + $formmail->add_attached_files($file, basename($file), dol_mimetype($file)); - } + }*/ // Show form print $formmail->get_form(); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 1500affbcda..9fa609d9d76 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2151,6 +2151,16 @@ else if ($id || $ref) if (GETPOST('modelselected')) { $action = 'presend'; } + + // Presend form + $modelmail='shipping_send'; + $defaulttopic='SendShippingRef'; + $diroutput = $conf->expedition->dir_output. '/sending'; + $trackid = 'shi'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + + /* if ($action == 'presend') { $ref = dol_sanitizeFileName($object->ref); @@ -2278,7 +2288,7 @@ else if ($id || $ref) print $formmail->get_form(); dol_fiche_end(); - } + }*/ } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 41ffeae3f67..1e7dc926ff9 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1712,6 +1712,7 @@ MailToSendSupplierInvoice=To send supplier invoice MailToSendContract=To send a contract MailToThirdparty=To send email from third party page MailToMember=To send email from member page +MailToUser=To send email from user page ByDefaultInList=Show by default on list view YouUseLastStableVersion=You use the latest stable version TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index a8d6bacdf31..bbc8f34a92e 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -79,14 +79,14 @@ NbOfActiveNotifications=Number of notifications (nb of recipient emails) PredefinedMailTest=This is a test mail sent to __EMAIL__.\nThe two lines are separated by a carriage return.\n\n__SIGNATURE__ PredefinedMailTestHtml=This is a test mail (the word test must be in bold).