"Fossies" - the Fresh Open Source Software Archive

Member "koha-19.11.15/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgets.tt" (23 Feb 2021, 29140 Bytes) of package /linux/misc/koha-19.11.15.tar.gz:


The requested HTML page contains a <FORM> tag that is unusable on "Fossies" in "automatic" (rendered) mode so that page is shown as HTML source code (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 [% USE raw %]
    2 [% USE Asset %]
    3 [% USE AuthorisedValues %]
    4 [% USE Branches %]
    5 [% USE Price %]
    6 [% SET footerjs = 1 %]
    7 [% INCLUDE 'doc-head-open.inc' %]
    8 <title>Koha &rsaquo; Administration &rsaquo; Funds[% IF op == 'add_form' %] &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund [% END %][% END %]</title>
    9 [% Asset.css("lib/jquery/plugins/treetable/stylesheets/jquery.treetable.css") | $raw %]
   10 [% INCLUDE 'doc-head-close.inc' %]
   11 </head>
   12 
   13 <body id="admin_aqbudgets" class="admin">
   14 [% INCLUDE 'header.inc' %]
   15 [% INCLUDE 'budgets-admin-search.inc' %]
   16 
   17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
   18     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/aqbudgetperiods.pl">Budgets</a> &rsaquo; [% IF op == 'list' %][% IF budget_period_id %]Funds for '[% budget_period_description | html %]'[% ELSE %]All funds[% END %][% END %]
   19     [% IF op == 'add_form' %]
   20       <a href="/cgi-bin/koha/admin/aqbudgets.pl?budget_period_id=[% budget_period_id | uri %]">Funds</a> &rsaquo; [% IF ( budget_id ) %]Modify fund[% IF ( budget_name ) %] '[% budget_name | html %]'[% END %][% ELSE %]Add fund[% END %]
   21     [% END %]
   22     [% IF op == 'delete_confirm' %]
   23       <a href="/cgi-bin/koha/admin/aqbudgets.pl">Funds</a> &rsaquo; Delete fund?
   24     [% END %]
   25 </div>
   26 
   27 <div class="main container-fluid">
   28     <div class="row">
   29         <div class="col-sm-10 col-sm-push-2">
   30             <main>
   31 
   32 [% UNLESS op == 'delete_confirm' %][% INCLUDE 'budgets-admin-toolbar.inc' %][% END %]
   33 
   34 [% IF (error_not_authorised_to_modify) %]
   35     <div class="dialog alert">
   36         <p>You are not authorized to modify this fund</p>
   37     </div>
   38 [% END %]
   39 
   40 [% IF op == 'list' %]
   41 
   42 <h1>
   43   [% IF budget_period_id %]
   44     Funds for '[% budget_period_description | html %]'
   45   [% ELSE %]
   46     All funds
   47   [% END %]
   48 </h1>
   49 
   50 [% INCLUDE 'budgets-active-currency.inc' %]
   51 
   52 [% IF budgets %]
   53 
   54 <table id="budgeth" class="group">
   55     [% UNLESS budget_period_id %]
   56       <caption>
   57         <span class="actions"><a href="#" id="expand_all">Expand all</a>
   58         | <a href="#" id="collapse_all">Collapse all</a>
   59         | <a href="#" id="hide_inactive">Hide inactive budgets</a>
   60         | <a href="#" id="show_inactive">Show inactive budgets</a></span>
   61       </caption>
   62     [% END %]
   63     <thead>
   64         <tr>
   65             <th>Active</th>
   66             <th>Budget period description</th>
   67             <th>Fund code</th>
   68             <th>Fund name</th>
   69             <th>Base-level allocated</th>
   70             <th>Base-level ordered</th>
   71             <th>Total ordered</th>
   72             <th>Base-level spent</th>
   73             <th>Total spent</th>
   74             <th>Base-level available</th>
   75             <th>Total available</th>
   76             <th>Actions</th>
   77         </tr>
   78     </thead>
   79     <tfoot>
   80     <tr>
   81     <th></th>
   82     <th></th>
   83     <th colspan="2" style="text-align: left;" nowrap="nowrap">Period allocated [% IF budget_period_total %][% budget_period_total | $Price %][% END %]  </th>
   84     <th nowrap="nowrap" class="data"> [% period_alloc_total | $Price %]</th>
   85     <th></th>
   86     <th class="data">[% ordered_total | $Price %]</th>
   87     <th></th>
   88     <th class="data">[% spent_total | $Price %]</th>
   89     <th></th>
   90     <th class="data">[% available_total | $Price %]</th>
   91     <th></th>
   92     </tr>
   93     </tfoot>
   94     <tbody>
   95     [% FOREACH budget IN budgets %]
   96     [% IF budget.budget_parent_id %]
   97       <tr data-tt-id="[% budget.budget_id | html %]" data-tt-parent-id="[% budget.budget_parent_id | html %]">
   98     [% ELSE %]
   99       <tr data-tt-id="[% budget.budget_id | html %]">
  100     [% END %]
  101     <td>[% budget.budget_period_active | html %]</td>
  102     <td>Budget [% budget.budget_period_description | html %] [id=[% budget.budget_period_id | html %]][% UNLESS budget.budget_period_active %] (inactive)[% END %]</td>
  103     <td>[% budget.budget_code | html %]</td>
  104     <td>[% budget.budget_name | html %]</td>
  105     <td class="data">
  106       [% IF budget.budget_parent_id %]
  107         <span class="child_fund_amount">[% budget.budget_amount | $Price %]</span>
  108       [% ELSE %]
  109         <span class="total_amount">[% budget.budget_amount | $Price %]</span>
  110       [% END %]
  111     </td>
  112     <td class="data">
  113       [% IF budget.budget_parent_id %]
  114         <span class="child_fund_amount">[% budget.budget_ordered | $Price %]</span>
  115       [% ELSE %]
  116         <span class="total_amount">[% budget.budget_ordered | $Price %]</span>
  117       [% END %]
  118     </td>
  119     <td class="data">
  120       [% IF budget.budget_parent_id %]
  121         <span class="child_fund_amount">[% budget.total_ordered | $Price %]</span>
  122       [% ELSE %]
  123         <span class="total_amount">[% budget.total_ordered | $Price %]</span>
  124       [% END %]
  125     </td>
  126     <td class="data">
  127       [% IF budget.budget_parent_id %]
  128         <span class="child_fund_amount">[% budget.budget_spent | $Price %]</span>
  129       [% ELSE %]
  130         <span class="total_amount">[% budget.budget_spent | $Price %]</span>
  131       [% END %]
  132     </td>
  133     <td class="data">
  134       [% IF budget.budget_parent_id %]
  135         <span class="child_fund_amount">[% budget.total_spent | $Price %]</span>
  136       [% ELSE %]
  137         <span class="total_amount">[% budget.total_spent | $Price %]</span>
  138       [% END %]
  139     </td>
  140 
  141 
  142     [% BLOCK colorcellvalue %]
  143         [% IF parent %]
  144             [% IF (value > 0) %]
  145                 <span class="child_fund_amount" style="color: green;">
  146             [% ELSIF (value < 0) %]
  147                 <span class="child_fund_amount" style="color: red;">
  148             [% ELSE %]
  149                 <span class="child_fund_amount">
  150             [% END %]
  151          [% ELSE %]
  152             [% IF (value > 0) %]
  153                 <span class="total_amount" style="color: green;">
  154             [% ELSIF (value < 0) %]
  155                 <span class="total_amount" style="color: red;">
  156             [% ELSE %]
  157                 <span class="totalamount">
  158             [% END %]
  159         [% END %]
  160             [% value | $Price %]
  161         </span>
  162     [% END %]
  163     <td class="data">
  164         [% INCLUDE colorcellvalue value=budget.budget_remaining parent=budget.budget_parent_id %]
  165     </td>
  166     <td class="data">
  167         [% INCLUDE colorcellvalue value=budget.total_remaining parent=budget.budget_parent_id %]
  168     </td>
  169     [% IF ( budget.budget_lock ) %]
  170         <td> <span></span> </td>
  171     [% ELSE %]
  172         <td>
  173             <div class="dropdown dropup">
  174                 <a class="btn btn-default btn-xs dropdown-toggle" id="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]" role="button" data-toggle="dropdown" href="#">
  175                    Actions <b class="caret"></b>
  176                 </a>
  177                 <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="budgetactions[% budget.budget_id | html %]_[% budget.budget_period_id | html %]">
  178                     <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=[% budget.budget_id | uri %]&amp;budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-pencil"></i> Edit</a></li>
  179                     [% IF budget.budget_has_children %]
  180                         <li class="disabled"><a href="#" class="deletefund-disabled" data-toggle="tooltip" data-placement="left" title="This fund has children"><i class="fa fa-trash"></i> Delete</a></li>
  181                     [% ELSE %]
  182                         <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=[% budget.budget_id | uri %]&amp;budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-trash"></i> Delete</a></li>
  183                     [% END %]
  184                     <li><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_parent_id=[% budget.budget_id | uri %]&amp;budget_period_id=[% budget.budget_period_id | uri %]"><i class="fa fa-plus"></i> Add child fund</a></li>
  185                 </ul>
  186             </div>
  187         </td>
  188     [% END %]
  189     </tr>
  190     [% END %]
  191     </tbody>
  192 </table>
  193 
  194 [% ELSE %]
  195     <p>No fund found</p>
  196 [% END %]
  197 
  198 [% END %] <!-- list -->
  199 
  200 <!-- ********************************************************************************************** -->
  201 <!-- create add/mod entry form -->
  202 [% IF op == 'add_form' && !error_not_authorised_to_modify %]
  203 <form action="/cgi-bin/koha/admin/aqbudgets.pl" id="edit_fund" name="Aform" method="post">
  204     <fieldset class="rows">
  205     <legend>[% IF ( budget_id ) %]Modify[% ELSE %]Add[% END %] Fund
  206     [% IF ( budget_period_description ) %]
  207         [% budget_name | html %] for Budget '[% budget_period_description | html %]'
  208     [% END %]
  209     </legend>
  210 
  211     <input type="hidden" name="op" value="add_validate" />
  212     <input type="hidden" name="checked" value="0" />
  213     <ol>
  214     [% IF ( budget_parent_id ) %]
  215     <li>
  216         <span class="label">Fund parent: </span>
  217         [% budget_parent_name | html %]
  218         [% budget_parent_id | html %] - [% budget_parent_name | html %]
  219         <input type="hidden" name="budget_parent_id" value="[% budget_parent_id | html %]" />
  220     </li>
  221     [% END %]
  222     <li>
  223     <label class="required"  for="budget_code">Fund code: </label>
  224     <input type="text" name="budget_code" id="budget_code" value="[% budget_code | html %]" size="30" />
  225     </li>
  226 
  227     <li>
  228     <label class="required" for="budget_name">Fund name: </label>
  229     <input type="text" name="budget_name" id="budget_name" value="[% budget_name | html %]" size="60" />
  230     </li>
  231 
  232     <li>
  233     <label style="white-space: nowrap;" for="budget_amount" class="required">Amount: </label>
  234     <input type="text" name="budget_amount" id="budget_amount" value="[% budget_amount | $Price on_editing => 1 %]" size="8" />
  235     </li>
  236 
  237     <li>
  238       <label for="budget_encumb">Warning at (%): </label>
  239       <input type="text" name="budget_encumb" id="budget_encumb" value="[% budget_encumb | html %]" size="10" />
  240       <span class="hint">0 to disable</span>
  241     </li>
  242 
  243     <li>
  244       <label for="budget_expend">Warning at (amount): </label>
  245       <input type="text" name="budget_expend" id="budget_expend" value="[% budget_expend | $Price on_editing => 1 %]" size="10" />
  246       <span class="hint">0 to disable</span>
  247     </li>
  248 
  249     <li>
  250         <span class="label">Owner: </span>
  251         [% IF  budget_owner %]
  252             <span  id="budget_owner_name">
  253                 <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% budget_owner.borrowernumber | uri %]">
  254                     [% budget_owner.firstname | html %] [% budget_owner.surname | html %]
  255                 </a> |
  256             </span>
  257         [% ELSE %]
  258             <span  id="budget_owner_name"></span>
  259         [% END %]
  260         <a id="edit_owner" class="new_window" href="#"><i class="fa fa-search"></i> Select owner</a>
  261         <a id="remove_owner" href="#"><i class="fa fa-trash"></i> Remove owner</a>
  262         <input type="hidden" name="budget_owner_id" id="budget_owner_id"
  263             value="[% budget_owner.borrowernumber | html %]" />
  264     </li>
  265 
  266 
  267     [% IF budget_has_children %]
  268         <li class="radio">
  269             <label>
  270                 <input type="checkbox" id="set_owner_to_children" name="set_owner_to_children" value="1" />
  271                 Update all child funds with this owner
  272             </label>
  273             <span class="hint">Selecting this option will overwrite existing fund owners, if any</span>
  274         </li>
  275     [% END %]
  276 
  277     <li>
  278         <span class="label">Users:</span>
  279         <ul style="float:left;" id="budget_users">
  280             [% FOREACH user IN budget_users %]
  281                 <li id="user_[% user.borrowernumber | html %]">
  282                     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% user.borrowernumber | uri %]">
  283                         [% user.firstname | html %] [% user.surname | html %]
  284                     </a>
  285                     &bull; <a href="#" class="del_user" data-borrowernumber="[% user.borrowernumber | html %]"><i class="fa fa-trash"></i> Remove</a>
  286                 </li>
  287             [% END %]
  288             <li><a href="#" id="add_user_button"><i class="fa fa-plus"></i> Add users</a></li>
  289         </ul>
  290         <input type="hidden" name="budget_users_ids" id="budget_users_id" value="[% budget_users_ids | html %]" />
  291     </li>
  292     <li>
  293     <label for="budget_branchcode">Library: </label>
  294     <select name="budget_branchcode" id="budget_branchcode">
  295         <option value=""></option>
  296         [% PROCESS options_for_libraries libraries => Branches.all( selected => budget_branchcode, unfiltered => 1 ) %]
  297     </select>
  298     </li>
  299 
  300     <li>
  301     <label for="budget_permission">Restrict access to: </label>
  302     <select name="budget_permission" id="budget_permission">
  303         [% IF ( budget_perm_0 ) %]
  304             <option value="0" selected="selected">
  305         [% ELSE %]
  306             <option value="0">
  307         [% END %]
  308             None
  309         </option>
  310 
  311         [% IF ( budget_perm_1 ) %]
  312             <option value="1" selected="selected">
  313         [% ELSE %]
  314             <option value="1">
  315         [% END %]
  316             Owner
  317         </option>
  318 
  319         [% IF ( budget_perm_3) %]
  320             <option value="3" selected="selected">
  321         [% ELSE %]
  322             <option value="3">
  323         [% END %]
  324             Owner and users
  325         </option>
  326 
  327         [% IF ( budget_perm_2 ) %]
  328             <option value="2" selected="selected">
  329         [% ELSE %]
  330             <option value="2">
  331         [% END %]
  332             Owner, users and library
  333         </option>
  334     </select>
  335     </li>
  336 
  337     <li>
  338     <label for="budget_notes">Notes: </label>
  339     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6">[% budget_notes | html %]</textarea>
  340     </li>
  341 
  342     <li>
  343     <label  style="white-space: nowrap;" for="authorised_value_category1">Statistic 1 done on: </label>
  344         <select name="sort1_authcat" id="authorised_value_category1">
  345             <option value=""></option>
  346             [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort1_authcat ) %]
  347         </select>
  348     </li>
  349     <li>
  350     <label  style="white-space: nowrap;" for="authorised_value_category2">Statistic 2 done on: </label>
  351         <select name="sort2_authcat" id="authorised_value_category2">
  352             <option value=""></option>
  353             [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => sort2_authcat ) %]
  354         </select>
  355     </li>
  356     </ol>
  357 
  358     [% IF ( budget_id ) %]
  359         <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
  360     [% END %]
  361     </fieldset>
  362 
  363     <fieldset class="action">
  364         <input type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
  365         <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
  366     </fieldset>
  367 </form>
  368 
  369 [% END %] <!-- add_form -->
  370 
  371 [% IF op == 'delete_confirm' %]
  372     <div class="dialog alert">
  373         <h3>Delete fund [% budget_name | html %]?</h3>
  374         If you delete this fund, all orders linked to this fund will be deleted!
  375         <table>
  376             <tr>
  377             <th scope="row">Fund amount:</th>
  378             <td>[% budget_amount | $Price %]</td>
  379             </tr>
  380         </table>
  381 
  382         <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
  383             <input type="hidden" name="op" value="delete_confirmed" />
  384             <input type="hidden" name="budget_id" value="[% budget_id | html %]" />
  385             <input type="hidden" name="budget_period_id" value="[% budget_period_id | html %]" />
  386             <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this fund</button>
  387         </form>
  388         <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
  389             <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
  390         </form>
  391     </div>
  392 [% END %]
  393 
  394             </main>
  395         </div> <!-- /.col-sm-10.col-sm-push-2 -->
  396 
  397         <div class="col-sm-2 col-sm-pull-10">
  398             <aside>
  399 
  400 [% IF op == 'list' %]
  401   <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="get">
  402     <a href="#" id="filterbutton">Filters</a>
  403     <fieldset class="brief" id="fundfilters">
  404     <h4>Fund filters</h4>
  405         <ol>
  406         <li>
  407             <label for="filter_budgetbranch2">Library: </label>
  408             <select name="filter_budgetbranch" id="filter_budgetbranch2">
  409                 <option value=""></option>
  410                 [% PROCESS options_for_libraries libraries => Branches.all( selected => selected_branchcode, unfiltered => 1 ) %]
  411             </select>
  412         </li>
  413         <li class="radio">
  414 
  415         <label for="show_mine">Show my funds only:</label>
  416             [% IF ( show_mine ) %]
  417                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
  418             [% ELSE %]
  419                 <input type="checkbox" id="show_mine"  name="show_mine" value="1" />
  420         [% END %]
  421         </li>
  422 
  423         [% IF periods %]
  424           <li>
  425             <label for="periods">Budget:</label>
  426             <select id="periods" name="budget_period_id">
  427               <option value="">All budgets</option>
  428               [% FOR period IN periods %]
  429                 [% IF budget_period_id && period.budget_period_id == budget_period_id %]
  430                   <option value="[% period.budget_period_id | html %]" selected="selected">[% period.budget_period_description | html %]</option>
  431                 [% ELSE %]
  432                   <option value="[% period.budget_period_id | html %]">[% period.budget_period_description | html %]</option>
  433                 [% END %]
  434               [% END %]
  435             </select>
  436           </li>
  437         [% END %]
  438         </ol>
  439 
  440         <input type="hidden" name="op" value="list" />
  441         <input type="submit" class="submit" name="filter" value="Go" />
  442     </fieldset>
  443 </form>[% END %]
  444 
  445                 [% INCLUDE 'acquisitions-menu.inc' %]
  446             </aside>
  447         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
  448      </div> <!-- /.row -->
  449 
  450 [% MACRO jsinclude BLOCK %]
  451     [% Asset.js("js/acq.js") | $raw %]
  452     <script>
  453         var MSG_BUDGET_PARENT_ALLOCATION = "- " + _("Fund amount exceeds parent allocation") + "\n";
  454         var MSG_BUDGET_PERIOD_ALLOCATION = "- " + _("Fund amount exceeds period allocation") + "\n";
  455         var MSG_PARENT_BENEATH_BUDGET = "- " + _("New budget-parent is beneath budget") + "\n";
  456     </script>
  457 
  458     [% Asset.js("js/acq.js") | $raw %]
  459     [% IF op == 'add_form' %]
  460         <script>
  461         //<![CDATA[
  462 
  463             function userPopup() {
  464                 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=add",
  465                     'PatronPopup',
  466                     'width=740,height=450,location=yes,toolbar=no,'
  467                     + 'scrollbars=yes,resize=yes'
  468                 );
  469             }
  470 
  471             function ownerPopup() {
  472                 window.open("/cgi-bin/koha/admin/add_user_search.pl?selection_type=select",
  473                     'PatronPopup',
  474                     'width=740,height=450,location=yes,toolbar=no,'
  475                     + 'scrollbars=yes,resize=yes'
  476                 );
  477             }
  478 
  479             function select_user(borrowernumber, borrower) {
  480                 ownerRemove();
  481                 var borrowername = borrower.firstname + ' ' + borrower.surname;
  482                 if (borrowernumber) {
  483                     var ownerlink = '<a href="/cgi-bin/koha/members/moremember.pl'
  484                         + '?borrowernumber=' + borrowernumber + '">'
  485                         + borrowername + '</a>';
  486                     $('#budget_owner_name').html(ownerlink);
  487                     $('#budget_owner_id').val(borrowernumber);
  488                 }
  489             }
  490 
  491             function ownerRemove() {
  492                 $('#budget_owner_name').empty();
  493                 $('#budget_owner_id').val('');
  494             }
  495 
  496             function add_user(borrowernumber, borrowername) {
  497                 var ids = $("#budget_users_id").val().split(':');
  498                 if(borrowernumber && ids.indexOf(borrowernumber.toString()) == -1) {
  499                     var li = '<li id="user_' + borrowernumber + '">'
  500                         + '<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber='
  501                         + borrowernumber + '">' + borrowername + '</a> '
  502                         + ' &bull; <a data-borrowernumber=" + borrowernumber +" class="del_user" href="#"><i class="fa fa-trash"></i> '+_("Remove")+'</a> '
  503                         + '</li>';
  504                     $("#budget_users").prepend(li);
  505                     ids.push(borrowernumber);
  506                     $("#budget_users_id").val(ids.join(':'));
  507                 } else {
  508                     return -1;
  509                 }
  510                 return 0;
  511             }
  512 
  513             function del_user(borrowernumber) {
  514                 var ids = $("#budget_users_id").val().split(':');
  515                 if (borrowernumber) {
  516                     var idx = ids.indexOf(borrowernumber+'');
  517                     if (idx != -1) {
  518                         ids.splice(idx, 1);
  519                         $("#budget_users_id").val(ids.join(':'));
  520                         $("li#user_" + borrowernumber).remove();
  521                     }
  522                 }
  523             }
  524 
  525             function Check(f) {
  526                 var ok=1;
  527                 var _alertString="";
  528                 var alertString2;
  529 
  530                 if (!(isNotNull(f.budget_code,1))) {
  531                     _alertString += _("- Budget code cannot be blank") + "\n";
  532                 }
  533 
  534                 if (!(isNotNull(f.budget_name,1))) {
  535                     _alertString += _("- Budget name cannot be blank") + "\n";
  536                 }
  537 
  538                 if (!(isNotNull(f.budget_amount,1))) {
  539                     _alertString += _("- Budget amount cannot be blank") + "\n";
  540                 }
  541 
  542                 var budgetId;
  543                 if   (typeof(f.budget_id ) != "undefined")  {
  544                     budgetId = f.budget_id.value
  545                 }
  546 
  547                 var newBudgetParent;
  548 
  549         //  hack to test if selected parent_id in scrolling-list...
  550         //  if value == 'undef' its got a selected_parent :/
  551                 if(f.budget_parent_id){
  552                     var chkAdd   =  f.budget_parent_id.value ;
  553                     if  (     typeof(chkAdd ) != "undefined") {
  554                         newBudgetParent  =  f.budget_parent_id.value
  555                     } else {
  556                         newBudgetParent  =  f.budget_parent_id.item(0).value
  557                     }
  558 
  559                     if   (budgetId  > 0)  {  ; //its a mod ...
  560                         // if parent == curent-budget, fail...
  561                         if ( newBudgetParent  ==  budgetId     ) {
  562                                 _alertString += _("- Budget parent is current budget") + "\n";
  563                         }
  564 
  565                         else if (newBudgetParent) {
  566                             var result = checkBudgetParent(  budgetId , newBudgetParent   );
  567                             if (result) {
  568                                 _alertString += result;
  569                             }
  570                         }
  571                     }
  572                 }
  573 
  574                  // else do lookup
  575                 var budgetTotal = Math.abs(f.budget_amount.value);
  576                 var result =   budgetExceedsParent  (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
  577                 if (result) {
  578                     _alertString += result;
  579                 }
  580 
  581                 if (_alertString.length==0) {
  582                     document.Aform.submit();
  583                 } else {
  584                     alertString2 = _("Form not submitted because of the following problem(s)");
  585                     alertString2 += "\n------------------------------------------------------------------------------------\n\n";
  586                     alertString2 += _alertString;
  587                     alert(alertString2);
  588                 }
  589             }
  590             $(document).ready(function(){
  591                 $("#remove_owner").on("click",function(e){
  592                     e.preventDefault();
  593                     ownerRemove();
  594                 });
  595                 $("#edit_owner").on("click",function(e){
  596                     e.preventDefault();
  597                     ownerPopup();
  598                 });
  599                 $("body").on("click",".del_user",function(e){
  600                     e.preventDefault();
  601                     var borrowernumber = $(this).data("borrowernumber");
  602                     del_user(borrowernumber);
  603                 });
  604                 $("#add_user_button").on("click",function(e){
  605                     e.preventDefault();
  606                     userPopup();
  607                 });
  608                 $("#edit_fund").on("submit",function(e){
  609                     e.preventDefault();
  610                     Check(this);
  611                 });
  612             });
  613         //]]>
  614         </script>
  615     [% ELSIF op == 'list' %]
  616         [% INCLUDE 'datatables.inc' %]
  617         [% Asset.js("lib/jquery/plugins/treetable/jquery.treetable.js") | $raw %]
  618 
  619         <script>
  620         //<![CDATA[
  621             //
  622             $(document).ready(function() {
  623                 [% IF budgets %]
  624                     var oTable = $("#budgeth").dataTable($.extend(true, {}, dataTablesDefaults, {
  625                         "fnDrawCallback": function ( oSettings ) {
  626                             if ( oSettings.aiDisplay.length == 0 )
  627                             {
  628                                 return;
  629                             }
  630 
  631                             var nTrs = $('#budgeth tbody tr');
  632                             var iColspan = nTrs[0].getElementsByTagName('td').length;
  633                             var sLastGroup = "";
  634                             for ( var i=0 ; i<nTrs.length ; i++ )
  635                             {
  636                                 var iDisplayIndex = oSettings._iDisplayStart + i;
  637                                 var sGroup = oSettings.aoData[ oSettings.aiDisplay[iDisplayIndex] ]._aData[1];
  638                                 if ( sGroup != sLastGroup )
  639                                 {
  640                                     var nGroup = document.createElement( 'tr' );
  641                                     var nCell = document.createElement( 'td' );
  642                                     nCell.colSpan = iColspan;
  643                                     nCell.className = "group";
  644                                     nCell.innerHTML = sGroup;
  645                                     nGroup.appendChild( nCell );
  646                                     nTrs[i].parentNode.insertBefore( nGroup, nTrs[i] );
  647                                     sLastGroup = sGroup;
  648                                 }
  649                             }
  650                         },
  651                         "footerCallback": function ( row, data, start, end, display ) {
  652                             var api = this.api(), data;
  653                             footer_column_sum( api, [ 4, 6, 8, 10 ], 2 );
  654                         },
  655                         "aoColumnDefs": [
  656                             { "bVisible": false, "aTargets": [ 0, 1 ] },
  657                             { "bSortable": false, "aTargets": ["_all"] }
  658                         ],
  659                         'dom': '<"top pager"ilpf>tr<"bottom pager"ip>',
  660                         'bSort': true,
  661                         'aaSortingFixed': [[ 1, 'asc' ]],
  662                         'bPaginate': false,
  663                         "bAutoWidth": false
  664                     }));
  665 
  666                     $(oTable).treetable({
  667                         expandable: true
  668                     });
  669                     $(oTable).treetable('expandAll');
  670                     $("#expand_all").click(function(e){
  671                         e.preventDefault();
  672                         $(oTable).treetable('expandAll');
  673                     });
  674                     $("#collapse_all").click(function(e){
  675                         e.preventDefault();
  676                         $(oTable).treetable('collapseAll');
  677                     });
  678 
  679                     [% UNLESS budget_period_id %]
  680                       $("#hide_inactive").click(function(e){
  681                         e.preventDefault();
  682                         oTable.fnFilter( 1, 0 ); // Show only active=1
  683                       });
  684                       $("#show_inactive").click(function(e){
  685                         e.preventDefault();
  686                         oTable.fnFilter( '', 0 );
  687                       });
  688                       $("#hide_inactive").click();
  689                     [% END %]
  690                     oTable.fnAddFilters("filter", 750);
  691                 [% END %]
  692 
  693                 $("#filterbutton").click(function() {
  694                     $("#fundfilters").slideToggle(0);
  695                 });
  696 
  697                 $(".deletefund-disabled").tooltip().on("click", function(e){
  698                     e.preventDefault();
  699                     alert(_("This fund has children. It cannot be deleted."));
  700                 });
  701             });
  702         //]]>
  703         </script>
  704     [% END %]
  705 [% END %]
  706 [% INCLUDE 'intranet-bottom.inc' %]