3 Pman.Dialog.Companies = new Roo.util.Observable({
5 show : function (data, callback)
7 Pman.Dialog.CoreCompanies.show({id:data.id});
14 //<script type="text/javascript">
18 Pman.Dialog.Companies = new Roo.util.Observable({
20 'beforerender' : true, // trigger so we can add modules later..
21 'show' : true, // trigger on showing form.. - to load additiona data..
34 this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}), {
36 title: "Edit Companies",
50 // tabPosition: 'top',
56 this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
57 this.dialog.addButton("Cancel", this.dialog.hide, this.dialog);
59 this.dialog.addButton("Save", this.save, this);
60 this.layout = this.dialog.getLayout();
61 this.layout.beginUpdate();
65 this.form = new Ext.form.Form({
70 actionfailed : function(f, act) {
71 _this.dialog.el.unmask();
73 Pman.standardActionFailed(f,act);
76 actioncomplete: function(f, act) {
77 _this.dialog.el.unmask();
78 //console.log('load completed');
79 // error messages?????
82 if (act.type == 'load') {
84 _this.data = act.result.data;
85 var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
88 if (_this.form.findField('comptype')) {
89 _this.form.findField('comptype')[meth]();
97 if (act.type == 'submit') { // only submitted here if we are
100 if (_this.callback) {
101 _this.callback.call(this, act.result.data);
113 //?? will this work...
115 this.form.addxtype.apply(this.form, this.getFormFields());
116 this.fireEvent('beforeRender', this );
118 var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
119 ef.dom.style.margin = 10;
121 this.form.render(ef.dom);
123 var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
125 //title: 'Org Details',
135 this.layout.endUpdate();
137 show : function (data, callback)
139 this.callback = callback;
140 this._id = data.id ? data.id : 0; // modify if you do not use ID !!!!
146 this.dialog.el.mask("Loading");
147 this.form.doAction('load', {
148 url: baseURL + '/Roo/Companies.html',
155 this.fireEvent('show');
158 this.form.setValues(data);
165 if (data.isOwner || !Pman.Login.isOwner()) {
166 this.dialog.setTitle("Your Company Details");
167 if (this.form.findField('comptype')) {
168 this.form.findField('comptype').disable();
175 this.dialog.setTitle(data.id ? "Edit Company" : "Add Company");
176 if (this.form.findField('comptype')) {
177 this.form.findField('comptype').enable();
180 this.fireEvent('show');
187 this.form.fileUpload = this.form.findField('imageUpload') ? true : false;
188 this.fireEvent('beforesave');
189 this.form.doAction('submit', {
190 url: baseURL + '/Roo/Companies.html',
199 comptypeList : function()
201 // should probably be system configurable..
204 [ 'CONSULTANT', "Consultant" ],
205 [ 'CLIENT' , "Client" ],
206 [ 'CONTRACTOR' , "Contractor" ]
207 // [ 'OWNER', "System Owner" ]
210 comptypeListToString: function(v) {
215 return "System Owner";
217 var a = this.comptypeList();
219 Roo.each(a, function( ar) {
231 getFormFields : function() {
238 this.c_comptype_name(),
254 this.c_background_color(),
256 //this.c_image_view(),
257 //this.c_image_change(),
266 c_code : function() {
269 fieldLabel : "Company ID (for filing Ref.)",
277 c_comptype_name : function() {
281 disabled : Pman.Login.isOwner() ? false : true,
282 name : 'comptype_name',
285 qtip : 'Select Company type',
294 xtype : 'SimpleStore',
295 fields: ['val', 'desc'],
296 data : this.comptypeList()
300 hiddenName : 'comptype',
305 triggerAction: 'all',
306 emptyText: "Select Type",
312 c_name : function() {
316 fieldLabel : "Company Name",
319 qtip : "Enter Company Name",
328 fieldLabel : "Phone",
331 qtip : "Enter Phone Number",
343 qtip : "Enter fax Number",
348 c_email : function() {
352 fieldLabel : "Email",
355 qtip : "Enter Email Address",
360 c_address : function() {
364 fieldLabel : "Address",
367 qtip : "Enter Address",
373 c_remarks : function() {
377 fieldLabel : "Remarks",
380 qtip : "Enter remarks",
386 c_background_color : function() {
389 name : 'background_color',
390 fieldLabel: "Background Colour"
393 c_image_view : function() {
396 xtype : 'FieldSetEx',
398 collapseGroup : 'companies-image',
402 style: 'width:420px;',
403 legend : "Logo Image",
406 xtype : 'DisplayImage', // image preview...
408 fieldLabel : 'Logo Image',
411 renderer : function(v) {
412 return v ? String.format('<img src="{0}" height="{1}">',
413 baseURL + '/Images/' + v + '/' + _this.data.logo_id_filename,
414 Math.min(this.height, _this.data.logo_id_height)) : "No Image Attached";
422 c_image_edit : function() {
426 fieldLabel : "Logo Image",
429 style: 'border: 1px solid #ccc;',
430 xtype : 'DisplayImage',
433 addTitle : "Change / Add Image",
434 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
435 handler : function() {
438 Pman.Dialog.Image.show({
440 ontable : 'Companies',
444 _t.setValue(data.id);
449 renderer : function(v) {
450 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
452 return "No Image Available" + '<BR/>';
454 return String.format('<img src="{0}" width="150">',
455 baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg'
462 c_image_change: function() {
464 xtype : 'FieldSetEx',
465 collapseGroup : 'companies-image',
466 name : 'image-change',
470 style: 'width:420px;',
471 legend : "Add / Change Image",
475 name : 'imageUpload',
476 fieldLabel : "Upload Image",
482 c_isOwner : function() {