1 //<script type="text/javascript">
4 Pman.Dialog.Companies = new Roo.util.Observable({
6 'beforerender' : true, // trigger so we can add modules later..
7 'show' : true, // trigger on showing form.. - to load additiona data..
20 this.dialog = new Ext.LayoutDialog(Ext.get(document.body).createChild({tag:'div'}), {
22 title: "Edit Companies",
36 // tabPosition: 'top',
42 this.dialog.addKeyListener(27, this.dialog.hide, this.dialog);
43 this.dialog.addButton("Cancel", this.dialog.hide, this.dialog);
45 this.dialog.addButton("Save", this.save, this);
46 this.layout = this.dialog.getLayout();
47 this.layout.beginUpdate();
51 this.form = new Ext.form.Form({
56 actionfailed : function(f, act) {
57 _this.dialog.el.unmask();
59 Pman.standardActionFailed(f,act);
62 actioncomplete: function(f, act) {
63 _this.dialog.el.unmask();
64 //console.log('load completed');
65 // error messages?????
68 if (act.type == 'load') {
70 _this.data = act.result.data;
71 var meth = _this.data.isOwner || !Pman.Login.isOwner() ? 'disable' : 'enable';
74 if (_this.form.findField('comptype')) {
75 _this.form.findField('comptype')[meth]();
83 if (act.type == 'submit') { // only submitted here if we are
87 _this.callback.call(this, act.result.data);
99 //?? will this work...
101 this.form.addxtype.apply(this.form, this.getFormFields());
102 this.fireEvent('beforeRender', this );
104 var ef = this.dialog.getLayout().getEl().createChild({tag: 'div'});
105 ef.dom.style.margin = 10;
107 this.form.render(ef.dom);
109 var vp = this.dialog.getLayout().add('center', new Ext.ContentPanel(ef, {
111 //title: 'Org Details',
121 this.layout.endUpdate();
123 show : function (data, callback)
125 this.callback = callback;
126 this._id = data.id ? data.id : 0; // modify if you do not use ID !!!!
132 this.dialog.el.mask("Loading");
133 this.form.doAction('load', {
134 url: baseURL + '/Roo/Companies.html',
141 this.fireEvent('show');
144 this.form.setValues(data);
151 if (data.isOwner || !Pman.Login.isOwner()) {
152 this.dialog.setTitle("Your Company Details");
153 if (this.form.findField('comptype')) {
154 this.form.findField('comptype').disable();
161 this.dialog.setTitle(data.id ? "Edit Company" : "Add Company");
162 if (this.form.findField('comptype')) {
163 this.form.findField('comptype').enable();
166 this.fireEvent('show');
173 this.form.fileUpload = this.form.findField('imageUpload') ? true : false;
174 this.fireEvent('beforesave');
175 this.form.doAction('submit', {
176 url: baseURL + '/Roo/Companies.html',
185 comptypeList : function()
187 // should probably be system configurable..
190 [ 'CONSULTANT', "Consultant" ],
191 [ 'CLIENT' , "Client" ],
192 [ 'CONTRACTOR' , "Contractor" ]
193 // [ 'OWNER', "System Owner" ]
196 comptypeListToString: function(v) {
201 return "System Owner";
203 var a = this.comptypeList();
205 Roo.each(a, function( ar) {
217 getFormFields : function() {
224 this.c_comptype_name(),
240 this.c_background_color(),
242 //this.c_image_view(),
243 //this.c_image_change(),
252 c_code : function() {
255 fieldLabel : "Company ID (for filing Ref.)",
263 c_comptype_name : function() {
267 disabled : Pman.Login.isOwner() ? false : true,
268 name : 'comptype_name',
271 qtip : 'Select Company type',
280 xtype : 'SimpleStore',
281 fields: ['val', 'desc'],
282 data : this.comptypeList()
286 hiddenName : 'comptype',
291 triggerAction: 'all',
292 emptyText: "Select Type",
298 c_name : function() {
302 fieldLabel : "Company Name",
305 qtip : "Enter Company Name",
314 fieldLabel : "Phone",
317 qtip : "Enter Phone Number",
329 qtip : "Enter fax Number",
334 c_email : function() {
338 fieldLabel : "Email",
341 qtip : "Enter Email Address",
346 c_address : function() {
350 fieldLabel : "Address",
353 qtip : "Enter Address",
359 c_remarks : function() {
363 fieldLabel : "Remarks",
366 qtip : "Enter remarks",
372 c_background_color : function() {
375 name : 'background_color',
376 fieldLabel: "Background Colour"
379 c_image_view : function() {
382 xtype : 'FieldSetEx',
384 collapseGroup : 'companies-image',
388 style: 'width:420px;',
389 legend : "Logo Image",
392 xtype : 'DisplayImage', // image preview...
394 fieldLabel : 'Logo Image',
397 renderer : function(v) {
398 return v ? String.format('<img src="{0}" height="{1}">',
399 baseURL + '/Images/' + v + '/' + _this.data.logo_id_filename,
400 Math.min(this.height, _this.data.logo_id_height)) : "No Image Attached";
408 c_image_edit : function() {
412 fieldLabel : "Logo Image",
415 style: 'border: 1px solid #ccc;',
416 xtype : 'DisplayImage',
419 addTitle : "Change / Add Image",
420 icon: Roo.rootURL + 'images/default/dd/drop-add.gif',
421 handler : function() {
424 Pman.Dialog.Image.show({
426 ontable : 'Companies',
430 _t.setValue(data.id);
435 renderer : function(v) {
436 //var vp = v ? v : 'Companies:' + _this.data.id + ':-LOGO';
438 return "No Image Available" + '<BR/>';
440 return String.format('<img src="{0}" width="150">',
441 baseURL + '/Images/Thumb/150x150/' + v + '/logo.jpg'
448 c_image_change: function() {
450 xtype : 'FieldSetEx',
451 collapseGroup : 'companies-image',
452 name : 'image-change',
456 style: 'width:420px;',
457 legend : "Add / Change Image",
461 name : 'imageUpload',
462 fieldLabel : "Upload Image",
468 c_isOwner : function() {