1 //<script type="text/javascript">
4 Pman.Dialog.Companies = new Roo.util.Observable({
6 show : function (data, callback)
8 Pman.Dialog.CoreCompanies.show({id:data.id});
12 //<script type="text/javascript">
15 Pman.Dialog.Companies = new Roo.util.Observable({
17 'beforerender' : true, // trigger so we can add modules later..
18 'show' : true, // trigger on showing form.. - to load additiona data..
21 show : function (data, callback)
23 Pman.Dialog.CoreCompanies.show({id:data.id});
35 this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}), {
37 title: "Edit Companies",
51 // tabPosition: 'top',
57 this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
58 this.dialog.addButton("Cancel", this.dialog.hide, this.dialog);
60 this.dialog.addButton("Save", this.save, this);
61 this.layout = this.dialog.getLayout();
62 this.layout.beginUpdate();
66 this.form = new Ext.form.Form({
71 actionfailed : function(f, act) {
72 _this.dialog.el.unmask();
74 Pman.standardActionFailed(f,act);
77 actioncomplete: function(f, act) {
78 _this.dialog.el.unmask();
79 //console.log('load completed');
80 // error messages?????
83 if (act.type == 'load') {
85 _this.data = act.result.data;
86 var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
89 if (_this.form.findField('comptype')) {
90 _this.form.findField('comptype')[meth]();
98 if (act.type == 'submit') { // only submitted here if we are
101 if (_this.callback) {
102 _this.callback.call(this, act.result.data);
114 //?? will this work...
116 this.form.addxtype.apply(this.form, this.getFormFields());
117 this.fireEvent('beforeRender', this );
119 var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
120 ef.dom.style.margin = 10;
122 this.form.render(ef.dom);
124 var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
126 //title: 'Org Details',
136 this.layout.endUpdate();
138 show : function (data, callback)
140 this.callback = callback;
141 this._id = data.id ? data.id : 0; // modify if you do not use ID !!!!
147 this.dialog.el.mask("Loading");
148 this.form.doAction('load', {
149 url: baseURL + '/Roo/Companies.html',
156 this.fireEvent('show');
159 this.form.setValues(data);
166 if (data.isOwner || !Pman.Login.isOwner()) {
167 this.dialog.setTitle("Your Company Details");
168 if (this.form.findField('comptype')) {
169 this.form.findField('comptype').disable();
176 this.dialog.setTitle(data.id ? "Edit Company" : "Add Company");
177 if (this.form.findField('comptype')) {
178 this.form.findField('comptype').enable();
181 this.fireEvent('show');
188 this.form.fileUpload = this.form.findField('imageUpload') ? true : false;
189 this.fireEvent('beforesave');
190 this.form.doAction('submit', {
191 url: baseURL + '/Roo/Companies.html',
200 comptypeList : function()
202 // should probably be system configurable..
205 [ 'CONSULTANT', "Consultant" ],
206 [ 'CLIENT' , "Client" ],
207 [ 'CONTRACTOR' , "Contractor" ]
208 // [ 'OWNER', "System Owner" ]
211 comptypeListToString: function(v) {
216 return "System Owner";
218 var a = this.comptypeList();
220 Roo.each(a, function( ar) {
232 getFormFields : function() {
239 this.c_comptype_name(),
255 this.c_background_color(),
257 //this.c_image_view(),
258 //this.c_image_change(),
267 c_code : function() {
270 fieldLabel : "Company ID (for filing Ref.)",
278 c_comptype_name : function() {
282 disabled : Pman.Login.isOwner() ? false : true,
283 name : 'comptype_name',
286 qtip : 'Select Company type',
295 xtype : 'SimpleStore',
296 fields: ['val', 'desc'],
297 data : this.comptypeList()
301 hiddenName : 'comptype',
306 triggerAction: 'all',
307 emptyText: "Select Type",
313 c_name : function() {
317 fieldLabel : "Company Name",
320 qtip : "Enter Company Name",
329 fieldLabel : "Phone",
332 qtip : "Enter Phone Number",
344 qtip : "Enter fax Number",
349 c_email : function() {
353 fieldLabel : "Email",
356 qtip : "Enter Email Address",
361 c_address : function() {
365 fieldLabel : "Address",
368 qtip : "Enter Address",
374 c_remarks : function() {
378 fieldLabel : "Remarks",
381 qtip : "Enter remarks",
387 c_background_color : function() {
390 name : 'background_color',
391 fieldLabel: "Background Colour"
394 c_image_view : function() {
397 xtype : 'FieldSetEx',
399 collapseGroup : 'companies-image',
403 style: 'width:420px;',
404 legend : "Logo Image",
407 xtype : 'DisplayImage', // image preview...
409 fieldLabel : 'Logo Image',
412 renderer : function(v) {
413 return v ? String.format('<img src="{0}" height="{1}">',
414 baseURL + '/Images/' + v + '/' + _this.data.logo_id_filename,
415 Math.min(this.height, _this.data.logo_id_height)) : "No Image Attached";
423 c_image_edit : function() {
427 fieldLabel : "Logo Image",
430 style: 'border: 1px solid #ccc;',
431 xtype : 'DisplayImage',
434 addTitle : "Change / Add Image",
435 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
436 handler : function() {
439 Pman.Dialog.Image.show({
441 ontable : 'Companies',
445 _t.setValue(data.id);
450 renderer : function(v) {
451 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
453 return "No Image Available" + '<BR/>';
455 return String.format('<img src="{0}" width="150">',
456 baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg'
463 c_image_change: function() {
465 xtype : 'FieldSetEx',
466 collapseGroup : 'companies-image',
467 name : 'image-change',
471 style: 'width:420px;',
472 legend : "Add / Change Image",
476 name : 'imageUpload',
477 fieldLabel : "Upload Image",
483 c_isOwner : function() {