mysql/core_notify_trigger_after_update.sql
[Pman.Core] / Pman.Dialog.Image.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.Image = {
8
9  _strings : {
10   'eb5d45750c7ab13aa8e6bacc80315a30' :"32M",
11   '2859a4ae58ae4e25abdfc530f814e42f' :"Upload an Image or File",
12   'c4ca4238a0b923820dcc509a6f75849b' :"1",
13   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
14   '91412465ea9169dfd901dd5e7c96dd99' :"Upload",
15   'ea72bacd2fdfa818907bb9559e6905a1' :"Upload Image or File"
16  },
17
18  dialog : false,
19  callback:  false,
20
21  show : function(data, cb)
22  {
23   if (!this.dialog) {
24    this.create();
25   }
26
27   this.callback = cb;
28   this.data = data;
29   this.dialog.show(this.data._el);
30   if (this.form) {
31    this.form.reset();
32    this.form.setValues(data);
33    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
34   }
35
36  },
37
38  create : function()
39  {
40    var _this = this;
41    this.dialog = Roo.factory({
42     xtype : 'LayoutDialog',
43     closable : false,
44     collapsible : false,
45     haveProgress : false,
46     height : 140,
47     modal : true,
48     resizable : false,
49     shadow : true,
50     title : _this._strings['2859a4ae58ae4e25abdfc530f814e42f'] /* Upload an Image or File */,
51     uploadComplete : false,
52     uploadProgress : function()
53     {
54         var dlg = this;
55        if (!dlg.haveProgress) {
56             Roo.MessageBox.progress("Uploading", "Uploading");
57         }
58         
59         if (dlg.haveProgress == 2) {
60             // it's been closed elsewhere..
61             return;
62         }
63         if (dlg.uploadComplete) {
64             Roo.MessageBox.hide();
65             return;
66         }
67         
68         dlg.haveProgress = 1;
69     
70         var uid = _this.form.findField('UPLOAD_IDENTIFIER').getValue();
71         new Pman.Request({
72             url : baseURL + '/Core/UploadProgress.php',
73             params: {
74                 id : uid
75             },
76             method: 'GET',
77             success : function(res){
78                 //console.log(data);
79                 var data = res.data;
80                 if (dlg.haveProgress == 2) {
81                     // it's been closed elsewhere..
82                     return;
83                 }
84                 
85                 if (dlg.uploadComplete) {
86                     Roo.MessageBox.hide();
87                     return;
88                 }
89                     
90                 if (data){
91                     Roo.MessageBox.updateProgress(data.bytes_uploaded/data.bytes_total,
92                         Math.floor((data.bytes_total - data.bytes_uploaded)/1000) + 'k remaining'
93                     );
94                 } else {
95                     Roo.MessageBox.updateProgress(1,
96                         "Upload Complete - processing"
97                     );
98                     return;
99                 }
100                 dlg.uploadProgress.defer(2000,dlg);
101             },
102             failure: function(data) {
103               //  console.log('fail');
104              //   console.log(data);
105             }
106         })
107         
108     },
109     width : 500,
110     listeners : {
111      show : function (_self)
112       {
113       
114           // this does not really work - escape on the borders works..
115           // resize to fit.. if we have styled stuff...
116           
117           
118           
119           
120           var d = this;
121           
122           var pad =     d.el.getSize().height - (d.header.getSize().height +
123               d.footer.getSize().height +        
124               d.layout.getRegion('center').getPanel(0).el.getSize().height
125               );
126           
127           var height = (
128               pad + 
129               d.header.getSize().height +
130               d.footer.getSize().height +        
131               d.layout.getRegion('center').getPanel(0).el.child('div').getSize().height
132           );
133           this.resizeTo(d.el.getSize().width, height);
134           
135           if (this.keylistener) {
136               return;
137           }
138           this.keylistener = this.addKeyListener(27, this.hide, this);
139           
140       }
141     },
142     xns : Roo,
143     '|xns' : 'Roo',
144     center : {
145      xtype : 'LayoutRegion',
146      xns : Roo,
147      '|xns' : 'Roo'
148     },
149     buttons : [
150      {
151       xtype : 'Button',
152       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
153       listeners : {
154        click : function (_self, e)
155         {
156             _this.dialog.hide();
157         }
158       },
159       xns : Roo,
160       '|xns' : 'Roo'
161      },
162      {
163       xtype : 'Button',
164       text : _this._strings['91412465ea9169dfd901dd5e7c96dd99'] /* Upload */,
165       listeners : {
166        click : function (_self, e)
167         {
168             // do some checks?
169              
170             //_this.dialog.el.mask("Sending");
171             _this.dialog.uploadComplete = false;
172             _this.form.doAction('submit', {
173                 params: {
174                     ts : Math.random()
175                 } 
176             });
177             _this.dialog.haveProgress = 0; // set to show..
178             _this.dialog.uploadProgress.defer(1000, _this.dialog);
179         
180         }
181       },
182       xns : Roo,
183       '|xns' : 'Roo'
184      }
185     ],
186     items  : [
187      {
188       xtype : 'ContentPanel',
189       fitToFrame : true,
190       region : 'center',
191       xns : Roo,
192       '|xns' : 'Roo',
193       items  : [
194        {
195         xtype : 'Form',
196         fileUpload : true,
197         labelWidth : 140,
198         method : 'POST',
199         style : 'margin:10px;',
200         timeout : 300,
201         url : baseURL + '/Roo/Images.php',
202         listeners : {
203          actioncomplete : function(_self,act)
204           {
205               _this.dialog.uploadComplete = true;
206               _this.dialog.haveProgress = 2; 
207               Roo.MessageBox.hide(); // force hiding
208               //_this.dialog.el.unmask();
209                
210               if (act.type == 'setdata') { 
211                   this.url = _this.data._url ? _this.data._url : baseURL + '/Roo/Images.php';
212                   this.el.dom.action = this.url;
213                   if (typeof(_this.data.timeout) != 'undefined') {
214                       this.timeout = _this.data.timeout;
215                   }
216                   
217                   this.findField('UPLOAD_IDENTIFIER').setValue(
218                       (new Date() * 1) + '' + Math.random());
219                       
220                   return;
221               }
222                
223              
224               if (act.type == 'load') {
225                 // should this happen?  
226                   _this.data = act.result.data;
227                  // _this.loaded();
228                   return;
229               }
230               
231               
232               if (act.type == 'submit') { // only submitted here if we are 
233                   _this.dialog.hide();
234                   Roo.log("Upload success");
235                   Roo.log(act);
236                   //console.log(act);
237                   if (_this.callback) {
238                       _this.callback.call(this, act.result.data, act.result.extra);
239                   }
240                   return; 
241               }
242               
243           
244               
245           },
246          actionfailed : function (_self, act)
247           {
248              
249              
250               _this.dialog.uploadComplete = true;
251              // _this.dialog.el.unmask();
252               // error msg???
253                _this.dialog.haveProgress = 2; 
254               if (act.type == 'submit') {
255                   Roo.log("Upload error");
256                   Roo.log(act);
257                   
258                   try {
259                       Roo.MessageBox.alert("Error", act.result.errorMsg.split(/\n/).join('<BR/>'));
260                   } catch(e) {
261                     //  Roo.log(e);
262                       Roo.MessageBox.alert("Error", "Saving failed = fix errors and try again");        
263                   }
264                   return;
265               }
266               
267               // what about load failing..
268               Roo.MessageBox.alert("Error", "Error loading details"); 
269           },
270          rendered : function (form)
271           {
272               _this.form= form;
273           }
274         },
275         xns : Roo.form,
276         '|xns' : 'Roo.form',
277         items  : [
278          {
279           xtype : 'Hidden',
280           name : 'UPLOAD_IDENTIFIER',
281           xns : Roo.form,
282           '|xns' : 'Roo.form'
283          },
284          {
285           xtype : 'Hidden',
286           name : 'post_max_size',
287           value : _this._strings['eb5d45750c7ab13aa8e6bacc80315a30'] /* 32M */,
288           xns : Roo.form,
289           '|xns' : 'Roo.form'
290          },
291          {
292           xtype : 'Hidden',
293           name : 'upload_max_filesize',
294           value : _this._strings['eb5d45750c7ab13aa8e6bacc80315a30'] /* 32M */,
295           xns : Roo.form,
296           '|xns' : 'Roo.form'
297          },
298          {
299           xtype : 'TextField',
300           fieldLabel : _this._strings['ea72bacd2fdfa818907bb9559e6905a1'] /* Upload Image or File */,
301           inputType : 'file',
302           name : 'imageUpload',
303           width : 200,
304           xns : Roo.form,
305           '|xns' : 'Roo.form'
306          },
307          {
308           xtype : 'Hidden',
309           name : 'ontable',
310           xns : Roo.form,
311           '|xns' : 'Roo.form'
312          },
313          {
314           xtype : 'Hidden',
315           name : 'onid',
316           xns : Roo.form,
317           '|xns' : 'Roo.form'
318          },
319          {
320           xtype : 'Hidden',
321           name : 'id',
322           xns : Roo.form,
323           '|xns' : 'Roo.form'
324          },
325          {
326           xtype : 'Hidden',
327           value : 1,
328           xns : Roo.form,
329           '|xns' : 'Roo.form'
330          },
331          {
332           xtype : 'Hidden',
333           name : 'imgtype',
334           xns : Roo.form,
335           '|xns' : 'Roo.form'
336          }
337         ]
338        }
339       ]
340      }
341     ]
342    });
343  }
344 };