/** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { global $conf, $langs, $user, $hookmanager, $form; if (!is_object($form)) { $form = new Form($this->db); } $langs->load("other"); $langs->load("mails"); $hookmanager->initHooks(array('formmail')); $parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction); $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); if (!empty($reshook)) { return $hookmanager->resPrint; } else { $out = ''; // Define list of attached files $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($_SESSION["listofpaths"])) { $listofpaths = explode(';', $_SESSION["listofpaths"]); } if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } $out .= "\n<!-- Debut form mail -->\n"; if ($this->withform == 1) { $out .= '<form method="POST" name="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">' . "\n"; $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />'; } foreach ($this->param as $key => $value) { $out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n"; } $out .= '<table class="border" width="100%">' . "\n"; // Substitution array if (!empty($this->withsubstit)) { $out .= '<tr><td colspan="2">'; $help = ""; foreach ($this->substit as $key => $val) { $help .= $key . ' -> ' . $langs->trans($val) . '<br>'; } $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help); $out .= "</td></tr>\n"; } // From if (!empty($this->withfrom)) { if (!empty($this->withfromreadonly)) { $out .= '<input type="hidden" id="fromname" name="fromname" value="' . $this->fromname . '" />'; $out .= '<input type="hidden" id="frommail" name="frommail" value="' . $this->frommail . '" />'; $out .= '<tr><td width="180">' . $langs->trans("MailFrom") . '</td><td>'; if ($this->fromtype == 'user' && $this->fromid > 0) { $langs->load("users"); $fuser = new User($this->db); $fuser->fetch($this->fromid); $out .= $fuser->getNomUrl(1); } else { $out .= $this->fromname; } if ($this->frommail) { $out .= " <" . $this->frommail . ">"; } else { if ($this->fromtype) { $langs->load("errors"); $out .= '<font class="warning"> <' . $langs->trans("ErrorNoMailDefinedForThisUser") . '> </font>'; } } $out .= "</td></tr>\n"; $out .= "</td></tr>\n"; } else { $out .= "<tr><td>" . $langs->trans("MailFrom") . "</td><td>"; $out .= $langs->trans("Name") . ':<input type="text" id="fromname" name="fromname" size="32" value="' . $this->fromname . '" />'; $out .= ' '; $out .= $langs->trans("EMail") . ':<<input type="text" id="frommail" name="frommail" size="32" value="' . $this->frommail . '" />>'; $out .= "</td></tr>\n"; } } // Replyto if (!empty($this->withreplyto)) { if ($this->withreplytoreadonly) { $out .= '<input type="hidden" id="replyname" name="replyname" value="' . $this->replytoname . '" />'; $out .= '<input type="hidden" id="replymail" name="replymail" value="' . $this->replytomail . '" />'; $out .= "<tr><td>" . $langs->trans("MailReply") . "</td><td>" . $this->replytoname . ($this->replytomail ? " <" . $this->replytomail . ">" : ""); $out .= "</td></tr>\n"; } } // Errorsto if (!empty($this->witherrorsto)) { //if (! $this->errorstomail) $this->errorstomail=$this->frommail; $errorstomail = !empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail; if ($this->witherrorstoreadonly) { $out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= $errorstomail; $out .= "</td></tr>\n"; } else { $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= '<input size="30" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= "</td></tr>\n"; } } // To if (!empty($this->withto) || is_array($this->withto)) { $out .= '<tr><td width="180">'; if ($this->withtofree) { $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); } else { $out .= $langs->trans("MailTo"); } $out .= '</td><td>'; if ($this->withtoreadonly) { if (!empty($this->toname) && !empty($this->tomail)) { $out .= '<input type="hidden" id="toname" name="toname" value="' . $this->toname . '" />'; $out .= '<input type="hidden" id="tomail" name="tomail" value="' . $this->tomail . '" />'; if ($this->totype == 'thirdparty') { $soc = new Societe($this->db); $soc->fetch($this->toid); $out .= $soc->getNomUrl(1); } else { if ($this->totype == 'contact') { $contact = new Contact($this->db); $contact->fetch($this->toid); $out .= $contact->getNomUrl(1); } else { $out .= $this->toname; } } $out .= ' <' . $this->tomail . '>'; if ($this->withtofree) { $out .= '<br>' . $langs->trans("or") . ' <input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } } else { $out .= !is_array($this->withto) && !is_numeric($this->withto) ? $this->withto : ""; } } else { if (!empty($this->withtofree)) { $out .= '<input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } if (!empty($this->withto) && is_array($this->withto)) { if (!empty($this->withtofree)) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); } if (isset($this->withtosocid) && $this->withtosocid > 0) { $liste = array(); $soc = new Societe($this->db); $soc->fetch($this->withtosocid); foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; } if ($this->withtofree) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); } } $out .= "</td></tr>\n"; } // CC if (!empty($this->withtocc) || is_array($this->withtocc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if ($this->withtoccreadonly) { $out .= !is_array($this->withtocc) && !is_numeric($this->withtocc) ? $this->withtocc : ""; } else { $out .= '<input size="' . (is_array($this->withtocc) ? "30" : "60") . '" id="sendtocc" name="sendtocc" value="' . (!is_array($this->withtocc) && !is_numeric($this->withtocc) ? isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")) . '" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1); } } $out .= "</td></tr>\n"; } // CCC if (!empty($this->withtoccc) || is_array($this->withtoccc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if (!empty($this->withtocccreadonly)) { $out .= !is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? $this->withtoccc : ""; } else { $out .= '<input size="' . (is_array($this->withtoccc) ? "30" : "60") . '" id="sendtoccc" name="sendtoccc" value="' . (!is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")) . '" />'; if (!empty($this->withtoccc) && is_array($this->withtoccc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); } } //if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print ' '.info_admin("+ ".$conf->global->MAIN_MAIL_AUTOCOPY_TO,1); $out .= "</td></tr>\n"; } // Ask delivery receipt if (!empty($this->withdeliveryreceipt)) { $out .= '<tr><td width="180">' . $langs->trans("DeliveryReceipt") . '</td><td>'; if (!empty($this->withdeliveryreceiptreadonly)) { $out .= yn($this->withdeliveryreceipt); } else { $out .= $form->selectyesno('deliveryreceipt', isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : 0, 1); } $out .= "</td></tr>\n"; } // Topic if (!empty($this->withtopic)) { $this->withtopic = make_substitutions($this->withtopic, $this->substit); $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailTopic") . '</td>'; $out .= '<td>'; if ($this->withtopicreadonly) { $out .= $this->withtopic; $out .= '<input type="hidden" size="60" id="subject" name="subject" value="' . $this->withtopic . '" />'; } else { $out .= '<input type="text" size="60" id="subject" name="subject" value="' . (isset($_POST["subject"]) ? $_POST["subject"] : (is_numeric($this->withtopic) ? '' : $this->withtopic)) . '" />'; } $out .= "</td></tr>\n"; } // Attached files if (!empty($this->withfile)) { $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>'; $out .= '<td>'; if (is_numeric($this->withfile)) { // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; $out .= '<script type="text/javascript" language="javascript">'; $out .= 'jQuery(document).ready(function () {'; $out .= ' jQuery(".removedfile").click(function() {'; $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; $out .= ' });'; $out .= '})'; $out .= '</script>' . "\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '<div id="attachfile_' . $key . '">'; $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; if (!$this->withfilereadonly) { $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>'; } $out .= '<br></div>'; } } else { $out .= $langs->trans("NoAttachedFiles") . '<br>'; } if ($this->withfile == 2) { $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; $out .= ' '; $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />'; } } else { $out .= $this->withfile; } $out .= "</td></tr>\n"; } // Message if (!empty($this->withbody)) { $defaultmessage = ""; // TODO A partir du type, proposer liste de messages dans table llx_c_email_template if ($this->param["models"] == 'facture_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoice"); } elseif ($this->param["models"] == 'facture_relance') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendInvoiceReminder"); } elseif ($this->param["models"] == 'propal_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendProposal"); } elseif ($this->param["models"] == 'order_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendOrder"); } elseif ($this->param["models"] == 'order_supplier_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierOrder"); } elseif ($this->param["models"] == 'invoice_supplier_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendSupplierInvoice"); } elseif ($this->param["models"] == 'shipping_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendShipping"); } elseif ($this->param["models"] == 'fichinter_send') { $defaultmessage = $langs->transnoentities("PredefinedMailContentSendFichInter"); } elseif ($this->param["models"] == 'thirdparty') { $defaultmessage = $langs->transnoentities("PredefinedMailContentThirdparty"); } elseif (!is_numeric($this->withbody)) { $defaultmessage = $this->withbody; } // Complete substitution array if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) { require_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; $langs->load('paypal'); if ($this->param["models"] == 'order_send') { $url = getPaypalPaymentUrl(0, 'order', $this->substit['__ORDERREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } if ($this->param["models"] == 'facture_send') { $url = getPaypalPaymentUrl(0, 'invoice', $this->substit['__FACREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } } $defaultmessage = str_replace('\\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']); } else { if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } } if (isset($_POST["message"])) { $defaultmessage = $_POST["message"]; } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage); $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } $out .= '<tr>'; $out .= '<td width="180" valign="top">' . $langs->trans("MailText") . '</td>'; $out .= '<td>'; if ($this->withbodyreadonly) { $out .= nl2br($defaultmessage); $out .= '<input type="hidden" id="message" name="message" value="' . $defaultmessage . '" />'; } else { if (!isset($this->ckeditortoolbar)) { $this->ckeditortoolbar = 'dolibarr_notes'; } // Editor wysiwyg require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if ($this->withfckeditor == -1) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $this->withfckeditor = 1; } else { $this->withfckeditor = 0; } } $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, 72); $out .= $doleditor->Create(1); } $out .= "</td></tr>\n"; } if ($this->withform == 1 || $this->withform == -1) { $out .= '<tr><td align="center" colspan="2"><center>'; $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="' . $langs->trans("SendMail") . '"'; // Add a javascript test to avoid to forget to submit file before sending email if ($this->withfile == 2 && $conf->use_javascript_ajax) { $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\'' . dol_escape_js($langs->trans("FileWasNotUploaded")) . '\'); return false; } else { return true; }"'; } $out .= ' />'; if ($this->withcancel) { $out .= ' '; $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="' . $langs->trans("Cancel") . '" />'; } $out .= '</center></td></tr>' . "\n"; } $out .= '</table>' . "\n"; if ($this->withform == 1) { $out .= '</form>' . "\n"; } $out .= "<!-- Fin form mail -->\n"; return $out; } }
/** * Show list of documents in a directory * * @param string $upload_dir Directory that was scanned * @param array $filearray Array of files loaded by dol_dir_list function before calling this function * @param string $modulepart Value for modulepart used by download wrapper * @param string $param Parameters on sort links * @param int $forcedownload Force to open dialog box "Save As" when clicking on file * @param string $relativepath Relative path of docs (autodefined if not provided) * @param int $permtodelete Permission to delete * @param int $useinecm Change output for use in ecm module * @param int $textifempty Text to show if filearray is empty * @param int $maxlength Maximum length of file name shown * @param string $url Full url to use for click links ('' = autodetect) * @return int <0 if KO, nb of files shown if OK */ function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '') { global $user, $conf, $langs; global $bc; global $sortfield, $sortorder; dol_syslog(get_class($this) . '::list_of_autoecmfiles upload_dir=' . $upload_dir . ' modulepart=' . $modulepart); // Show list of documents if (empty($useinecm)) { print load_fiche_titre($langs->trans("AttachedFiles")); } if (empty($url)) { $url = $_SERVER["PHP_SELF"]; } print '<table width="100%" class="nobordernopadding">'; print '<tr class="liste_titre">'; $sortref = "fullname"; if ($modulepart == 'invoice_supplier') { $sortref = 'level1name'; } print_liste_field_titre($langs->trans("Ref"), $url, $sortref, "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Documents2"), $url, "name", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Size"), $url, "size", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Date"), $url, "date", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre('', '', ''); print '</tr>'; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { include_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; $object_instance = new Societe($this->db); } else { if ($modulepart == 'invoice') { include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; $object_instance = new Facture($this->db); } else { if ($modulepart == 'invoice_supplier') { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; $object_instance = new FactureFournisseur($this->db); } else { if ($modulepart == 'propal') { include_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; $object_instance = new Propal($this->db); } else { if ($modulepart == 'supplier_proposal') { include_once DOL_DOCUMENT_ROOT . '/supplier_proposal/class/supplier_proposal.class.php'; $object_instance = new SupplierProposal($this->db); } else { if ($modulepart == 'order') { include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; $object_instance = new Commande($this->db); } else { if ($modulepart == 'order_supplier') { include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php'; $object_instance = new CommandeFournisseur($this->db); } else { if ($modulepart == 'contract') { include_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php'; $object_instance = new Contrat($this->db); } else { if ($modulepart == 'product') { include_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; $object_instance = new Product($this->db); } else { if ($modulepart == 'tax') { include_once DOL_DOCUMENT_ROOT . '/compta/sociales/class/chargesociales.class.php'; $object_instance = new ChargeSociales($this->db); } else { if ($modulepart == 'project') { include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php'; $object_instance = new Project($this->db); } else { if ($modulepart == 'fichinter') { include_once DOL_DOCUMENT_ROOT . '/fichinter/class/fichinter.class.php'; $object_instance = new Fichinter($this->db); } else { if ($modulepart == 'user') { include_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php'; $object_instance = new User($this->db); } } } } } } } } } } } } } $var = true; foreach ($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && !preg_match('/\\.meta$/i', $file['name'])) { // Define relative path used to store the file $relativefile = preg_replace('/' . preg_quote($upload_dir . '/', '/') . '/', '', $file['fullname']); //var_dump($file); $id = 0; $ref = ''; $label = ''; // To show ref or specific information according to view to show (defined by $module) if ($modulepart == 'company') { preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'invoice') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'invoice_supplier') { preg_match('/([^\\/]+)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; if (is_numeric($ref)) { $id = $ref; $ref = ''; } } // $ref may be also id with old supplier invoices if ($modulepart == 'propal') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'supplier_proposal') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'order') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'order_supplier') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'contract') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'product') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'tax') { preg_match('/(\\d+)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'project') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'fichinter') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $ref = isset($reg[1]) ? $reg[1] : ''; } if ($modulepart == 'user') { preg_match('/(.*)\\/[^\\/]+$/', $relativefile, $reg); $id = isset($reg[1]) ? $reg[1] : ''; } if (!$id && !$ref) { continue; } $found = 0; if (!empty($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { $found = 1; } else { //print 'Fetch '.$id." - ".$ref.'<br>'; if ($id) { $result = $object_instance->fetch($id); } else { //fetchOneLike looks for objects with wildcards in its reference. //It is useful for those masks who get underscores instead of their actual symbols //fetchOneLike requires some info in the object. If it doesn't have it, then 0 is returned //that's why we look only look fetchOneLike when fetch returns 0 if (!($result = $object_instance->fetch('', $ref))) { $result = $object_instance->fetchOneLike($ref); } } if ($result > 0) { // Save object into a cache $found = 1; $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = clone $object_instance; } if ($result == 0) { $found = 1; $this->cache_objects[$modulepart . '_' . $id . '_' . $ref] = 'notfound'; unset($filearray[$key]); } } if (!$found > 0 || !is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { continue; } // We do not show orphelins files $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>'; if ($found > 0 && is_object($this->cache_objects[$modulepart . '_' . $id . '_' . $ref])) { print $this->cache_objects[$modulepart . '_' . $id . '_' . $ref]->getNomUrl(1, 'document'); } else { print $langs->trans("ObjectDeleted", $id ? $id : $ref); } print '</td>'; print '<td>'; //print "XX".$file['name']; //$file['name'] must be utf8 print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart; if ($forcedownload) { print '&attachment=1'; } print '&file=' . urlencode($relativefile) . '">'; print img_mime($file['name'], $file['name'] . ' (' . dol_print_size($file['size'], 0, 0) . ')') . ' '; print dol_trunc($file['name'], $maxlength, 'middle'); print '</a>'; print "</td>\n"; print '<td align="right">' . dol_print_size($file['size'], 1, 1) . '</td>'; print '<td align="center">' . dol_print_date($file['date'], "dayhour") . '</td>'; print '<td align="right">'; if (!empty($useinecm)) { print '<a data-ajax="false" href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart; } if ($forcedownload) { print '&attachment=1'; } print '&file=' . urlencode($relativefile) . '">'; print img_view() . '</a> '; //if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>'; //else print ' '; print "</td></tr>\n"; } } if (count($filearray) == 0) { print '<tr ' . $bc[false] . '><td colspan="4">'; if (empty($textifempty)) { print $langs->trans("NoFileFound"); } else { print $textifempty; } print '</td></tr>'; } print "</table>"; // Fin de zone }
print '<td colspan="3">'; // List of files $listofpaths = dol_dir_list($upload_dir, 'all', 0, '', '', 'name', SORT_ASC, 0); // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; $out .= '<script type="text/javascript" language="javascript">'; $out .= 'jQuery(document).ready(function () {'; $out .= ' jQuery(".removedfile").click(function() {'; $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; $out .= ' });'; $out .= '})'; $out .= '</script>' . "\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '<div id="attachfile_' . $key . '">'; $out .= img_mime($listofpaths[$key]['name']) . ' ' . $listofpaths[$key]['name']; $out .= ' <input type="image" style="border: 0px;" src="' . img_picto($langs->trans("Search"), 'delete.png', '', '', 1) . '" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; $out .= '<br></div>'; } } else { $out .= $langs->trans("NoAttachedFiles") . '<br>'; } // Add link to add file $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; $out .= ' '; $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />'; print $out; print '</td></tr>'; // Background color print '<tr><td width="25%">' . $langs->trans("BackgroundColorByDefault") . '</td><td colspan="3">'; print $htmlother->selectColor($object->bgcolor, 'bgcolor', 'edit_mailing', 0);
$i = 0; foreach ($filearray as $key => $val) { $file = $val['name']; // readdir return value in ISO and we want UTF8 in memory if (!utf8_check($file)) { $file = utf8_encode($file); } if (preg_match('/^\\./', $file)) { continue; } $modulepart = 'import'; $urlsource = $_SERVER["PHP_SELF"] . '?step=' . $step . $param . '&filetoimport=' . urlencode($filetoimport); $relativepath = $file; $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td width="16">' . img_mime($file) . '</td>'; print '<td>'; $modulepart = 'import'; //$relativepath=$filetoimport; print '<a href="' . DOL_URL_ROOT . '/document.php?modulepart=' . $modulepart . '&file=' . urlencode($relativepath) . '&step=3' . $param . '" target="_blank">'; print $file; print '</a>'; print '</td>'; // Affiche taille fichier print '<td align="right">' . dol_print_size(dol_filesize($dir . '/' . $file)) . '</td>'; // Affiche date fichier print '<td align="right">' . dol_print_date(dol_filemtime($dir . '/' . $file), 'dayhour') . '</td>'; // Del button print '<td align="right"><a href="' . DOL_URL_ROOT . '/document.php?action=remove_file&step=3' . $param . '&modulepart=' . $modulepart . '&file=' . urlencode($relativepath); print '&urlsource=' . urlencode($urlsource); print '">' . img_delete() . '</a></td>';
// Joined files $i=''; //$i=0; //while ($i < 4) //{ // $i++; //$property='joined_file'.$i; print '<tr><td>'.$langs->trans("MailFile").' '.$i.'</td>'; print '<td colspan="3">'; // List of files $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) { print img_mime($listofpaths[$key]['name']).' '.$listofpaths[$key]['name']; print ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="removedfile" name="removedfile" />'; print '<input type="hidden" name="removedfileid" value="'.($key+1).'" />'; print '<br>'; } } else { print $langs->trans("NoAttachedFiles").'<br>'; } // Add link to add file print '<input type="file" class="flat" name="addedfile'.$i.'" value="'.$langs->trans("Upload").'"/>'; print ' '; print '<input type="submit" class="button" name="addfile'.$i.'" value="'.$langs->trans("MailingAddFile").'">'; //print $mil->$property?'<br>'.$mil->$property:'';
/** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files * this->param: Contains more parameteres like email templates info * * @param string $addfileaction Name of action when posting file attachments * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { global $conf, $langs, $user, $hookmanager, $form; if (!is_object($form)) { $form = new Form($this->db); } $langs->load("other"); $langs->load("mails"); $hookmanager->initHooks(array('formmail')); $parameters = array('addfileaction' => $addfileaction, 'removefileaction' => $removefileaction); $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); if (!empty($reshook)) { return $hookmanager->resPrint; } else { $out = ''; // Define list of attached files $listofpaths = array(); $listofnames = array(); $listofmimes = array(); if (!empty($_SESSION["listofpaths"])) { $listofpaths = explode(';', $_SESSION["listofpaths"]); } if (!empty($_SESSION["listofnames"])) { $listofnames = explode(';', $_SESSION["listofnames"]); } if (!empty($_SESSION["listofmimes"])) { $listofmimes = explode(';', $_SESSION["listofmimes"]); } // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) { $newlang = $this->param['langsmodels']; } if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('other'); } // Get message template $model_id = 0; if (array_key_exists('models_id', $this->param)) { $model_id = $this->param["models_id"]; } $arraydefaultmessage = $this->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); //var_dump($arraydefaultmessage); $out .= "\n<!-- Begin form mail -->\n"; if ($this->withform == 1) { $out .= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '#formmail">' . "\n"; $out .= '<input style="display:none" type="submit" id="sendmail" name="sendmail">'; $out .= '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '" />'; $out .= '<input type="hidden" name="trackid" value="' . $this->trackid . '" />'; $out .= '<a id="formmail" name="formmail"></a>'; } foreach ($this->param as $key => $value) { $out .= '<input type="hidden" id="' . $key . '" name="' . $key . '" value="' . $value . '" />' . "\n"; } $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); if ($result < 0) { setEventMessage($this->error, 'errors'); } $modelmail_array = array(); foreach ($this->lines_model as $line) { $modelmail_array[$line->id] = $line->label; } // Zone to select its email template if (count($modelmail_array) > 0) { $out .= '<div style="padding: 3px 0 3px 0">' . "\n"; $out .= $langs->trans('SelectMailModel') . ': ' . $this->selectarray('modelmailselected', $modelmail_array, 0, 1); if ($user->admin) { $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } $out .= ' '; $out .= '<input class="button" type="submit" value="' . $langs->trans('Valid') . '" name="modelselected" id="modelselected">'; $out .= ' '; $out .= '</div>'; } $out .= '<table class="border" width="100%">' . "\n"; // Substitution array if (!empty($this->withsubstit)) { $out .= '<tr><td colspan="2">'; $help = ""; foreach ($this->substit as $key => $val) { $help .= $key . ' -> ' . $langs->trans($val) . '<br>'; } $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $help); $out .= "</td></tr>\n"; } // From if (!empty($this->withfrom)) { if (!empty($this->withfromreadonly)) { $out .= '<input type="hidden" id="fromname" name="fromname" value="' . $this->fromname . '" />'; $out .= '<input type="hidden" id="frommail" name="frommail" value="' . $this->frommail . '" />'; $out .= '<tr><td width="180">' . $langs->trans("MailFrom") . '</td><td>'; if ($this->fromtype == 'user' && $this->fromid > 0) { $langs->load("users"); $fuser = new User($this->db); $fuser->fetch($this->fromid); $out .= $fuser->getNomUrl(1); } else { $out .= $this->fromname; } if ($this->frommail) { $out .= " <" . $this->frommail . ">"; } else { if ($this->fromtype) { $langs->load("errors"); $out .= '<font class="warning"> <' . $langs->trans("ErrorNoMailDefinedForThisUser") . '> </font>'; } } $out .= "</td></tr>\n"; $out .= "</td></tr>\n"; } else { $out .= "<tr><td>" . $langs->trans("MailFrom") . "</td><td>"; $out .= $langs->trans("Name") . ':<input type="text" id="fromname" name="fromname" size="32" value="' . $this->fromname . '" />'; $out .= ' '; $out .= $langs->trans("EMail") . ':<<input type="text" id="frommail" name="frommail" size="32" value="' . $this->frommail . '" />>'; $out .= "</td></tr>\n"; } } // Replyto if (!empty($this->withreplyto)) { if ($this->withreplytoreadonly) { $out .= '<input type="hidden" id="replyname" name="replyname" value="' . $this->replytoname . '" />'; $out .= '<input type="hidden" id="replymail" name="replymail" value="' . $this->replytomail . '" />'; $out .= "<tr><td>" . $langs->trans("MailReply") . "</td><td>" . $this->replytoname . ($this->replytomail ? " <" . $this->replytomail . ">" : ""); $out .= "</td></tr>\n"; } } // Errorsto if (!empty($this->witherrorsto)) { //if (! $this->errorstomail) $this->errorstomail=$this->frommail; $errorstomail = !empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : $this->errorstomail; if ($this->witherrorstoreadonly) { $out .= '<input type="hidden" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= $errorstomail; $out .= "</td></tr>\n"; } else { $out .= '<tr><td>' . $langs->trans("MailErrorsTo") . '</td><td>'; $out .= '<input size="30" id="errorstomail" name="errorstomail" value="' . $errorstomail . '" />'; $out .= "</td></tr>\n"; } } // To if (!empty($this->withto) || is_array($this->withto)) { $out .= '<tr><td width="180">'; if ($this->withtofree) { $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); } else { $out .= $langs->trans("MailTo"); } $out .= '</td><td>'; if ($this->withtoreadonly) { if (!empty($this->toname) && !empty($this->tomail)) { $out .= '<input type="hidden" id="toname" name="toname" value="' . $this->toname . '" />'; $out .= '<input type="hidden" id="tomail" name="tomail" value="' . $this->tomail . '" />'; if ($this->totype == 'thirdparty') { $soc = new Societe($this->db); $soc->fetch($this->toid); $out .= $soc->getNomUrl(1); } else { if ($this->totype == 'contact') { $contact = new Contact($this->db); $contact->fetch($this->toid); $out .= $contact->getNomUrl(1); } else { $out .= $this->toname; } } $out .= ' <' . $this->tomail . '>'; if ($this->withtofree) { $out .= '<br>' . $langs->trans("or") . ' <input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } } else { $out .= !is_array($this->withto) && !is_numeric($this->withto) ? $this->withto : ""; } } else { if (!empty($this->withtofree)) { $out .= '<input size="' . (is_array($this->withto) ? "30" : "60") . '" id="sendto" name="sendto" value="' . (!is_array($this->withto) && !is_numeric($this->withto) ? isset($_REQUEST["sendto"]) ? $_REQUEST["sendto"] : $this->withto : "") . '" />'; } if (!empty($this->withto) && is_array($this->withto)) { if (!empty($this->withtofree)) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $this->withto, GETPOST("receiver"), 1); } if (isset($this->withtosocid) && $this->withtosocid > 0) { $liste = array(); $soc = new Societe($this->db); $soc->fetch($this->withtosocid); foreach ($soc->thirdparty_and_contact_email_array(1) as $key => $value) { $liste[$key] = $value; } if ($this->withtofree) { $out .= " " . $langs->trans("or") . " "; } $out .= $form->selectarray("receiver", $liste, GETPOST("receiver"), 1); } } $out .= "</td></tr>\n"; } // CC if (!empty($this->withtocc) || is_array($this->withtocc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if ($this->withtoccreadonly) { $out .= !is_array($this->withtocc) && !is_numeric($this->withtocc) ? $this->withtocc : ""; } else { $out .= '<input size="' . (is_array($this->withtocc) ? "30" : "60") . '" id="sendtocc" name="sendtocc" value="' . (!is_array($this->withtocc) && !is_numeric($this->withtocc) ? isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : $this->withtocc : (isset($_POST["sendtocc"]) ? $_POST["sendtocc"] : "")) . '" />'; if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receivercc", $this->withtocc, GETPOST("receivercc"), 1); } } $out .= "</td></tr>\n"; } // CCC if (!empty($this->withtoccc) || is_array($this->withtoccc)) { $out .= '<tr><td width="180">'; $out .= $form->textwithpicto($langs->trans("MailCCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= '</td><td>'; if (!empty($this->withtocccreadonly)) { $out .= !is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? $this->withtoccc : ""; } else { $out .= '<input size="' . (is_array($this->withtoccc) ? "30" : "60") . '" id="sendtoccc" name="sendtoccc" value="' . (!is_array($this->withtoccc) && !is_numeric($this->withtoccc) ? isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : $this->withtoccc : (isset($_POST["sendtoccc"]) ? $_POST["sendtoccc"] : "")) . '" />'; if (!empty($this->withtoccc) && is_array($this->withtoccc)) { $out .= " " . $langs->trans("or") . " "; $out .= $form->selectarray("receiverccc", $this->withtoccc, GETPOST("receiverccc"), 1); } } $showinfobcc = ''; if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') { $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; } if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO) && !empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') { $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ASKPRICESUPPLIER_TO; } if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') { $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; } if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') { $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; } if ($showinfobcc) { $out .= ' + ' . $showinfobcc; } $out .= "</td></tr>\n"; } // Ask delivery receipt if (!empty($this->withdeliveryreceipt)) { $out .= '<tr><td width="180">' . $langs->trans("DeliveryReceipt") . '</td><td>'; if (!empty($this->withdeliveryreceiptreadonly)) { $out .= yn($this->withdeliveryreceipt); } else { $defaultvaluefordeliveryreceipt = 0; if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_PROPAL) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') { $defaultvaluefordeliveryreceipt = 1; } if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ASKPRICESUPPLIER) && !empty($this->param['models']) && $this->param['models'] == 'askpricesupplier_send') { $defaultvaluefordeliveryreceipt = 1; } if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_ORDER) && !empty($this->param['models']) && $this->param['models'] == 'order_send') { $defaultvaluefordeliveryreceipt = 1; } if (!empty($conf->global->MAIL_FORCE_DELIVERY_RECEIPT_INVOICE) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') { $defaultvaluefordeliveryreceipt = 1; } $out .= $form->selectyesno('deliveryreceipt', isset($_POST["deliveryreceipt"]) ? $_POST["deliveryreceipt"] : $defaultvaluefordeliveryreceipt, 1); } $out .= "</td></tr>\n"; } // Topic if (!empty($this->withtopic)) { $defaulttopic = ""; if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['topic']) { $defaulttopic = $arraydefaultmessage['topic']; } elseif (!is_numeric($this->withtopic)) { $defaulttopic = $this->withtopic; } $defaulttopic = make_substitutions($defaulttopic, $this->substit); $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailTopic") . '</td>'; $out .= '<td>'; if ($this->withtopicreadonly) { $out .= $defaulttopic; $out .= '<input type="hidden" size="60" id="subject" name="subject" value="' . $defaulttopic . '" />'; } else { $out .= '<input type="text" size="60" id="subject" name="subject" value="' . (isset($_POST["subject"]) && !$_POST['modelselected'] ? $_POST["subject"] : ($defaulttopic ? $defaulttopic : '')) . '" />'; } $out .= "</td></tr>\n"; } // Attached files if (!empty($this->withfile)) { $out .= '<tr>'; $out .= '<td width="180">' . $langs->trans("MailFile") . '</td>'; $out .= '<td>'; if (is_numeric($this->withfile)) { // TODO Trick to have param removedfile containing nb of image to delete. But this does not works without javascript $out .= '<input type="hidden" class="removedfilehidden" name="removedfile" value="">' . "\n"; $out .= '<script type="text/javascript" language="javascript">'; $out .= 'jQuery(document).ready(function () {'; $out .= ' jQuery(".removedfile").click(function() {'; $out .= ' jQuery(".removedfilehidden").val(jQuery(this).val());'; $out .= ' });'; $out .= '})'; $out .= '</script>' . "\n"; if (count($listofpaths)) { foreach ($listofpaths as $key => $val) { $out .= '<div id="attachfile_' . $key . '">'; $out .= img_mime($listofnames[$key]) . ' ' . $listofnames[$key]; if (!$this->withfilereadonly) { $out .= ' <input type="image" style="border: 0px;" src="' . DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/delete.png" value="' . ($key + 1) . '" class="removedfile" id="removedfile_' . $key . '" name="removedfile_' . $key . '" />'; //$out.= ' <a href="'.$_SERVER["PHP_SELF"].'?removedfile='.($key+1).' id="removedfile_'.$key.'">'.img_delete($langs->trans("Delete").'</a>'; } $out .= '<br></div>'; } } else { $out .= $langs->trans("NoAttachedFiles") . '<br>'; } if ($this->withfile == 2) { $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="' . $langs->trans("Upload") . '" />'; $out .= ' '; $out .= '<input type="submit" class="button" id="' . $addfileaction . '" name="' . $addfileaction . '" value="' . $langs->trans("MailingAddFile") . '" />'; } } else { $out .= $this->withfile; } $out .= "</td></tr>\n"; } // Message if (!empty($this->withbody)) { $defaultmessage = ""; if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) { $defaultmessage = $arraydefaultmessage['content']; } elseif (!is_numeric($this->withbody)) { $defaultmessage = $this->withbody; } // Complete substitution array if (!empty($conf->paypal->enabled) && !empty($conf->global->PAYPAL_ADD_PAYMENT_URL)) { require_once DOL_DOCUMENT_ROOT . '/paypal/lib/paypal.lib.php'; $langs->load('paypal'); if ($this->param["models"] == 'order_send') { $url = getPaypalPaymentUrl(0, 'order', $this->substit['__ORDERREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } if ($this->param["models"] == 'facture_send') { $url = getPaypalPaymentUrl(0, 'invoice', $this->substit['__FACREF__']); $this->substit['__PERSONALIZED__'] = str_replace('\\n', "\n", $langs->transnoentitiesnoconv("PredefinedMailContentLink", $url)); } } $defaultmessage = str_replace('\\n', "\n", $defaultmessage); // Deal with format differences between message and signature (text / HTML) if (dol_textishtml($defaultmessage) && !dol_textishtml($this->substit['__SIGNATURE__'])) { $this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']); } else { if (!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) { $defaultmessage = dol_nl2br($defaultmessage); } } if (isset($_POST["message"]) && !$_POST['modelselected']) { $defaultmessage = $_POST["message"]; } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) $defaultmessage = preg_replace("/^(<br>)+/", "", $defaultmessage); $defaultmessage = preg_replace("/^\n+/", "", $defaultmessage); } $out .= '<tr>'; $out .= '<td width="180" valign="top">' . $langs->trans("MailText") . '</td>'; $out .= '<td>'; if ($this->withbodyreadonly) { $out .= nl2br($defaultmessage); $out .= '<input type="hidden" id="message" name="message" value="' . $defaultmessage . '" />'; } else { if (!isset($this->ckeditortoolbar)) { $this->ckeditortoolbar = 'dolibarr_notes'; } // Editor wysiwyg require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; if ($this->withfckeditor == -1) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { $this->withfckeditor = 1; } else { $this->withfckeditor = 0; } } $doleditor = new DolEditor('message', $defaultmessage, '', 280, $this->ckeditortoolbar, 'In', true, true, $this->withfckeditor, 8, 72); $out .= $doleditor->Create(1); } $out .= "</td></tr>\n"; } if ($this->withform == 1 || $this->withform == -1) { $out .= '<tr><td align="center" colspan="2"><div class="center">'; $out .= '<input class="button" type="submit" id="sendmail" name="sendmail" value="' . $langs->trans("SendMail") . '"'; // Add a javascript test to avoid to forget to submit file before sending email if ($this->withfile == 2 && $conf->use_javascript_ajax) { $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\'' . dol_escape_js($langs->trans("FileWasNotUploaded")) . '\'); return false; } else { return true; }"'; } $out .= ' />'; if ($this->withcancel) { $out .= ' '; $out .= '<input class="button" type="submit" id="cancel" name="cancel" value="' . $langs->trans("Cancel") . '" />'; } $out .= '</div></td></tr>' . "\n"; } $out .= '</table>' . "\n"; if ($this->withform == 1) { $out .= '</form>' . "\n"; } // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) { $out .= '<script type="text/javascript" language="javascript">'; $out .= 'jQuery(document).ready(function () {'; $out .= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is calle at every key pressed ! */ var code = e.keyCode || e.which; if (code == 13) { e.preventDefault(); return false; } });'; $out .= ' })'; $out .= '</script>'; } $out .= "<!-- End form mail -->\n"; return $out; } }
/** * Show list of documents in a directory * @param upload_dir Directory that was scanned * @param filearray Array of files loaded by dol_dir_list function before calling this function * @param modulepart Value for modulepart used by download wrapper * @param param Parameters on sort links * @param forcedownload Force to open dialog box "Save As" when clicking on file * @param relativepath Relative path of docs (autodefined if not provided) * @param permtodelete Permission to delete * @param useinecm Change output for use in ecm module * @param textifempty Text to show if filearray is empty * @param maxlength Maximum length of file name shown * @return int <0 if KO, nb of files shown if OK */ function list_of_autoecmfiles($upload_dir,$filearray,$modulepart,$param,$forcedownload=0,$relativepath='',$permtodelete=1,$useinecm=0,$textifempty='',$maxlength=0) { global $user, $conf, $langs; global $bc; global $sortfield, $sortorder; // Affiche liste des documents existant if (empty($useinecm)) print_titre($langs->trans("AttachedFiles")); //else { $bc[true]=''; $bc[false]=''; }; $url=$_SERVER["PHP_SELF"]; print '<table width="100%" class="nobordernopadding">'; print '<tr class="liste_titre">'; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Documents2"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder); print_liste_field_titre('','',''); print '</tr>'; if ($modulepart == 'invoice') { include_once(DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'); $object_static=new Facture($this->db); } if ($modulepart == 'invoice_supplier') { include_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'); $object_static=new FactureFournisseur($this->db); } $var=true; foreach($filearray as $key => $file) { if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && ! preg_match('/\.meta$/i',$file['name'])) { // Define relative path used to store the file $relativefile=preg_replace('/'.preg_quote($upload_dir.'/','/').'/','',$file['fullname']); //print 'eeee'.$relativefile; //var_dump($file); $var=!$var; print '<tr '.$bc[$var].'>'; print '<td>'; $id='';$ref=''; if ($modulepart == 'invoice') { preg_match('/(.*)\/[^\/]+$/',$relativefile,$reg); $ref=$reg[1]; $object_static->fetch('',$ref); //print $relativefile.'rr'.$id; print $object_static->getNomUrl(1,'document'); } if ($modulepart == 'invoice_supplier') { preg_match('/(\d+)\/[^\/]+$/',$relativefile,$reg); $id=$reg[1]; $object_static->fetch($id); //print $relativefile.'rr'.$id; print $object_static->getNomUrl(1,'document'); } print '</td>'; print '<td>'; //print "XX".$file['name']; //$file['name'] must be utf8 print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; if ($forcedownload) print '&attachment=1'; print '&file='.urlencode($relativefile).'">'; print img_mime($file['name'],$file['name'].' ('.dol_print_size($file['size'],0,0).')').' '; print dol_trunc($file['name'],$maxlength,'middle'); print '</a>'; print "</td>\n"; print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>'; print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>'; print '<td align="right">'; if (! empty($useinecm)) print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart; if ($forcedownload) print '&attachment=1'; print '&file='.urlencode($relativefile).'">'; print img_view().'</a> '; //if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>'; //else print ' '; print "</td></tr>\n"; } } if (sizeof($filearray) == 0) { print '<tr '.$bc[$var].'><td colspan="4">'; if (empty($textifempty)) print $langs->trans("NoFileFound"); else print $textifempty; print '</td></tr>'; } print "</table>"; // Fin de zone }