Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.js
index 1cf9e21..54086ad 100644 (file)
@@ -92,17 +92,23 @@ Pman.Dialog.CoreNotifyRecur = {
                             listeners : {
                                 update : function (_self, record, operation)
                                 {
-                                    Roo.log(operation);
+                                    //Roo.log(operation);
                                     if (operation != 'commit') {
                                         return;
                                     }
+                                    var p = Roo.apply({}, record.data);
+                                    p.dtstart = record.data.dtstart.format('Y-m-d');
+                                    p.dtend = record.data.dtend.format('Y-m-d');    
+                                    
+                                    
                                     new Pman.Request({
                                         url : baseURL + '/Roo/Core_notify_recur',
                                         method :'POST',
-                                        params : record.data,
-                                        success : function()
+                                        params : p,
+                                        success : function(data)
                                         {
-                                            //??
+                                            //Roo.log(data);
+                                            record.set('id', data.data.id);
                                         },
                                         failure : function() {
                                             Roo.MessageBox.alert("Error", "There was a problem saving");
@@ -205,7 +211,7 @@ Pman.Dialog.CoreNotifyRecur = {
                                             var r = grid.getDataSource().reader.newRow({
                                             // defaults..
                                                 person_id : _this.data.person_id,
-                                                dtstart : new Date(0),
+                                                dtstart : new Date(),
                                                 dtend : Date.parseDate('2050-01-01', 'Y-m-d'),
                                                 tz : 'Asia/Hong Kong',
                                                 onid : _this.data.onid,
@@ -236,15 +242,35 @@ Pman.Dialog.CoreNotifyRecur = {
                                 {
                                     xtype: 'Button',
                                     xns: Roo.Toolbar,
-                                    text : "Delete",
-                                    cls : 'x-btn-text-icon',
-                                    icon : rootURL + '/Pman/templates/images/trash.gif',
                                     listeners : {
                                         click : function()
                                         {
-                                             Pman.genericDelete(_this, 'core_notify_recur'); 
+                                             _this.grid.stopEditing();
+                                             var s = _this.grid.selModel.getSelectedCell()
+                                             if (!s) {
+                                                Roo.MessageBox.alert("Error", "Select row");
+                                                return;
+                                            }
+                                            
+                                            new Pman.Request({
+                                                url : baseURL + '/Roo/core_notify_recur',
+                                                method : 'POST',
+                                                params : {
+                                                    _delete : _this.grid.ds.getAt(s[0]).data.id,
+                                                }, 
+                                                success : function() {
+                                                    _this.grid.ds.load({});
+                                                },
+                                                failure : function() {
+                                                    Roo.MessageBox.alert("Error", "Deleting failed - try reloading");
+                                                }
+                                           });
+                                            
                                         }
-                                    }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Delete",
+                                    icon : rootURL + '/Pman/templates/images/trash.gif'
                                 }
                             ]
                         },
@@ -437,12 +463,10 @@ Pman.Dialog.CoreNotifyRecur = {
                                         xtype: 'ComboBox',
                                         xns: Roo.form,
                                         allowBlank : 'false',
-                                        displayField : 'tz',
                                         editable : true,
                                         emptyText : "Select timezone",
                                         fieldLabel : 'core_enum',
                                         forceSelection : true,
-                                        hiddenName : 'tz',
                                         listWidth : 400,
                                         loadingText : "Searching...",
                                         minChars : 2,