templates/Group/editGroupContent.html.twig line 1

Open in your IDE?
  1. {#
  2. template to
  3. - show the content of a group
  4. - edit the group
  5. - add members to the group
  6. - send mails to a group
  7.     is used in both Group/editGroup.html.twig
  8.     and Admin/editGroup.html.twig
  9. #}
  10. {% block content %}
  11. <div class="container-fluid">
  12.     <!-- Content Wrapper. Contains page content -->
  13.     <div class="">
  14.         <!-- Main content -->
  15.         <section class="content">
  16.             <p>
  17.                 {{ data.group.groupname }}
  18.                 {#  % if (data.isGroupAdmin == 1) or (is_granted('ROLE_GLOBAL_EDITOR')) % #}
  19.                 {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  20.                     &nbsp;<button class="btn btn-primary btn-xs editGroup">Edit</button>
  21.                 {% endif %}
  22.             </p>
  23.             <div class="container-fluid">
  24.                 <div class="row">
  25.                     <div class="btn-group btn-breadcrumb">
  26.                         <a
  27.                                 href="{{ path('groups') }}"
  28.                                 class="btn btn-default">
  29.                             <i class="glyphicon glyphicon-home"></i>
  30.                         </a>
  31.                         {% for group in data.ancestors %}
  32.                             {% if loop.last %}
  33.                                 <span
  34.                                         class="btn btn-default tipso disabled"
  35.                                         disabled="disabled"
  36.                                         title="{{ group.groupname }}">
  37.                                     {% if group.groupname | length > 20 %}
  38.                                         {{ group.groupname | truncate(20) }}
  39.                                     {% else %}
  40.                                         {{ group.groupname }}
  41.                                     {% endif %}
  42.                                 </span>
  43.                             {% else %}
  44.                                 <a
  45.                                         href="{{ path('view_group',{groupId:group.idGroup}) }}"
  46.                                         class="btn btn-default tipso"
  47.                                         title="{{ group.groupname }}">
  48.                                     {% if group.groupname | length > 20 %}
  49.                                         {{ group.groupname | truncate(20) }}
  50.                                     {% else %}
  51.                                         {{ group.groupname }}
  52.                                     {% endif %}
  53.                                 </a>
  54.                             {% endif %}
  55.                         {% endfor %}
  56.                     </div>
  57.                     <p>
  58.                         {% if data.subgroups is defined and data.subgroups | length > 0 %}
  59.                             {{ data.group.groupname }} also has the {% if data.subgroups | length >1 %}sub-groups{% else %}sub-group{% endif %} :
  60.                             {% for subgroup in data.subgroups  %}
  61.                                 <a
  62.                                         href="{{ path('view_group',{groupId:subgroup.idGroup}) }}">
  63.                                     {{ subgroup.groupname }}
  64.                                 </a>
  65.                                 {% if not loop.last %},{% else %}.{% endif %}
  66.                             {% endfor %}
  67.                         {% else %}
  68.                             no subgroups found for this group
  69.                         {% endif %}
  70.                     </p>
  71.                 </div>
  72.                 <div class="row">
  73.                     <div class="bottom-buffer50">
  74.                         <article>
  75.                             <p
  76.                                     class="description">
  77.                                 {{ data.group.description |raw | nl2br  }}
  78.                             </p>
  79.                         </article>
  80.                     </div>
  81.                     <div class="row">
  82.                         <div class="col-md-12">
  83.                             <table
  84.                                     id="datatable"
  85.                                     class="table table-striped table-bordered dataTable dt-responsive wrap">
  86.                                 {% for i in ['thead', 'tfoot'] %}
  87.                                     <{{ i }}>
  88.                                         <tr>
  89.                                             {% if app.user %}
  90.                                                 <th>Select</th>
  91.                                             {% else %}
  92.                                                 <th id="{{ i }}-th"></th>
  93.                                             {% endif %}
  94.                                             <th style="width: 65%;">Name</th>
  95.                                             <th style="width: 15%;">Group Role</th>
  96.                                             <th style="width: 15%;">Country (worklocation)</th>
  97.                                             <th style="width: 15%;">FirstName</th>
  98.                                         </tr>
  99.                                     </{{ i }}>
  100.                                 {% endfor %}
  101.                             </table>
  102.                             {#   % if is_granted('ROLE_ADMIN') % #}
  103.                             {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  104.                                 <button
  105.                                     href="#compose-mail"
  106.                                     data-toggle="modal"
  107.                                     class="btn btn-primary"
  108.                                     id="compose"
  109.                                     style="display: none;">
  110.                                     <i class="fa fa-envelope-o fa-fw"></i>
  111.                                     Send email to everybody<br />
  112.                                     in this group <strong>and</strong> all sub-groups
  113.                                 </button>
  114.                             {% endif %}
  115.                             {#  % if is_granted('ROLE_ADMIN') % #}
  116.                             {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  117.                                 <br/>
  118.                                 <a
  119.                                         href="{{ path('get_group_experts_addresses',{groupId:data.group.idGroup}) }}"
  120.                                         target="_blank">
  121.                                     <button
  122.                                             class="btn btn-primary"
  123.                                             id="export"
  124.                                             style="display: block;">
  125.                                         <i class="fa fa-download fa-fw"></i>
  126.                                         Export info about experts<br />
  127.                                         in this group <strong>and</strong> all sub-groups<br />
  128.                                         as CSV
  129.                                     </button>
  130.                                 </a>
  131.                             {% endif %}
  132.                         </div>
  133.                     </div>
  134.                 </div>
  135.             </div>
  136.         </section>
  137.     </div>
  138.     {# this part (modals) is only needed when a user is logged in as admin #}
  139.     {#  % if is_granted('ROLE_ADMIN') % #}
  140.     {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  141.     <!-- Modal to send mails to group -->
  142.     <div
  143.             aria-hidden="true"
  144.             aria-labelledby="compose-mail"
  145.             role="dialog"
  146.             tabindex="-1"
  147.             id="compose-mail"
  148.             class="modal fade"
  149.             style="display: none;">
  150.         <div class="modal-dialog modal-lg">
  151.             <div class="modal-content">
  152.                 <div class="modal-header">
  153.                     <button
  154.                             aria-hidden="true"
  155.                             data-dismiss="modal"
  156.                             class="close"
  157.                             type="button">
  158.                         ×
  159.                     </button>
  160.                     <h4 class="modal-title">
  161.                         Compose Mail
  162.                     </h4>
  163.                 </div>
  164.                 <div class="modal-body">
  165.                     <div role="form" class="form-horizontal">
  166.                         <div class="form-group">
  167.                             <label class="col-lg-2 control-label">Sender</label>
  168.                             <div class="col-lg-10">
  169.                                 {% if file_exists(web_path~asset('uploads/profile/profile_'~app.user.id~'.png')) %}
  170.                                     <img
  171.                                         src="{{ asset('uploads/profile/profile_'~app.user.id~'.png') }}"
  172.                                         alt="user profile"
  173.                                         class="profile-img-sm img-circle" />
  174.                                 {% endif %}
  175.                                 <label
  176.                                         class="control-label">
  177.                                     {{ data.user.fname~' '~data.user.sname }} &lt;{{ app.user.email }}&gt;<br />
  178.                                     <div class="checkbox">
  179.                                         <label class="no-padding" for="selfEmail">
  180.                                             <input
  181.                                                     type="checkbox"
  182.                                                     value=""
  183.                                                     id="selfEmail">
  184.                                             <span class="cr">
  185.                                                 <i class="cr-icon glyphicon glyphicon-ok"></i>
  186.                                             </span>
  187.                                             Send a copy of this message to me too
  188.                                         </label>
  189.                                     </div>
  190.                                 </label>
  191.                             </div>
  192.                         </div>
  193.                         <div class="form-group">
  194.                             <label class="col-lg-2 control-label">Recipients</label>
  195.                             <div class="col-lg-10">
  196.                                 <label
  197.                                         class="control-label">
  198.                                     All people in the {{ data.group.groupname }} group
  199.                                 </label>
  200.                             </div>
  201.                         </div>
  202.                         <div class="form-group">
  203.                             <label
  204.                                     class="col-lg-2 control-label"
  205.                                     for="subject">
  206.                                 Subject
  207.                             </label>
  208.                             <div class="col-lg-10">
  209.                                 <input
  210.                                         type="text"
  211.                                         placeholder=""
  212.                                         id="subject"
  213.                                         name="subject"
  214.                                         class="form-control" />
  215.                             </div>
  216.                         </div>
  217.                         <div class="form-group">
  218.                             <label
  219.                                     class="col-lg-2 control-label"
  220.                                     for="message">
  221.                                 Message
  222.                             </label>
  223.                             <div class="col-lg-10">
  224.                                 <textarea
  225.                                         rows="10"
  226.                                         cols="30"
  227.                                         class="form-control textarea"
  228.                                         id="message"
  229.                                         name="message">
  230.                                 </textarea>
  231.                             </div>
  232.                         </div>
  233.                         <div class="form-group">
  234.                             <label class="col-lg-2 control-label" for="info"></label>
  235.                             <div class="col-lg-10">
  236.                                 <div style="margin-top:5px">
  237.                                     <div class="infoHidden">
  238.                                         <a class="showInfo" href="javascript:void(0)">[Info on inserting names]</a>
  239.                                     </div>
  240.                                     <div class="infoShown">
  241.                                         <a class="hideInfo" href="javascript:void(0)" style="float:right">[Hide]</a>
  242.                                         If you include these special words in your message, they will be replaced:
  243.                                         <br><br>
  244.                                         <div class="table-responsive">
  245.                                             <table class="table table-condensed">
  246.                                                 <tbody><tr>
  247.                                                     <td>_FULLNAME_</td>
  248.                                                     <td>Recipient name (first name &amp; surname)</td>
  249.                                                 </tr>
  250.                                                 <tr>
  251.                                                     <td>_FNAME_</td>
  252.                                                     <td>Recipient first name</td>
  253.                                                 </tr>
  254.                                                 <tr>
  255.                                                     <td>_SNAME_</td>
  256.                                                     <td>Recipient surname</td>
  257.                                                 </tr>
  258.                                                 <tr>
  259.                                                     <td>_TITLE_</td>
  260.                                                     <td>Recipient title</td>
  261.                                                 </tr>
  262.                                                 </tbody>
  263.                                             </table>
  264.                                         </div>
  265.                                     </div>
  266.                                 </div>
  267.                             </div>
  268.                         </div>
  269.                         <div class="form-group">
  270.                             <div class="col-lg-offset-2 col-lg-10">
  271.                                 <div class="fileUpload">
  272.                                     <form
  273.                                             action="{{ path('upload_email_attachments') }}"
  274.                                             class="dropzone"
  275.                                             id="myAwesomeDropzone">
  276.                                     </form>
  277.                                 </div>
  278.                             </div>
  279.                         </div>
  280.                         <div class="form-group">
  281.                             <div class="col-lg-offset-2 col-lg-10">
  282.                                 <div class="btn-toolbar pull-right ">
  283.                                     <button
  284.                                             class="btn btn-send btn-danger"
  285.                                             id="closeModal"
  286.                                             data-dismiss="modal">
  287.                                         <i class="fa fa-times-circle"></i>
  288.                                         Close
  289.                                     </button>
  290.                                     <button
  291.                                             class="btn btn-send btn-primary"
  292.                                             id="sendmail">
  293.                                         Send
  294.                                         <i class="fa fa-envelope-o"></i>
  295.                                     </button>
  296.                                 </div>
  297.                             </div>
  298.                         </div>
  299.                     </div>
  300.                 </div>
  301.             </div><!-- /.modal-content -->
  302.         </div><!-- /.modal-dialog -->
  303.     </div><!-- /.modal -->
  304.     {# not very sure what this does #}
  305.     <div
  306.             class="modal fade"
  307.             id="modal-edit"
  308.             tabindex="-1"
  309.             role="dialog"
  310.             aria-labelledby="myModalLabel"
  311.             aria-hidden="true">
  312.         <div class="modal-dialog">
  313.             <div class="modal-content">
  314.                 <div class="modal-header">
  315.                     <button
  316.                             type="button"
  317.                             class="close"
  318.                             data-dismiss="modal"
  319.                             aria-hidden="true">
  320.                         &times;
  321.                     </button>
  322.                     <h4 class="modal-title"></h4>
  323.                 </div>
  324.                 <div class="modal-body">
  325.                     <p>
  326.                         <span class="modal-message"></span>
  327.                     </p>
  328.                 </div>
  329.                 <div class="modal-footer">
  330.                 </div>
  331.             </div>
  332.         </div>
  333.     </div>
  334.     {# modal to edit the group settings/info #}
  335.     <div
  336.             class="modal fade"
  337.             id="groupEdit"
  338.             tabindex="-1"
  339.             role="dialog"
  340.             aria-labelledby="groupEditLabel"
  341.             aria-hidden="true">
  342.         <div class="modal-dialog modal-lg">
  343.             <form
  344.                     id="FormMessage"
  345.                     class="form-horizontal">
  346.                 <div class="modal-content">
  347.                     <div class="modal-header btn-success">
  348.                         <h4 id="groupEditLabel">
  349.                             Edit Description for : <strong>{{ data.group.groupname }}</strong>
  350.                         </h4>
  351.                     </div>
  352.                     <div class="modal-body">
  353.                         <br />
  354.                         <div class="control-group">
  355.                             <label for="groupName">
  356.                                 Name:
  357.                             </label>
  358.                             <input
  359.                                     name="groupName"
  360.                                     type="text"
  361.                                     id="groupName"
  362.                                     value="{{ data.group.groupname }}"
  363.                                     class="form-control" />
  364.                         </div>
  365.                         <br />
  366.                         <div class="control-group">
  367.                             <label for="description">
  368.                                 Description
  369.                             </label>
  370.                             <textarea
  371.                                     id="description"
  372.                                     name="description"
  373.                                     class="form-control textarea"
  374.                                     rows="10">
  375.                                 {{ data.group.description |raw | nl2br  }}
  376.                             </textarea>
  377.                         </div>
  378.                         <br />
  379.                         <div class="control-group">
  380.                             <input
  381.                                     type="checkbox"
  382.                                     name="officialBody"
  383.                                     id="officialBody"
  384.                                     value="{{ data.group.officialBody }}" />
  385.                             <label for="officialBody">
  386.                                 This group is an official subsidiary body.
  387.                             </label>
  388.                         </div>
  389.                         <br />
  390.                         <div class="control-group">
  391.                             <label for="template">
  392.                                 List Group Member(s)
  393.                             </label>
  394.                             <select
  395.                                     name="template"
  396.                                     id="template"
  397.                                     class="form-control">
  398.                                 {% for key, template in data.templates %}
  399.                                     {% if key == data.group.idMstemplate %}
  400.                                         <option value="{{ key }}" selected>
  401.                                             {{ template }}
  402.                                         </option>
  403.                                     {% else %}
  404.                                         <option value="{{ key }}">
  405.                                             {{ template }}
  406.                                         </option>
  407.                                     {% endif %}
  408.                                 {% endfor %}
  409.                             </select>
  410.                         </div>
  411.                         <br />
  412.                     </div>
  413.                     <div class="modal-footer">
  414.                         <div class="text-right">
  415.                             <button
  416.                                     type="button"
  417.                                     class="btn btn-danger"
  418.                                     data-dismiss="modal">
  419.                                 <i class="fa fa-times-circle" aria-hidden="true"></i>
  420.                                 Cancel
  421.                             </button>
  422.                             <button
  423.                                     type="button"
  424.                                     class="btn btn-success saveGroup">
  425.                                 <i class="fa fa-floppy-o" aria-hidden="true"></i>
  426.                                 Save
  427.                             </button>
  428.                         </div>
  429.                     </div>
  430.                 </div>
  431.             </form>
  432.         </div>
  433.     </div>
  434.     {# modal to add a member to the group #}
  435.     <div
  436.             class="modal fade"
  437.             id="addMember"
  438.             tabindex="-1"
  439.             role="dialog"
  440.             aria-labelledby="addMemberLabel"
  441.             aria-hidden="true">
  442.         <div class="modal-dialog modal-lg">
  443.             <div class="modal-content">
  444.                 <div class="modal-header btn-success">
  445.                     <h4 id="groupEditLabel">
  446.                         Add Member(s) to <strong>{{ data.group.groupname }}</strong>
  447.                     </h4>
  448.                 </div>
  449.                 <div class="modal-body">
  450.                     <div class="row">
  451.                         <div class="col-xs-8 col-xs-offset-2">
  452.                             <div class="input-group">
  453.                                 <div class="input-group-btn search-panel">
  454.                                     <button
  455.                                             type="button"
  456.                                             class="btn btn-default dropdown-toggle"
  457.                                             data-toggle="dropdown">
  458.                                         <span id="search_concept">Filter by</span> <span class="caret"></span>
  459.                                     </button>
  460.                                     <ul class="dropdown-menu" role="menu">
  461.                                         <li><a href="#name">Name</a></li>
  462.                                         <li><a href="#email">Email</a></li>
  463.                                         <li class="divider"></li>
  464.                                         <li><a href="#group">Groups</a></li>
  465.                                     </ul>
  466.                                 </div>
  467.                                 <input
  468.                                         type="hidden"
  469.                                         name="search_param"
  470.                                         value="all"
  471.                                         id="search_param" />
  472.                                 <input
  473.                                         type="text"
  474.                                         class="form-control"
  475.                                         name="searchTerm"
  476.                                         id="searchTerm"
  477.                                         placeholder="Search Members..." >
  478.                                 <span class="input-group-btn">
  479.                                     <button
  480.                                             class="btn btn-default searchMembers"
  481.                                             id="searchButton"
  482.                                             type="button">
  483.                                         <i class="fa fa-search fa-fw"></i>
  484.                                         Search
  485.                                     </button>
  486.                                 </span>
  487.                             </div>
  488.                         </div>
  489.                     </div>
  490.                     <div class="container-fluid">
  491.                         <div class="result">
  492.                             <table class="table table-striped resultSet">
  493.                                 <thead>
  494.                                     <tr>
  495.                                         <th>Name</th>
  496.                                         <th>Group Role</th>
  497.                                         <th>Institution</th>
  498.                                         <th>Country (worklocation)</th>
  499.                                         <th>Action</th>
  500.                                         <th style="display: none">Relevance</th>
  501.                                     </tr>
  502.                                 </thead>
  503.                                 <tfoot>
  504.                                     <tr>
  505.                                         <th>Name</th>
  506.                                         <th>Group Role</th>
  507.                                         <th>Institution</th>
  508.                                         <th>Country (worklocation)</th>
  509.                                         <th>Action</th>
  510.                                         <th style="display: none">Relevance</th>
  511.                                     </tr>
  512.                                 </tfoot>
  513.                             </table>
  514.                         </div>
  515.                     </div>
  516.                 </div>
  517.                 <div class="modal-footer">
  518.                     <div class="text-right">
  519.                         <button
  520.                                 type="button"
  521.                                 class="btn btn-success add-all" style="display: none;">
  522.                             <i class="fa fa-plus fa-fw" aria-hidden="true"></i>
  523.                             Add all the above to group
  524.                         </button>
  525.                         <button
  526.                                 type="button"
  527.                                 class="btn btn-danger"
  528.                                 data-dismiss="modal">
  529.                             <i class="fa fa-times-circle fa-fw" aria-hidden="true"></i>
  530.                             Close
  531.                         </button>
  532.                     </div>
  533.                 </div>
  534.             </div>
  535.         </div>
  536.     </div>
  537.     {# modal to edit a member/role #}
  538.     <div class="modal fade" id="editMember">
  539.         <div class="modal-dialog">
  540.              <div class="modal-content">
  541.                  <div class="modal-header">
  542.                      <h4 class="modal-title"></h4>
  543.                  </div>
  544.                  <div class="modal-body">
  545.                     <h4 class="member"></h4>
  546.                     <div class="container-fluid">
  547.                         <div class="form-horizontal">
  548.                             <div class="form-group">
  549.                                 <label class="control-label col-sm-3" for="email">
  550.                                     Group Role :
  551.                                 </label>
  552.                                 <div class="col-sm-9">
  553.                                     <input
  554.                                             type="text"
  555.                                             class="form-control"
  556.                                             id="groupRole"
  557.                                             placeholder="Enter group role" value="" />
  558.                                     <input
  559.                                             type="hidden"
  560.                                             id="memberid"
  561.                                             name="memberid" />
  562.                                 </div>
  563.                             </div>
  564.                         </div>
  565.                     </div>
  566.                  </div>
  567.                  <div class="modal-footer">
  568.                      <button
  569.                              type="button"
  570.                              class="btn btn-danger"
  571.                              data-dismiss="modal">
  572.                          <i class="fa fa-times-circle fa-fw" aria-hidden="true"></i>
  573.                          Cancel
  574.                      </button>
  575.                     <button
  576.                             type="button"
  577.                             class="btn btn-success"
  578.                             id="addRole">
  579.                         <i class="fa fa-floppy-o fa-fw" aria-hidden="true"></i>
  580.                         Save
  581.                     </button>
  582.                 </div>
  583.              </div>
  584.         </div>
  585.     </div>
  586.     {% endif %}
  587. </div>
  588. {% include "footer.html.twig" %}
  589.     <script src="{{ asset('js/handlebars.runtime.min.js') }}" type="text/javascript"></script>
  590.     <script src="{{ asset('js/handlebars.min.js') }}" type="text/javascript"></script>
  591.     <script src="{{ asset('js/app.min.js') }}" type="text/javascript"></script>
  592.     <script src="{{ asset('js/jquery.dataTables.min.js') }}" type="text/javascript"></script>
  593.     <script src="{{ asset('js/dataTables.bootstrap.min.js') }}" type="text/javascript"></script>
  594.     <script src="{{ asset('js/dataTables.responsive.min.js') }}" type="text/javascript"></script>
  595.     <script src="{{ asset('js/responsive.bootstrap.min.js') }}" type="text/javascript"></script>
  596.     <script src="{{ asset('js/jquery.nestable.js') }}" type="text/javascript"></script>
  597.     <script src="{{ asset('js/tipped.js') }}" type="text/javascript"></script>
  598.     <script src="{{ asset('js/bootstrap-editable.min.js') }}" type="text/javascript"></script>
  599.     <script src="{{ asset('js/bootstrap-tooltip.js') }}" type="text/javascript"></script>
  600.     <script src="{{ asset('js/confirm-bootstrap.js') }}" type="text/javascript"></script>
  601.     <script src="{{ asset('js/bootstrap-editable.min.js') }}" type="text/javascript"></script>
  602.     <script src="{{ asset('js/dataTables.select.min.js') }}" type="text/javascript"></script>
  603.     <script src="{{ asset('js/bootstrap-dialog.js') }}" type="text/javascript"></script>
  604.     <script src="{{ asset('js/dataTables.buttons.min.js') }}" type="text/javascript"></script>
  605.     <script src="{{ asset('js/dataTables.rowReorder.min.js') }}" type="text/javascript"></script>
  606.     <script src="{{ asset('js/tinymce.min.js') }}" type="text/javascript"></script>
  607.     <script type="text/javascript">
  608.         var removeEmailAttachments = '{{ path('remove_email_attachments') }}';
  609.     </script>
  610.     <script src="{{ asset('js/dropzone.js') }}" type="text/javascript"></script>
  611.     <script type="text/javascript" class="init">
  612.         $(document).ready(function() {
  613.             //set the top nav menu style
  614.             $(".groups").addClass('navactive');
  615.             Tipped.create('.tipso', {maxWidth: 250});
  616.             $("#compose").css('display', 'none');
  617.             var status= 0;
  618.             var ajaxUrl = "/dataTablesServerProcessing?group={{ data.group.idGroup }}";
  619.             var mainTableDefaults = {
  620.                 {% if app.request.query.get("display") is defined and app.request.query.get("display") != "" %}
  621.                     {% if  app.request.query.get("display") == 'all' %}
  622.                         paging: false,
  623.                     {% else %}
  624.                         iDisplayLength: {{ app.request.query.get("display") }},
  625.                     {% endif %}
  626.                 {% endif %}
  627.                 "processing": true,
  628.                 "language": {
  629.                     "processing": '<div id="cssload-wrapper">' +
  630.                         '<div id="cssload-border">' +
  631.                         '<div id="cssload-whitespace">' +
  632.                         '<div id="cssload-line">' +
  633.                         '</div>' +
  634.                         '</div>' +
  635.                         '</div>' +
  636.                         '</div>',
  637.                     "emptyTable": "There are no members in the group. Please add members using \"Add Member\" button."
  638.                 },
  639.                 "serverSide": true,
  640.                 "pageLength": 50,
  641.                 "ajax": ajaxUrl,
  642.                 dom:
  643.                 "<'row'<'col-sm-6 text-center'B><'col-sm-3'l><'col-sm-3'f>>" +
  644.                 "<'toolbar'><'row'<'col-sm-12'tr>>" +
  645.                 "<'row'<'col-sm-3'i><'col-sm-9'p>>",
  646.                 "info": true,
  647.                 aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
  648.                 columns: [
  649.                     {
  650.                         "orderable": false
  651.                     },
  652.                     {
  653.                         data: 'sname',
  654.                         "searchable": true,
  655.                         render: function(data, type, full, meta)
  656.                         {
  657.                             var data = '<span ' +
  658.                                 'class="info">' +
  659.                                 '<div ' +
  660.                                 '   class="media">';
  661.                             {% if data.group.idMstemplate == 2 %}
  662.                                 data += '<div ' +
  663.                                     'class="media-left">';
  664.                                 if (status == 0) {
  665.                                     data += '<a ' +
  666.                                         'href="{{ path('view_profile', {'user': 'idInd'}) }}" ' +
  667.                                         'target="_blank">';
  668.                                 }
  669.                                 data += '<img ' +
  670.                                     'alt="expert image 64x64" ' +
  671.                                     'class="media-object" ' +
  672.                                     'data-src="' + full.image +'" ' +
  673.                                     'style="width: 64px;" ' +
  674.                                     'src="' + full.image + '" ' +
  675.                                     'data-holder-rendered="true" ' +
  676.                                     'onerror="this.src=\'/assets/uploads/default.png\';" />';
  677.                                 if (status == 0) {
  678.                                     data += '</a>';
  679.                                 }
  680.                                 data += '</div>';
  681.                             {% endif %}
  682.                             data += '<div ' +
  683.                                 'class="media-body">' +
  684.                                 '<h4 ';
  685.                             if (full.status != 1
  686.                                 || full.deceased != 0
  687.                                 || full.retired != 0
  688.                             ) {
  689.                                 data += ' class="text-warning" ';
  690.                             } else {
  691.                                 data += ' class="media-heading" ';
  692.                             }
  693.                             data += '>';
  694.                             //console.log(full);
  695.                             if (status == 0) {
  696.                                 data += '<a ' +
  697.                                     'href="{{ path('view_profile', {'user': 'idInd'}) }}" ' +
  698.                                     'target="_blank" '
  699.                                 if (full.status != 1
  700.                                     || full.deceased != 0
  701.                                     || full.retired != 0
  702.                                 ) {
  703.                                     data += 'class="text-warning" ';
  704.                                 }
  705.                                 data += '>';
  706.                             }
  707.                             data +=  full.name;
  708.                             if (full.status != 1) {
  709.                                 data += ' (profile not active!)';
  710.                             }
  711.                             if (full.deceased != 0) {
  712.                                 data += ' (deceased!)';
  713.                             }
  714.                             if (full.retired != 0) {
  715.                                 data += ' (retired!)';
  716.                             }
  717.                             if (status == 0) {
  718.                                 data += '</a>';
  719.                             }
  720.                             data +=  '</h4><p>';
  721.                             if ($.trim(full.instName) != "") {
  722.                                 if (status == 0) {
  723.                                     data += '<a ' +
  724.                                         'href="{{ path('view_institution',{'instId':'idInst'}) }}" ' +
  725.                                         'target="_blank">';
  726.                                 }
  727.                                 data += '<small>' + full.instName + '</small>';
  728.                                 if (status == 0) {
  729.                                     data += '</a>';
  730.                                 }
  731.                                 data += '<br />';
  732.                             }
  733.                             if (status == 0) {
  734.                                 if ($.trim(full.groupRole) != "") {
  735.                                     data += '<span class="label label-primary">' + full.groupRole + '</span>';
  736.                                     {#  % if (data.isGroupAdmin == 1) or (is_granted('ROLE_GLOBAL_EDITOR')) % #}
  737.                                     {#  % if is_granted('ROLE_ADMIN') % #}
  738.                                     {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  739.                                     data += '<span ' +
  740.                                         'class="edit-role">' +
  741.                                         '<i class="fa fa-cog fa-fw tipso" ' +
  742.                                         'aria-hidden="true" ' +
  743.                                         'title="Edit role">' +
  744.                                         '</i>' +
  745.                                         '</span>';
  746.                                     {% endif %}
  747.                                 } else {
  748.                                     {#  % if (data.isGroupAdmin == 1) or (is_granted('ROLE_GLOBAL_EDITOR')) % #}
  749.                                     {#  % if is_granted('ROLE_ADMIN') % #}
  750.                                     {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  751.                                     data += '<span ' +
  752.                                         'class="edit-role">' +
  753.                                         '<i ' +
  754.                                         'class="fa fa-plus fa-fw tipso" ' +
  755.                                         'aria-hidden="true" ' +
  756.                                         'title="Add role">' +
  757.                                         '</i>' +
  758.                                         '</span>';
  759.                                     {% endif %}
  760.                                 }
  761.                             }
  762.                             data += '</p></div>' +
  763.                                     '</div></span>';
  764.                             data = data.replace(/idInd/g, full.idInd);
  765.                             data = data.replace(/idInst/g, full.idInst);
  766.                             return data;
  767.                         }
  768.                     },
  769.                     {
  770.                         data: 'groupRole',
  771.                         "searchable": true
  772.                     },
  773.                     {
  774.                         data: 'country',
  775.                         "searchable": true
  776.                     },
  777.                     {
  778.                         data: 'fname',
  779.                         "searchable": true
  780.                     },
  781.                 ],
  782.                 columnDefs: [
  783.                     {
  784.                         "targets": [0,3],
  785.                         "defaultContent": ""
  786.                     },
  787.                     {% if app.user %}
  788.                     {
  789.                         "targets":  0,
  790.                         className: 'select-checkbox'
  791.                     },
  792.                     {% endif %}
  793.                     {
  794.                         "targets" : 4,
  795.                         visible: false
  796.                     },
  797.                 ],
  798.                 {#  % if (data.isGroupAdmin == 1) or (is_granted('ROLE_GLOBAL_EDITOR')) % #}
  799.                 {#   % if is_granted('ROLE_ADMIN') % #}
  800.                 {% if (data.isGroupAdmin == 1) or is_granted('ROLE_ADMIN') %}
  801.                     select: {
  802.                         style:    'multi+shift',
  803.                         selector: 'td:first-child'
  804.                     },
  805.                     buttons: [
  806.                         {
  807.                             text: 'Add Member(s)',
  808.                             className: 'add-member'
  809.                         },
  810.                         {
  811.                             text: 'Remove Selected',
  812.                             className: 'remove-member'
  813.                         },
  814.                     ],
  815.                 {% else %}
  816.                     buttons: [],
  817.                 {% endif %}
  818.                 "order": [[ 3, "desc" ]],
  819.                 initComplete : function( settings, json ) {
  820.                     $(".wait").css('display','none');
  821.                     Tipped.create('.tipso', {maxWidth: 250});
  822.                     if ($('#datatable').DataTable().data().count() > 0) {
  823.                         $("#compose").css('display', 'block');
  824.                     }
  825.                 }
  826.             };
  827.             var table = $('#datatable').DataTable(mainTableDefaults);
  828.             {% if (data.isGroupAdmin == 1) or (is_granted('ROLE_GLOBAL_EDITOR')) %}
  829.             /*
  830.             this seems to cause trouble
  831.             arno 27/11/2024
  832.             table.buttons(1).disable();
  833.              */
  834.             table.on( 'select', function ( e, dt, type, indexes ) {
  835.                 if (table.rows('.selected').count() > 0) {
  836.                     table.buttons(1).enable();
  837.                 } else {
  838.                     table.buttons(1).disable();
  839.                 }
  840.             } ).on( 'deselect', function ( e, dt, type, indexes ) {
  841.                 if (table.rows('.selected').count() > 0) {
  842.                     table.buttons(1).enable();
  843.                 } else {
  844.                     table.buttons(1).disable();
  845.                 }
  846.             } );
  847.             $("body").on('click',".edit-role",function (e) {
  848.                 var $this = table.row( $(this).parents('tr') ).data();
  849.                 let idInd = $this.idInd;
  850.                 $editMember = $("#editMember")
  851.                 $editMember.find(".member").html("");
  852.                 $editMember.find("#memberid").val("");
  853.                 e.preventDefault();
  854.                 $editMember.find("#memberid").val(idInd);
  855.                 $editMember.find("#groupRole").val($this.groupRole);
  856.                 if ($.trim($this.groupRole) == "") {
  857.                     $editMember.find(".modal-title").html("Add Group Role");
  858.                     $editMember.find(".member").html("Add role for <strong>"+$this.fname +" "+ $this.lname+"</strong>.");
  859.                 } else {
  860.                     $editMember.find(".modal-title").html("Edit Group Role");
  861.                     $editMember.find(".member").html("Edit role for <strong>"+$this.fname +" "+ $this.lname+"</strong>.");
  862.                 }
  863.                 $editMember.modal("show");
  864.             });
  865.             $("#editMember" ).on( "click", "#addRole", function(e) {
  866.                 e.preventDefault();
  867.                 $this = $(this);
  868.                 $editMember = $("#editMember");
  869.                 $editMember.find(".ajaxresult").remove();
  870.                 memberid = $.trim($editMember.find("#memberid").val());
  871.                 groupid = {{ data.group.idGroup }};
  872.                 role = $.trim($editMember.find("#groupRole").val());
  873.                 if (memberid!="") {
  874.                     $.ajax({
  875.                         url: '{{ path('set_group_role') }}',
  876.                         type: 'POST',
  877.                         data: {
  878.                             memberid: memberid,
  879.                             groupid: groupid,
  880.                             role: role
  881.                         },
  882.                         success: function (response) {
  883.                             if (response.status == 1) {
  884.                                 $('#datatable').DataTable().draw();
  885.                                 $("#memberid").after("<span class='ajaxresult text-success'>Role updated successfully.</span>");
  886.                                 setTimeout(function() {
  887.                                     $(".ajaxresult").remove();
  888.                                     $editMember.modal("hide");
  889.                                 }, 1000);
  890.                             } else {
  891.                                 $("#memberid").after("<span class='ajaxresult text-danger'>"+response.message+"</span>");
  892.                             }
  893.                         }
  894.                     });
  895.                 }
  896.             });
  897.             $("body").on( "click", ".remove-member", function(e) {
  898.                 if (table.rows('.selected').count() > 0) {
  899.                     var memberids = $.map(table.rows('.selected').data(), function (item) {
  900.                         return item['idInd'];
  901.                     });
  902.                     BootstrapDialog.confirm({
  903.                         title: 'Remove Member(s)',
  904.                         message: 'Remove selected member(s) from group?',
  905.                         type: BootstrapDialog.TYPE_DANGER,
  906.                         closable: false,
  907.                         draggable: false,
  908.                         btnCancelLabel: '<i class="fa fa-times-circle fa-fw" aria-hidden="true"></i> Cancel',
  909.                         btnOKLabel: '<i class="fa fa-user-times fa-fw" aria-hidden="true"></i> Remove Member(s)',
  910.                         btnOKClass: 'btn-danger',
  911.                         btnCancelClass: 'btn-success',
  912.                         callback: function(result) {
  913.                             if (result) {
  914.                                 $.ajax({
  915.                                     url: "{{ path('delete_group_member') }}",
  916.                                     method: 'POST',
  917.                                     data: {memberids: memberids, groupid: {{ data.group.idGroup }} },
  918.                                     success: function (response) {
  919.                                         if (response.status == 1) {
  920.                                             $('#datatable').DataTable().draw();
  921.                                             if ($('#datatable').DataTable().data().count() > 0) {
  922.                                                 $("#compose").css('display', 'block');
  923.                                             } else {
  924.                                                 $("#compose").css('display', 'none');
  925.                                             }
  926.                                         }
  927.                                     }
  928.                                 });
  929.                             }
  930.                         }
  931.                     });
  932.                 }
  933.             });
  934.             $(".editGroup").click(function (e) {
  935.                 console.log('edit.group.content.html.twig - editGroup - click');
  936.                 e.preventDefault();
  937.                 $("#groupEdit").modal("show");
  938.             })
  939.             $(".saveGroup").click(function (e) {
  940.                 e.preventDefault();
  941.                 if ($("#officialBody").is(":checked")) {
  942.                     officialBody = 1;
  943.                 } else {
  944.                     officialBody = 0;
  945.                 }
  946.                 $.ajax({
  947.                     url: '{{ path('save_group') }}',
  948.                     data: {
  949.                         'groupid': {{ data.group.idGroup }},
  950.                         'groupname': $("#groupName").val(),
  951.                         'description': tinyMCE.get('description').getContent(),
  952.                         'officialbody': officialBody,
  953.                         'template': $("#template").val()
  954.                     },
  955.                     type: 'POST',
  956.                     success: function (response) {
  957.                         //console.log(response.message);
  958.                         if (response.status == 1 ) {
  959.                             $("#groupEdit").modal("hide");
  960.                             window.location.reload();
  961.                         } else {
  962.                             $("#groupEdit").modal("show");
  963.                         }
  964.                     }
  965.                 });
  966.             });
  967.             //open the modal to enter a new member
  968.             /*
  969.             $("body").on( "click", ".add-member", function(e) {
  970.                 e.preventDefault();
  971.                 $("#addMember").modal("show");
  972.                 $(".add-all").css('display','none');
  973.             });
  974.              */
  975.             $(".add-member").click(function (e) {
  976.                 e.preventDefault();
  977.                 $("#addMember").modal("show");
  978.                 $(".add-all").css('display','none');
  979.                 const searchTerm = document.getElementById('searchTerm');
  980.                 const searchButton = document.getElementById('searchButton');
  981.                 searchTerm.addEventListener('keydown', (event) => {
  982.                     if (event.keyCode === 13) {
  983.                         searchButton.click()
  984.                     }
  985.                 })
  986.             });
  987.             $('.search-panel .dropdown-menu').find('a').click(function(e) {
  988.                 e.preventDefault();
  989.                 var param = $(this).attr("href").replace("#","");
  990.                 var concept = $(this).text();
  991.                 $('.search-panel span#search_concept').text(concept);
  992.                 $('.input-group #search_param').val(param);
  993.                 var searchfield = $("#searchTerm");
  994.                 if (param=="group") {
  995.                     var selectbox = '<select id="searchTerm" name="searchTerm" class="form-control"></select>';
  996.                     searchfield.replaceWith(selectbox);
  997.                     $.getJSON( "{{ path('get_all_groups_json') }}", function( data ) {
  998.                         $.each( data, function( key, val ) {
  999.                             $("#searchTerm").append($("<option></option>")
  1000.                                             .attr("value",val.groupname)
  1001.                                             .text(val.groupname));
  1002.                         })
  1003.                     });
  1004.                 } else {
  1005.                     searchfield.replaceWith(
  1006.                         '<input ' +
  1007.                         '   type="text" ' +
  1008.                         '   class="form-control" ' +
  1009.                         '   name="searchTerm" ' +
  1010.                         '   id="searchTerm" ' +
  1011.                         '   placeholder="Search Members...">'
  1012.                     );
  1013.                 }
  1014.             });
  1015.             /**
  1016.              * try to find a member to be added to a group
  1017.              */
  1018.             $("body").on( "click", ".searchMembers", function(e) {
  1019.                 e.preventDefault();
  1020.                 if ($.trim($("#searchTerm").val()) != "") {
  1021.                     $(".result").css('display','block');
  1022.                     var resultSet = $('.resultSet').DataTable( {
  1023.                         "language": {
  1024.                             "emptyTable": "No member found using above search criteria."
  1025.                         },
  1026.                         destroy: true,
  1027.                         "ajax": {
  1028.                             url: "{{ path('get_members') }}",
  1029.                             type: "POST",
  1030.                             data: {
  1031.                                 searchterm: $.trim($("#searchTerm").val()),
  1032.                                 searchparam: $("#search_param").val(),
  1033.                                 groupid: {{ data.group.idGroup}}
  1034.                             },
  1035.                         },
  1036.                         "columns": [
  1037.                             {
  1038.                                 "data": "id_ind",
  1039.                                 render:function (data, type, full, meta) {
  1040.                                     var url = "{{ path('view_profile', {'user': 'idInd'}) }}";
  1041.                                     url = url.replace(/idInd/g, full.id_ind);
  1042.                                     return '<a href="' + url + '" target="_blank">' + full.title + ' ' + full.fname + ' ' + full.sname + '</a>';
  1043.                                 }
  1044.                             },
  1045.                             {
  1046.                                 "data": "id_ind",
  1047.                                 render:function (data, type, full, meta) {
  1048.                                     return '<input type="text" class="form-control grouprole" id="input_'+data+'" name="groupRole"  placeholder="Add Group Role...">';
  1049.                                 }
  1050.                             },
  1051.                             {
  1052.                                 "data": "inst_name"
  1053.                             },
  1054.                             {
  1055.                                 "data": "country"
  1056.                             },
  1057.                             {
  1058.                                 "data": "id_ind",
  1059.                                 render:function (data, type, full, meta) {
  1060.                                     return '<a href="javascript:void(0);" class="btn btn-sm btn-success addMemberGroup"><i class="fa fa-plus" aria-hidden="true"></i> Add</a>';
  1061.                                 }
  1062.                             },
  1063.                             {
  1064.                                 "data": "relevance"
  1065.                             },
  1066.                        ],
  1067.                        columnDefs: [
  1068.                            {
  1069.                                'targets': [5],
  1070.                                'visible': false,
  1071.                                'searchable': true
  1072.                            }
  1073.                        ],
  1074.                        order: [[ 5, "desc" ]],
  1075.                        aLengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
  1076.                        "fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
  1077.                            if (($('.resultSet').DataTable().rows().data().count() > 0) && ($('.resultSet').DataTable().rows().data().count()<100)) {
  1078.                                $(".add-all").css('display','inline-block');
  1079.                            } else {
  1080.                                $(".add-all").css('display','none');
  1081.                            }
  1082.                        }
  1083.                    } );
  1084.                }
  1085.             });
  1086.             $("body").on("click",".addMemberGroup",function (event) {
  1087.                 var $this = $(this);
  1088.                 var idInd = $this.parents("tr").attr('id');
  1089.                $.ajax({
  1090.                    url: "{{ path('add_group_member') }}",
  1091.                    data:{userid: idInd, groupid: "{{ data.group.idGroup }}",grouprole: $this.parents("tr").find(".grouprole").val()},
  1092.                    type: "POST",
  1093.                    success:function (response) {
  1094.                       if (response.status ==1) {
  1095.                           $('.resultSet').DataTable().row( $this.parents('tr') ).remove().draw();
  1096.                           table.ajax.reload();
  1097.                           if ($('.resultSet').DataTable().rows().data().count()==0) {
  1098.                               $(".add-all").css('display','none');
  1099.                               //console.log($('#datatable').DataTable().data().count());
  1100.                               if ($('#datatable').DataTable().data().count() > 0) {
  1101.                                   $("#compose").css('display', 'block');
  1102.                               }
  1103.                           }
  1104.                       }
  1105.                    }
  1106.                });
  1107.             });
  1108.             $("body").on("click",".add-all",function (event) {
  1109.                 if ( $('.resultSet').DataTable() instanceof $.fn.dataTable.Api) {
  1110.                     var element = {};
  1111.                     var memberdata = [];
  1112.                     $('.resultSet').DataTable().rows().data().each(function (value) {
  1113.                         var role;
  1114.                         if ($("#input_"+value.id_ind).val()===undefined) {
  1115.                             role = "";
  1116.                         } else {
  1117.                             role = $("#input_"+value.id_ind).val();
  1118.                         }
  1119.                         $.ajax({
  1120.                             url: "{{ path('add_group_member') }}",
  1121.                             data:{userid: value.id_ind, groupid: "{{ data.group.idGroup }}",grouprole: role},
  1122.                             type: "POST",
  1123.                             success:function (response) {
  1124.                                 if (response.status ==1) {
  1125.                                     $('.resultSet').DataTable().row($("tr#"+value.id_ind) ).remove().draw();
  1126.                                     table.ajax.reload();
  1127.                                     if ($('.resultSet').DataTable().rows().data().count()==0) {
  1128.                                         $(".add-all").css('display','none');
  1129.                                     }
  1130.                                     if ($('#datatable').DataTable().data().count() > 0) {
  1131.                                         $("#compose").css('display', 'block');
  1132.                                     }
  1133.                                 }
  1134.                             }
  1135.                         });
  1136.                     });
  1137.                 }
  1138.             });
  1139.             $('#addMember').on('hidden.bs.modal', function () {
  1140.                 $('.resultSet').DataTable().clear().draw();
  1141.                 $("#searchTerm").val("");
  1142.                 $(".result").css('display','none');
  1143.             });
  1144.             tinymce.init({
  1145.                 selector: 'textarea',
  1146.                 plugins: [
  1147.                     "advlist autolink lists link image charmap print preview anchor",
  1148.                     "searchreplace visualblocks code fullscreen",
  1149.                     "insertdatetime media table contextmenu paste imagetools powerpaste"
  1150.                 ],
  1151.                 toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
  1152.                 powerpaste_allow_local_images: true,
  1153.                 powerpaste_word_import: 'prompt',
  1154.                 powerpaste_html_import: 'prompt',
  1155.                 branding: false,
  1156.                 relative_urls: false,
  1157.                 convert_urls: false,
  1158.                 forced_root_block : false
  1159.             });
  1160.             $(document).on('focusin', function(event) {
  1161.                 if ($(event.target).closest(".mce-window").length) {
  1162.                     e.stopImmediatePropagation();
  1163.                 }
  1164.             });
  1165.             /**
  1166.              * Upload script
  1167.              */
  1168.             Dropzone.options.myAwesomeDropzone = {
  1169.                 init: function() {
  1170.                     this.on('success', function(file, response) {
  1171.                         $("#message").after($('<input type="hidden" name="file[]" class="file" value="' + response + '">'));
  1172.                     });
  1173.                     this.on('queuecomplete', function() {
  1174.                         // Invoked when all files finished uploading
  1175.                         // Now just submit the form. It will send the filenames along since
  1176.                         // they are added as hidden input fields.
  1177.                     });
  1178.                     this.on('removedfile', function (file, response) {
  1179.                         $('.file:input[value="'+file.fid+'"]').remove();
  1180.                     });
  1181.                 },
  1182.                 maxFilesize: 10,
  1183.                 maxFiles: 15,
  1184.                 accept: function(file, done) {
  1185.                     var thumbnail = $('.dropzone').find(".dz-preview:last");
  1186.                     thumbnail.removeClass('dz-file-preview').addClass('dz-image-preview');
  1187.                     switch (file.type) {
  1188.                         case 'application/pdf':
  1189.                             thumbnail.find('img').attr('src','{{ asset("img/pdf-icon.png") }}');
  1190.                             break;
  1191.                         case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
  1192.                             thumbnail.find('img').attr('src','{{ asset("img/word-icon.png") }}');
  1193.                             break;
  1194.                         case 'application/vnd.ms-excel':
  1195.                             thumbnail.find('img').attr('src','{{ asset("img/excel-icon.png") }}');
  1196.                             break;
  1197.                         case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
  1198.                             thumbnail.find('img').attr('src','{{ asset("img/excel-icon.png") }}');
  1199.                             break;
  1200.                         case 'application/vnd.ms-powerpoint':
  1201.                             thumbnail.find('img').attr('src','{{ asset("img/PowerPoint-icon.png") }}');
  1202.                             break;
  1203.                         case 'application/application/zip, application/octet-stream':
  1204.                             thumbnail.find('img').attr('src','{{ asset("img/zip-icon.jpg") }}');
  1205.                             break;
  1206.                         case 'text/csv':
  1207.                             thumbnail.find('img').attr('src','{{ asset("img/csv-icon.jpg") }}');
  1208.                             break;
  1209.                         case 'text/plain':
  1210.                             thumbnail.find('img').attr('src','{{ asset("img/txt-icon.png") }}');
  1211.                             break;
  1212.                         case 'application/zip':
  1213.                             thumbnail.find('img').attr('src','{{ asset("img/zip-icon.jpg") }}');
  1214.                             break;
  1215.                     }
  1216.                     done();
  1217.                 },
  1218.             };
  1219.             $("#sendmail").click(function () {
  1220.                 $this = $(this);
  1221.                 var subject = $("#subject").val();
  1222.                 var message = tinyMCE.get('message').getContent();
  1223.                 selfEmail = $("#selfEmail").is(":checked");
  1224.                 var file = $('input:hidden.file').serialize();
  1225.                 var error = false;
  1226.                 if ($.trim(subject)=="") {
  1227.                     $("#subject").parents('.form-group').addClass('has-error');
  1228.                     errorsubject = true;
  1229.                 } else {
  1230.                     $("#subject").parents('.form-group').removeClass('has-error');
  1231.                     errorsubject = false;
  1232.                 }
  1233.                 if ($.trim(message)=="") {
  1234.                     $("#message").parents('.form-group').addClass('has-error');
  1235.                     $("#message").siblings(".mce-tinymce").css('border-color','red');
  1236.                     errormessage = true;
  1237.                 } else {
  1238.                     $("#message").parents('.form-group').removeClass('has-error');
  1239.                     $("#message").siblings(".mce-tinymce").css('border-color','rgb(210, 214, 222)');
  1240.                     errormessage = false;
  1241.                 }
  1242.                 if (!errormessage && !errorsubject) {
  1243.                     $this.prop("disabled",true);
  1244.                     $this.html("<i class='fa fa-spin fa-cog'></i> Sending</button>");
  1245.                     $.ajax({
  1246.                         url: "{{ path('email_queue') }}",
  1247.                         data:{
  1248.                             userid: "{{ app.user.id }}",
  1249.                             groupid: "{{ data.group.idGroup }}",
  1250.                             email: "{{ app.user.email }}",
  1251.                             selfmail: selfEmail,
  1252.                             subject: subject,
  1253.                             message: message,
  1254.                             file: file,
  1255.                             searchstring: window.location.href
  1256.                         },
  1257.                         type: "POST",
  1258.                         success:function (response) {
  1259.                             $this.html("Send <i class='fa fa-envelope-o'></i>");
  1260.                             $(".dz-default.dz-message").css("opacity",1);
  1261.                             $("#selfEmail").prop("checked",false);
  1262.                             $("#subject").val("");
  1263.                             tinymce.get("message").setContent('');
  1264.                             $('div.dz-success').remove();
  1265.                             $("#message").siblings(".file").remove();
  1266.                             $this.prop("disabled",false);
  1267.                             $("#compose-mail").modal("hide");
  1268.                             BootstrapDialog.alert({
  1269.                                 title: 'Email Received Successfully.',
  1270.                                 message: 'Your email is successfully received. It will now be queued and sent out to the recipients shortly.',
  1271.                                 type: BootstrapDialog.TYPE_SUCCESS,
  1272.                                 closable: false,
  1273.                                 draggable: false,
  1274.                                 buttonLabel: 'OK',
  1275.                             });
  1276.                         }
  1277.                     });
  1278.                 }
  1279.             });
  1280.             {% endif %}
  1281.             $('[class=showInfo]').on('click', function() {
  1282.                 $(document).find('[class=infoHidden]').hide();
  1283.                 $(document).find('[class=infoShown]').show();
  1284.                 return false;
  1285.             });
  1286.             $('[class=hideInfo]').on('click', function() {
  1287.                 $(document).find('[class=infoHidden]').show();
  1288.                 $(document).find('[class=infoShown]').hide();
  1289.                 return false;
  1290.             });
  1291.         } );
  1292.     </script>
  1293. {% endblock %}