30 if (!defined(
'NOREQUIREMENU')) {
31 define(
'NOREQUIREMENU',
'1');
33 if (!defined(
'NOREQUIREHTML')) {
34 define(
'NOREQUIREHTML',
'1');
36 if (!defined(
'NOLOGIN')) {
39 if (!defined(
'NOIPCHECK')) {
40 define(
'NOIPCHECK',
'1');
42 if (!defined(
'NOBROWSERNOTIF')) {
43 define(
'NOBROWSERNOTIF',
'1');
49 $entity = (!empty($_GET[
'entity']) ? (int) $_GET[
'entity'] : (!empty($_POST[
'entity']) ? (int) $_POST[
'entity'] : 1));
50 if (is_numeric($entity)) {
51 define(
"DOLENTITY", $entity);
55 require
'../../main.inc.php';
56 require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formticket.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/core/lib/ticket.lib.php';
59 require_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
60 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
61 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
62 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
63 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
68 $langs->loadLangs(array(
'companies',
'other',
'mails',
'ticket'));
76 $action =
GETPOST(
'action',
'aZ09');
77 $cancel =
GETPOST(
'cancel',
'aZ09');
83 $hookmanager->initHooks(array(
'publicnewticketcard',
'globalcard'));
89 if (
getDolGlobalInt(
'TICKET_CREATE_THIRD_PARTY_WITH_CONTACT_IF_NOT_EXIST')) {
90 $with_contact =
new Contact($db);
93 $extrafields->fetch_name_optionals_label(
$object->table_element);
108 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
113 if (empty($reshook)) {
115 $backtopage =
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE', DOL_URL_ROOT.
'/public/ticket/');
117 header(
"Location: ".$backtopage);
122 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
126 $vardir = $conf->ticket->dir_output;
127 $upload_dir_tmp = $vardir.
'/temp/'.session_id();
133 $action =
'create_ticket';
137 if (
GETPOST(
'removedfile',
'alpha') && !
GETPOST(
'save',
'alpha')) {
138 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
142 $vardir = $conf->ticket->dir_output.
'/';
143 $upload_dir_tmp = $vardir.
'/temp/'.session_id();
147 $action =
'create_ticket';
150 if ($action ==
'create_ticket' &&
GETPOST(
'save',
'alpha')) {
152 $origin_email =
GETPOST(
'email',
'alpha');
153 if (empty($origin_email)) {
155 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Email")));
159 $searched_companies =
$object->searchSocidByEmail($origin_email,
'0');
163 $contacts =
$object->searchContactByEmail($origin_email);
167 foreach ($contacts as $key => $contact) {
168 if ((
int) $contact->statut == 1) {
175 if (
getDolGlobalInt(
'TICKET_EMAIL_MUST_EXISTS') && ($cid < 0 || empty($contacts[$cid]->socid))) {
177 array_push(
$object->errors, $langs->trans(
"ErrorEmailMustExistToCreateTicket"));
182 $contact_lastname =
'';
183 $contact_firstname =
'';
188 if (is_array($contacts) && count($contacts) == 1) {
189 $with_contact = current($contacts);
193 $contact_lastname = trim(
GETPOST(
'contact_lastname',
'alphanohtml'));
194 $contact_firstname = trim(
GETPOST(
'contact_firstname',
'alphanohtml'));
195 $company_name = trim(
GETPOST(
'company_name',
'alphanohtml'));
196 $contact_phone = trim(
GETPOST(
'contact_phone',
'alphanohtml'));
197 if (!($with_contact->id > 0)) {
199 if (empty($contact_lastname)) {
201 array_push(
$object->errors, $langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Lastname')));
205 if (empty($contact_firstname)) {
207 array_push(
$object->errors, $langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Firstname')));
213 if (!
GETPOST(
"subject",
"restricthtml")) {
215 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Subject")));
218 if (!
GETPOST(
"message",
"restricthtml")) {
220 array_push(
$object->errors, $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Message")));
225 if (!empty($origin_email) && !
isValidEmail($origin_email)) {
227 array_push(
$object->errors, $langs->trans(
"ErrorBadEmailAddress", $langs->transnoentities(
"email")));
233 $sessionkey =
'dol_antispam_value';
234 $ok = (array_key_exists($sessionkey, $_SESSION) ===
true && (strtolower($_SESSION[$sessionkey]) === strtolower(
GETPOST(
'code',
'restricthtml'))));
237 array_push(
$object->errors, $langs->trans(
"ErrorBadValueForCode"));
248 $nb_post_max =
getDolGlobalInt(
"MAIN_SECURITY_MAX_POST_ON_PUBLIC_PAGES_BY_IP_ADDRESS", 200);
254 if ($nb_post_max > 0) {
255 $sql =
"SELECT COUNT(ref) as nb_tickets";
256 $sql .=
" FROM ".MAIN_DB_PREFIX.
"ticket";
257 $sql .=
" WHERE ip = '".$db->escape(
$object->ip).
"'";
258 $sql .=
" AND datec > '".$db->idate($minmonthpost).
"'";
259 $resql = $db->query(
$sql);
261 $num = $db->num_rows($resql);
265 $obj = $db->fetch_object($resql);
266 $nb_post_ip = $obj->nb_tickets;
277 $object->origin_email = $origin_email;
283 if (!is_object($user)) {
284 $user =
new User($db);
289 if ($with_contact && !($with_contact->id > 0)) {
291 if (!empty($company_name)) {
292 $company->name = $company_name;
294 $company->particulier = 1;
297 $result = $company->create($user);
300 $errors = ($company->error ? array($company->error) : $company->errors);
301 array_push(
$object->errors, $errors);
302 $action =
'create_ticket';
307 $with_contact->email = $origin_email;
308 $with_contact->lastname = $contact_lastname;
309 $with_contact->firstname = $contact_firstname;
310 $with_contact->socid = $company->id;
311 $with_contact->phone_pro = $contact_phone;
312 $result = $with_contact->create($user);
315 $errors = ($with_contact->error ? array($with_contact->error) : $with_contact->errors);
316 array_push(
$object->errors, $errors);
317 $action =
'create_ticket';
319 $contacts = array($with_contact);
324 if (!empty($searched_companies) && is_array($searched_companies)) {
325 $object->fk_soc = $searched_companies[0]->id;
328 if (is_array($contacts) && count($contacts) > 0 && $cid >= 0) {
329 $object->fk_soc = $contacts[$cid]->socid;
330 $usertoassign = $contacts[$cid]->id;
333 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
338 $object->context[
'disableticketemail'] = 1;
341 $object->context[
'createdfrompublicinterface'] = 1;
343 if ($nb_post_max > 0 && $nb_post_ip >= $nb_post_max) {
345 array_push(
$object->errors, $langs->trans(
"AlreadyTooMuchPostOnThisIPAdress"));
346 $action =
'create_ticket';
356 $action =
'create_ticket';
360 if (!$error && $id > 0) {
361 if ($usertoassign > 0) {
362 $object->add_contact($usertoassign,
"SUPPORTCLI",
'external', 0);
367 $action =
"infos_success";
371 $action =
'create_ticket';
378 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formmail.class.php';
379 include_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
387 $attachedfiles = $formmail->get_attached_files();
388 $filepath = $attachedfiles[
'paths'];
389 $filename = $attachedfiles[
'names'];
390 $mimetype = $attachedfiles[
'mimes'];
393 $appli = $mysoc->name;
395 $subject =
'['.$appli.
'] '.$langs->transnoentities(
'TicketNewEmailSubject',
$object->ref,
$object->track_id);
397 $message .= $langs->transnoentities(
'TicketNewEmailBodyInfosTicket').
'<br>';
400 $infos_new_ticket = $langs->transnoentities(
'TicketNewEmailBodyInfosTrackId',
'<a href="'.$url_public_ticket.
'" rel="nofollow noopener">'.
$object->track_id.
'</a>').
'<br>';
401 $infos_new_ticket .= $langs->transnoentities(
'TicketNewEmailBodyInfosTrackUrl').
'<br><br>';
403 $message .= $infos_new_ticket;
404 $message .=
getDolGlobalString(
'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->transnoentities(
'TicketMessageMailSignatureText', $mysoc->name));
406 $sendto =
GETPOST(
'email',
'alpha');
408 $from =
getDolGlobalString(
'MAIN_INFO_SOCIETE_NOM') .
' <'.getDolGlobalString(
'TICKET_NOTIFICATION_EMAIL_FROM').
'>';
411 $deliveryreceipt = 0;
415 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
417 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
418 $mailfile =
new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'',
'tic'.
$object->id,
'',
'ticket');
419 if ($mailfile->error || !empty($mailfile->errors)) {
422 $result = $mailfile->sendfile();
425 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
431 $appli = $mysoc->name;
433 $subject =
'['.$appli.
'] '.$langs->transnoentities(
'TicketNewEmailSubjectAdmin',
$object->ref,
$object->track_id);
434 $message_admin = $langs->transnoentities(
'TicketNewEmailBodyAdmin',
$object->track_id).
'<br><br>';
435 $message_admin .=
'<ul><li>'.$langs->trans(
'Title').
' : '.
$object->subject.
'</li>';
436 $message_admin .=
'<li>'.$langs->trans(
'Type').
' : '.
$object->type_label.
'</li>';
437 $message_admin .=
'<li>'.$langs->trans(
'Category').
' : '.
$object->category_label.
'</li>';
438 $message_admin .=
'<li>'.$langs->trans(
'Severity').
' : '.
$object->severity_label.
'</li>';
439 $message_admin .=
'<li>'.$langs->trans(
'From').
' : '.
$object->origin_email.
'</li>';
441 $extrafields->fetch_name_optionals_label(
$object->table_element);
442 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
443 foreach (
$object->array_options as $key => $value) {
444 $key = substr($key, 8);
445 $message_admin .=
'<li>'.$langs->trans($extrafields->attributes[
$object->table_element][
'label'][$key]).
' : '.$extrafields->showOutputField($key, $value,
'',
$object->table_element).
'</li>';
448 $message_admin .=
'</ul>';
450 $message_admin .=
'<p>'.$langs->trans(
'Message').
' : <br>'.
$object->message.
'</p>';
451 $message_admin .=
'<p><a href="'.dol_buildpath(
'/ticket/card.php', 2).
'?track_id='.
$object->track_id.
'" rel="nofollow noopener">'.$langs->trans(
'SeeThisTicketIntomanagementInterface').
'</a></p>';
458 $conf->global->MAIN_MAIL_AUTOCOPY_TO =
'';
460 include_once DOL_DOCUMENT_ROOT.
'/core/class/CMailFile.class.php';
461 $mailfile =
new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc,
'', $deliveryreceipt, -1,
'',
'',
'tic'.
$object->id,
'',
'ticket');
462 if ($mailfile->error || !empty($mailfile->errors)) {
465 $result = $mailfile->sendfile();
468 $conf->global->MAIN_MAIL_AUTOCOPY_TO = $old_MAIN_MAIL_AUTOCOPY_TO;
474 $object->copyFilesForTicket(
'');
479 $messagetoshow = $langs->trans(
'MesgInfosPublicTicketCreatedWithTrackId',
'{s1}',
'{s2}');
480 $messagetoshow = str_replace(array(
'{s1}',
'{s2}'), array(
'<strong>'.
$object->track_id.
'</strong>',
'<strong>'.$object->ref.
'</strong>'), $messagetoshow);
484 header(
"Location: index.php".(!empty($entity) &&
isModEnabled(
'multicompany') ?
'?entity='.$entity :
''));
502 $form =
new Form($db);
506 print
'<div class="error">'.$langs->trans(
'TicketPublicInterfaceForbidden').
'</div>';
511 $arrayofjs = array();
513 $arrayofcss = array(
'/opensurvey/css/style.css',
getDolGlobalString(
'TICKET_URL_PUBLIC_INTERFACE',
'/ticket/').
'css/styles.css.php');
515 llxHeaderTicket($langs->trans(
"CreateTicket"),
"", 0, 0, $arrayofjs, $arrayofcss);
518 print
'<div class="ticketpublicarea ticketlargemargin centpercent">';
520 if ($action !=
"infos_success") {
521 $formticket->withfromsocid = isset($socid) ? $socid : $user->socid;
522 $formticket->withtitletopic = 1;
523 $formticket->withcompany = 0;
524 $formticket->withusercreate = 1;
525 $formticket->fk_user_create = 0;
526 $formticket->withemail = 1;
527 $formticket->ispublic = 1;
528 $formticket->withfile = 2;
529 $formticket->action =
'create_ticket';
530 $formticket->withcancel = 1;
532 $formticket->param = array(
'returnurl' => $_SERVER[
'PHP_SELF'].($conf->entity > 1 ?
'?entity='.$conf->entity :
''));
534 print
load_fiche_titre($langs->trans(
'NewTicket'),
'',
'', 0, 0,
'marginleftonly');
537 $langs->load(
"errors");
538 print
'<div class="error">';
539 print $langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"TicketEmailNotificationFrom")).
'<br>';
540 print $langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentities(
"Ticket"));
544 $formticket->showForm(0,
'edit', 1, $with_contact);
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Class to send emails (with attachments or not) Usage: $mailfile = new CMailFile($subject,...
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
htmlPrintOnlineFooter($fromcompany, $langs, $addformmessage=0, $suffix='', $object=null)
Show footer of company in HTML pages.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_add_file_process($upload_dir, $allowoverwrite=0, $updatesessionordb=0, $varfiles='addedfile', $savingdocmask='', $link=null, $trackid='', $generatethumbs=1, $object=null)
Get and save an upload file (for example after submitting a new file a mail form).
dol_remove_file_process($filenb, $donotupdatesession=0, $donotdeletefile=1, $trackid='')
Remove an uploaded file (for example after submitting a new file a mail form).
dol_is_dir($folder)
Test if filename is a directory.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
isValidEmail($address, $acceptsupervisorkey=0, $acceptuserkey=0)
Return true if email syntax is ok.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
getUserRemoteIP()
Return the IP of remote user.
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Class to generate the form for creating a new ticket.
httponly_accessforbidden($message='1', $http_response_code=403, $stringalreadysanitized=0)
Show a message to say access is forbidden and stop program.
generate_random_id($car=16)
Generate a random id.
llxHeaderTicket($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs=[], $arrayofcss=[])
Show http header, open body tag and show HTML header banner for public pages for tickets.