BUGFIX new_acq (Javascript error under certain circumstances)
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / aqbudgets.tmpl
1 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
2 <!-- TMPL_INCLUDE NAME="calendar.inc" -->
3 <script type="text/javascript" src="<!-- TMPL_VAR NAME='themelang' -->/js/acq.js"></script>
4
5 <!-- TMPL_IF name="add_form" -->
6 <script type="text/javascript">
7 //<![CDATA[
8         //
9         var actTotal ="";
10
11         function ownerRemove(f) {
12         document.getElementById('budget_owner_name').innerHTML = '';
13     }
14
15         function Check(f) {
16                 var ok=1;
17                 var _alertString="";
18                 var alertString2;
19
20         // var actTotal ="";
21
22             if (!(isNotNull(f.budget_code,1))) {
23                         _alertString += _("- Budget code missing\n");
24                 }
25
26             if (!(isNotNull(f.budget_name,1))) {
27                         _alertString += _("- Budget name missing\n");
28                 }
29
30                 if( ! (isNum(f.budget_amount,0))     && ! (isNum(f.budget_amount_sublevel,0)  ) )  {
31                         _alertString += _("- Budget base-level and sub-level amount missing or invalid\n");
32                 }
33
34         var budgetId;
35         if   (typeof(f.budget_id ) != "undefined")  {
36             budgetId = f.budget_id.value
37         }
38
39         var newBudgetParent;
40
41 //  hack to test if selected parent_id in scrolling-list...
42 //  if value == 'undef' its got a selected_parent :/
43         var chkAdd   =  f.budget_parent_id.value ;
44         if  (     typeof(chkAdd ) != "undefined") {
45             newBudgetParent  =  f.budget_parent_id.value
46         } else {
47             newBudgetParent  =  f.budget_parent_id.item(0).value
48         }
49
50         if   (budgetId  > 0)  {  ; //its a mod ...
51             // if parent eq curent-budget, fail...
52             if ( newBudgetParent  ==  budgetId     ) {
53                             _alertString += _("- Budget parent is current budget\n");
54             }
55
56             else if (newBudgetParent) {
57                 var result = checkBudgetParent(  budgetId , newBudgetParent   );
58                 if (result) {
59                             _alertString += result;
60                 }
61             }
62         }
63
64          // else do lookup
65         var budgetTotal = Math.abs(f.budget_amount.value)  + Math.abs(f.budget_amount_sublevel.value);
66         var result =   budgetExceedsParent  (budgetTotal, budgetId, newBudgetParent, f.budget_period_id.value)
67         if (result) {
68             _alertString += result;
69         }
70
71                 if (_alertString.length==0) {
72                         document.Aform.submit();
73                 } else {
74                         alertString2 = _("Form not submitted because of the following problem(s)\n");
75                         alertString2 += "------------------------------------------------------------------------------------\n\n";
76                         alertString2 += _alertString;
77                         alert(alertString2);
78                 }
79         }
80 //]]>
81 </script>
82 <!-- /TMPL_IF -->
83
84 </head>
85 <body>
86 <!-- TMPL_INCLUDE NAME="header.inc" -->
87 <!-- TMPL_INCLUDE NAME="budgets-admin-search.inc" -->
88
89 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; 
90     <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <!-- TMPL_IF NAME="else" -->Budgets<!-- /TMPL_IF --><!-- TMPL_IF name="add_form" -->
91     <a href="/cgi-bin/koha/admin/aqbudgets.pl">Budgets</a> &rsaquo; <!-- TMPL_IF NAME="budget_id" -->Modify<!-- TMPL_ELSE -->Add<!-- /TMPL_IF --> Budget<!-- /TMPL_IF -->  <!-- TMPL_IF name="delete_confirm" -->
92     <a href="/cgi-bin/koha/admin/aqbudgets.pl">Budgets</a> &rsaquo; Delete Budget?<!-- /TMPL_IF --></div>
93
94 <div id="doc3" class="yui-t2">
95 <div id="bd">
96 <div id="yui-main">
97 <div class="yui-b">
98
99 <!-- TMPL_INCLUDE NAME="budgets-admin.inc" -->
100 <!-- TMPL_IF name="else" -->
101
102 <h1>Budgets for '<!-- TMPL_VAR name="budget_period_description" -->'</h1>
103 <input type="hidden" name"budget_period_id" value="<!-- TMPL_VAR name=    'budget_period_id' -->" />
104 <form action="/cgi-bin/koha/admin/aqbudgets.pl" method="post">
105     <fieldset>
106     <legend>Budget options</legend>
107     <li><label for="budget_period_dropbox">Select Budget Period:</label>
108         <!-- TMPL_VAR name="budget_period_dropbox" -->
109         <input type="hidden" value="<!-- TMPL_VAR name='budget_period_id' -->" />
110     </li>
111     <li>
112         <label for="budget_branchcode_dropbox">Limit to Branch:</label>
113         <select name="budget_branchcode"  >
114             <option value=""></option>
115             <!-- TMPL_LOOP name="branchloop" -->
116             <option value="<!-- TMPL_VAR name="value" -->" <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF -->><!-- TMPL_VAR name="branchname" --></option>
117             <!-- /TMPL_LOOP -->
118         </select>
119     
120         <input type="hidden" value="<!-- TMPL_VAR name='budget_period_id' -->" />
121     <li>
122         <!-- TMPL_IF NAME="show_mine" -->
123             <input type="checkbox" id="show_mine"  name="show_mine" value="1" checked="checked" />
124         <!-- TMPL_ELSE -->  
125             <input type="checkbox" id="show_mine"  name="show_mine" value="1"  />
126         <!-- /TMPL_IF -->  
127         <label for="show_mine">Show my budgets only</label>
128     </li>
129     <input type="hidden" name="show" value="1"  -->
130     <input type="submit" value="Select" />
131 </fieldset>
132 </form>
133
134 <table>
135     <tr>
136     <th>Budget hierarchy</th>
137     <th>Budget name</th>
138     <th>Total<br>allocated</th>
139     <th>Base-level<br>allocated</th>
140     <th>Sub-level<br>allocated (unallocated)</th>
141     <th>Base-level<br>spent</th>
142     <th>Base-level<br>remaining</th>
143     <!--
144     <th>Sub-level<br>spent</th>
145     <th>Encum%</th>
146     <th>Expend%</th>
147     -->
148     <th>Owner</th>
149     <th>Branch</th>
150     <th>Note</th>
151     <th colspan="3">Actions</th>
152     </tr>
153
154 <!-- TMPL_LOOP name="budget" -->
155     <!-- TMPL_IF NAME="toggle" -->
156     <tr class="highlight">
157     <!-- TMPL_ELSE -->
158     <tr>
159     <!-- /TMPL_IF -->
160
161     <td><!-- TMPL_VAR NAME="budget_code_indent" --></td>
162     <td><!-- TMPL_VAR NAME="budget_name" --></td>
163     <td align='right'><!-- TMPL_VAR NAME="budget_amount_total" --></td>
164     <td align='right'><!-- TMPL_VAR NAME="budget_amount" --> </td>
165     <!-- TMPL_IF NAME="budget_amount_sublevel" -->
166         <td align='center'><!-- TMPL_VAR NAME="budget_amount_sublevel" -->
167     <!-- TMPL_IF NAME="budget_unalloc_sublevel" -->
168         (<span  STYLE="color: green;" > <!-- TMPL_VAR NAME="budget_unalloc_sublevel" --></span>)
169     <!-- /TMPL_IF -->
170     </td>
171     <!-- TMPL_ELSE -->
172         <td align='center'>--</td>
173     <!-- /TMPL_IF -->
174
175     <td align='right'><!-- TMPL_VAR NAME="budget_spent" --> </td>
176     <td align='right'
177     <!-- TMPL_IF NAME="remaining_pos" --> STYLE="color: green;" <!-- /TMPL_IF -->
178     <!-- TMPL_IF NAME="remaining_neg" --> STYLE="color: red;" <!-- /TMPL_IF -->   >
179     <!-- TMPL_VAR NAME="budget_remaining" --> </td>
180
181     <!--
182     <td><!-- TMPL_VAR NAME="budget_encumb" --></td>
183     <td><!-- TMPL_VAR NAME="budget_expend" --></td>
184     -->
185     <td>    <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="budget_owner_id" -->"><!-- TMPL_VAR NAME="budget_owner_name" --></a></td>
186
187     <td><!-- TMPL_VAR NAME="budget_branchcode" --></td>
188     <td><!-- TMPL_VAR NAME="budget_notes" --></td>
189     <!-- TMPL_IF NAME='budget_lock'-->
190         <td> <span STYLE="color: gray;" > Edit Delete </span> </td>
191     <!-- TMPL_ELSE -->
192         <td><a href="/cgi-bin/koha/admin/aqbudgets.pl?op=add_form&amp;budget_id=<!-- TMPL_VAR NAME="budget_id" -->&amp;budget_period_id=<!-- TMPL_VAR NAME="budget_period_id" -->" >Edit</a>
193         <a href="/cgi-bin/koha/admin/aqbudgets.pl?op=delete_confirm&amp;budget_id=<!-- TMPL_VAR NAME="budget_id" -->">Delete       </a></td>
194     <!-- /TMPL_IF -->
195     </tr>
196 <!-- /TMPL_LOOP -->
197
198     <tfoot>
199     <tr>
200     <th colspan='2' style='text-align: left;' nowrap>Period allocated <!-- TMPL_VAR NAME='budget_period_total'-->  </th>
201     <th nowrap style='text-align: right;' > <!-- TMPL_VAR NAME='period_alloc_total'--></th>
202     <th nowrap  style='text-align: right;'> <!-- TMPL_VAR NAME='base_alloc_total'--></th>
203     <th nowrap  style='text-align: center;'> <!-- TMPL_VAR NAME='sub_alloc_total'--></th>
204     <th style='text-align: right;' ><!-- TMPL_VAR NAME='base_spent_total'--></th>
205     <th style='text-align: right;' ><!-- TMPL_VAR NAME='base_remaining_total'--></th>
206     <th></th>
207     <th></th>
208     <th></th>
209     <th></th>
210     </tr>
211     </tfoot>
212 </table>
213
214 <span><b>Currency = <!-- TMPL_VAR NAME="cur" --> <!-- TMPL_VAR NAME="cur_format" --></b></span><br>
215 <div class="paginationBar"><!-- TMPL_VAR NAME="pagination_bar" --></div>
216 <!-- /TMPL_IF --> <!-- else -->
217
218 <!-- ********************************************************************************************** -->
219 <!-- create add/mod entry form -->
220 <!-- TMPL_IF name="add_form" -->
221
222 <form action="/cgi-bin/koha/admin/aqbudgets.pl" name="Aform" method="post">
223     <fieldset class="rows">
224     <legend><!-- TMPL_IF NAME="budget_id" -->Modify<!-- TMPL_ELSE -->Add<!-- /TMPL_IF --> Budget
225     <!-- TMPL_IF NAME="budget_period_description" -->
226         <!-- TMPL_VAR NAME="budget_name" --> for period <!-- TMPL_VAR NAME="budget_period_description" -->
227     <!-- /TMPL_IF -->
228     </legend>
229
230     <input type="hidden" name="op" value="add_validate" />
231     <input type="hidden" name="checked" value="0" />
232     <ol>
233     <li>
234     <label for="parents">Budget Parent: </label>
235     <!-- TMPL_VAR NAME="budget_parent_dropbox" -->
236
237     <input type="hidden" name="budget_parent_id" value="<!-- TMPL_VAR NAME="budget_parent_id" -->" />
238     </li>
239
240     <li>
241     <label style="color: red;"  for="budget_code">Budget Code: </label>
242     <input type="text" name="budget_code" id="budget_code" value="<!-- TMPL_VAR NAME="budget_code" -->" size="30" />
243     </li>
244
245     <li>
246     <label style="color: red;" for="budget_name">Budget Name: </label>
247     <input type="text" name="budget_name" id="budget_name" value="<!-- TMPL_VAR NAME="budget_name" -->" size="60" />
248     </li>
249
250     <div class='hint'>base-level and sub-level amount fields cannot both be empty</div>
251     <li>
252     <label style='white-space: nowrap;' for="budget_amount">Base-level amount: </label>
253     <input type="text" name="budget_amount" id="budget_amount" value="<!-- TMPL_VAR NAME="budget_amount" -->" size="8" />
254     </li>
255
256     <li>
257     <label for="budget_amount_sublevel">Sub-level amount: </label>
258     <input type="text" name="budget_amount_sublevel" id="budget_amount_sublevel" value="<!-- TMPL_VAR NAME="budget_amount_sublevel" -->" size="8" />
259     </li>
260
261     <li>
262     <label for="">Encumberance: </label>
263     <input type="text" name="budget_encumb" id="budget_encumb" value="<!-- TMPL_VAR NAME="budget_encumb" -->" size="8" />
264     </li>
265
266     <li>
267     <label for="">Expenditure: </label>
268     <input type="text" name="budget_expend" id="budget_expend" value="<!-- TMPL_VAR NAME="budget_expend" -->" size="8" />
269     </li>
270
271     <input type="hidden" name="budget_owner_id" id="budget_owner_id" value='<!-- TMPL_VAR NAME="budget_owner_id" -->' />
272     <li>
273     <label for="parents">Owner: </label>
274     <span  id="budget_owner_name">
275     <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="budget_owner_id" -->"><!-- TMPL_VAR NAME="budget_owner_name" --></a>
276     </span>
277
278     <!-- FIXME: hardcoded button positions :/ -->
279     <input style="position:absolute; left:600px;" type="button" id="patron_search" value="Edit owner" onclick="ownerPopup(); return false;" />
280     <input style="position:absolute; left:680px;"  type="button" id="patron_search" value="Remove owner" onclick="ownerRemove(this.form); return false;" />
281     </li>
282     </td>
283     </tr>
284     </table>
285
286     <li>
287     <label for="branch">Library: </label>
288     <select name="budget_branchcode">
289     <option value=""></option>
290     <!-- TMPL_LOOP name="branchloop_select" -->
291         <option value="<!-- TMPL_VAR name="value" -->"
292         <!-- TMPL_IF name="selected" -->selected<!-- /TMPL_IF --> >
293         <!-- TMPL_VAR name="branchname" --></option>
294     <!-- /TMPL_LOOP -->
295     </select>
296     </li>
297
298     <li>
299     <label for="branch">Restrict access to: </label>
300     <!-- TMPL_VAR name="budget_perm_dropbox" -->
301     </li>
302
303     <li>
304     <label for="">Notes: </label>
305     <textarea name="budget_notes" id="budget_notes"  cols="80" rows="6" ><!-- TMPL_VAR NAME='budget_notes' --></textarea>
306     </li>
307
308     <li>
309     <label  style='white-space: nowrap;' for="parents">Planning Category1: </label>
310     <!-- TMPL_VAR NAME="sort1_authcat_dropbox" -->
311     </li>
312     <li>
313     <label  style='white-space: nowrap;' for="parents">Planning Category2: </label>
314     <!-- TMPL_VAR NAME="sort2_authcat_dropbox" -->
315     </li>
316     </ol>
317
318     <!-- TMPL_IF NAME="budget_id" -->
319         <input type="hidden" name="budget_id" value="<!-- TMPL_VAR NAME='budget_id' -->" />
320     <!-- /TMPL_IF -->
321     </fieldset>
322
323     <fieldset class="action">
324         <input type="button" value="Submit" onclick="Check(this.form)" /> <a class="cancel" href="/cgi-bin/koha/admin/aqbudgets.pl">Cancel</a>
325         <input type="hidden" name="budget_period_id" value="<!-- TMPL_VAR name='budget_period_id' -->" />
326     </fieldset>
327 </form>
328
329 <!-- /TMPL_IF --> <!-- add_form -->
330
331 <!-- TMPL_IF name="delete_confirm" -->
332 <div class="dialog alert"> <h3>Delete Budget <!-- TMPL_VAR NAME="budget_name" -->?</h3>
333 <table>
334     <<tr>
335     <th scope="row">Budget Amount:</td>
336     <td><!-- TMPL_VAR NAME="budget_amount" --></td>
337     </tr>
338 </table>
339
340 <form action="<!-- TMPL_VAR NAME="action" -->" method="post">
341     <input type="hidden" name="op" value="delete_confirmed" />
342     <input type="hidden" name="budget_id" value="<!-- TMPL_VAR NAME="budget_id" -->" />
343     <input type="submit" value="Delete this budget" class="approve" />
344 </form>
345
346 <form action="<!-- TMPL_VAR NAME="action" -->" method="get">
347     <input type="submit" class="deny" value="No, Do Not Delete" />
348 </form>
349 </div>
350 <!-- /TMPL_IF -->
351
352 </div>
353 </div>
354 <div class="yui-b">
355     <!-- TMPL_INCLUDE NAME="admin-menu.inc" -->
356 </div>
357 </div>
358 <!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->