if ($_SESSION["do_crm_action_permission"]->action_permitted('add',8) === true) { ?> <div id="add_note"> <?php echo _('Add Note (use : for loading the emoji and @ for users)'); ?> <br /> <?php $e_add_notes = new Event("Notes->eventAddNotes"); $e_add_notes->addParam("idmodule",$module_id); $e_add_notes->addParam("module",$module); $e_add_notes->addParam("sqrecord",$sqcrm_record_id); echo '<form class="form-horizontal" id="Notes__eventAddNotes" name="Notes__eventAddNotes" method="post" enctype="multipart/form-data">'; echo $e_add_notes->getFormEvent(); ?> <?php FieldType200::display_field('entity_notes','','expand_text_area'); ?> <br /><br /> <?php FieldType21::display_field('note_files'); ?> <br /><br /> <div id="notes_submit"> <input type="submit" class="btn btn-primary" value="<?php echo _('Save');?>"/> </div> </form> </div> <hr class="form_hr"> <?php } ?> <?php
/** * function to send nudge email on a note * @param integer $idnotes * @param string $note_content * @param integer $related_module_id * @param integer $sqcrm_record_id */ public function send_note_nudge_email($idnotes, $note_content, $related_module_id, $sqcrm_record_id) { if ((int) $idnotes > 0) { $mentioned_email_receiptents = array(); preg_match_all("/(^|[^@\\w])@(\\w{1,15})\\b/im", $note_content, $mentioned_users); if (is_array($mentioned_users) && array_key_exists(2, $mentioned_users) && count($mentioned_users[2]) > 0) { $do_user = new \User(); $active_users = $do_user->get_active_users(); $current_user = 0; $active_users_key_as_username = array(); foreach ($active_users as $key => $users) { if ($users["iduser"] == $current_user) { continue; } $active_users_key_as_username[$users["user_name"]] = array("firstname" => $users["firstname"], "lastname" => $users["lastname"], "email" => $users["email"]); } foreach ($mentioned_users[2] as $key => $val) { if (array_key_exists($val, $active_users_key_as_username)) { $mentioned_email_receiptents[] = $active_users_key_as_username[$val]; } } } if (is_array($mentioned_email_receiptents) && count($mentioned_email_receiptents) > 0) { $email_template = new \EmailTemplate("send_notes_user_mentioned_email"); $emailer = new \SQEmailer(); $do_module = new \Module(); $do_module->getId($related_module_id); $entity_url = \NavigationControl::getNavigationLink($do_module->name, 'detail', $sqcrm_record_id, '#note' . $idnotes); $view_url = '<a href="' . SITE_URL . $entity_url . '">' . _('view on sQcrm') . '</a>'; $note_content = \FieldType200::display_value($note_content); $note_content = str_replace('/themes/images/emoji-pngs', SITE_URL . '/themes/images/emoji-pngs', $note_content); foreach ($mentioned_email_receiptents as $key => $mentioned) { $to_email = $mentioned["email"]; $email_data = array("notes_content" => $note_content, "firstname" => $mentioned["firstname"], "lastname" => $mentioned["lastname"], "view_url" => $view_url, "module_name" => \CommonUtils::get_module_name_as_text($related_module_id), "user_name" => $_SESSION["do_user"]->user_name); $emailer->IsSendmail(); $emailer->setEmailTemplate($email_template); $emailer->mergeArray($email_data); $emailer->AddAddress($to_email, $mentioned["firstname"] . ' ' . $mentioned["lastname"]); $emailer->send(); } } } }