Acq: several interface improvements
[working/Evergreen.git] / Open-ILS / src / templates / acq / common / add_to_po.tt2
1         <div dojoType="dijit.Dialog" jsId='addToPoDialog'>
2             <script type="dojo/connect" event="execute">
3                 var dia = this;
4                 var poId = addToPoInput.attr('value');
5                 if (!poId) return false;
6
7                 var liId = dia._get_li();
8                 console.log("adding li " + liId + " to PO " + poId);
9
10                 fieldmapper.standardRequest(
11                     ['open-ils.acq',
12                         'open-ils.acq.purchase_order.add_lineitem'],
13                     {   async: true,
14                         params: [openils.User.authtoken, poId, liId],
15                         oncomplete: function(r) {
16                             if ((r = openils.Util.readResponse(r))) {
17                                 if (r.success) {
18                                     location.href = oilsBasePath +
19                                         '/acq/po/view/' + poId;
20                                 } else {
21                                     if (r.error == 'bad-po-state') {
22                                         alert(localeStrings.ADD_LI_TO_PO_BAD_PO_STATE);
23                                     } else if (r.error == 'bad-li-state') {
24                                         alert(localeStrings.ADD_LI_TO_PO_BAD_LI_STATE);
25                                     }
26                                 }
27                             }
28                             dia.hide();
29                         }
30                     }
31                 );
32             </script>
33             <script type="dojo/connect" event="onShow">
34                 if (!window._already_addToPo_onShow) {
35                     var dia = this;
36                     openils.Util.registerEnterHandler(
37                         addToPoInput.domNode,
38                         function() { dia.execute(); }
39                     );
40                     window._already_addToPo_onShow = true;
41                 }
42             </script>
43             <table class='dijitTooltipTable'>
44                 <tr>
45                     <td><label>[% l('Enter the PO Name: ') %]</label></td>
46                     <td>
47                         <input jsId="addToPoInput" dojoType="openils.widget.PCrudAutocompleteBox" fmclass="acqpo" searchAttr="name" name="target_po" />
48
49                         </td>
50                 </tr>
51                 <tr>
52                     <td colspan='2' align='center'>
53                         <span dojoType='dijit.form.Button' type="submit">[% l('Save') %]</span>
54                     </td>
55                 </tr>
56             </table>
57         </div>