1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.XtupleShipment = {
10 show : function(data, cb)
18 this.dialog.show(this.data._el);
21 this.form.setValues(data);
22 this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });
30 this.dialog = Roo.factory({
31 xtype: 'LayoutDialog',
38 title : "Edit Shipment / Delivery",
42 xtype: 'ContentPanel',
50 actioncomplete : function(_self,action)
52 if (action.type == 'setdata') {
54 if (_this.data.shiphead_id) {
55 this.load({ method: 'GET', params: { '_id' : _this.data.shiphead_id }});
58 _this.grid.ds.load({});
62 if (action.type == 'load') {
63 var d = action.result.data;
66 if (d.shiphead_shipped *1 > 0) {
68 "Warning", "This shipment has been confirmed, you must unconfirm it before you can edit it"
76 _this.grid.ds.load({});
80 if (action.type =='submit') {
85 _this.callback.call(_this, _this.form.getValues());
91 rendered : function (form)
97 style : 'margin:10px;',
99 url : baseURL + '/Roo/shiphead.php',
110 style : 'width:350px;height:193px;',
115 labelAlign : 'right',
122 fieldLabel : 'Number#',
123 name : 'shiphead_number',
133 labelAlign : 'right',
143 name : 'shiphead_shipdate',
150 name : 'shiphead_location_id_location_name',
158 name : 'shiphead_shipto_id_shipto_name',
165 name : 'shiphead_shipvia',
171 fieldLabel : 'Tracking',
172 name : 'shiphead_tracknum',
190 legend : "Delivery Notes",
191 style : 'width:330px',
196 fieldLabel : 'Delivery Notes',
197 name : 'shiphead_delivery_note',
206 legend : "Shipment Notes",
207 style : 'width:330px',
212 fieldLabel : 'Shipment Notes',
213 name : 'shiphead_notes',
223 name : 'shiphead_order_id'
228 name : 'shiphead_sfstatus',
234 name : 'shiphead_location_id'
239 name : 'shiphead_shipto_id'
244 name : 'shiphead_id',
261 activate : function() {
264 if (_this.isBuilder) {
270 _this.grid.ds.load({});
277 tableName : 'coitem',
278 title : "Order Items",
286 //_this.dialog = Pman.Dialog.FILL_IN
287 if (_this.panel.active) {
291 rowdblclick : function (_self, rowIndex, e)
295 afteredit : function (e)
297 //Roo.log('afteredit');
299 if (e.field == 'item_number') {
300 // afterselect handles this...
306 autoExpandColumn : 'item_descrip1',
310 xtype: 'CellSelectionModel',
313 tabend : function (_self)
315 _this.addItemBtn.fireEvent('click', _this.addItemBtn);
324 beforeload : function (_self,o) {
325 if (! _this.form.findField('shiphead_order_id').getValue()) {
328 o.params = o.params || {};
330 o.params.coitem_cohead_id = _this.form.findField('shiphead_order_id').getValue();
331 o.params.limit = 999;
332 o.params._stocked_only = 1;
333 o.params.shiphead_id = _this.form.findField('shiphead_id').getValue();
334 o.params.coitem_shipto_id = _this.form.findField('shiphead_shipto_id').getValue();
335 o.params['query[coitem_location_src]'] = _this.form.findField('shiphead_location_id').getValue();
341 sortInfo : { field : 'coitem_linenumber', direction: 'ASC' },
346 url : baseURL + '/Roo/coitem.php'
351 totalProperty : 'total',
356 'name': 'coitem_linenumber',
360 'name': 'coitem_itemsite_id',
364 'name': 'coitem_qtyord'
367 'name': 'coitem_unitcost'
370 'name': 'coitem_price'
373 'name': 'coitem_custprice'
376 'name': 'coitem_qtyreturned'
379 'name': 'coitem_prcost'
382 'name': 'coitem_price_uom_id',
386 'name': 'coitem_qtyreserved'
399 click : function (_self, e)
401 _this.grid.ds.each(function(r) {
402 r.set('shipitem_qty', Math.max(r.data.coitem_qtyord - r.data.shipitem_shipped));
406 text : "Fullfill all"
415 text : "Restore From"
421 select : function (combo, record, index)
423 //_this.grid.footer.onClick('first');
428 var data = record.json.data;
430 _this.grid.ds.each(function (r) {
431 if (typeof(data[r.data.coitem_itemsite_id+'']) == 'undefined') {
434 r.set('shipitem_qty', parseInt(data[r.data.coitem_itemsite_id+'']));
444 displayField : 'name',
446 emptyText : "Restore from",
447 forceSelection : true,
449 loadingText : "Searching...",
452 qtip : "Select Action",
453 queryParam : 'query[action]',
454 selectOnFocus : true,
455 tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
456 triggerAction : 'all',
464 beforeload : function (_self, o)
466 o.params = o.params || {};
467 // staff can see all logs, other companies can only see their own.
469 o.params._stash = _this.form.findField('shiphead_order_id').getValue();
474 sortInfo : { field : 'action' , direction : 'ASC' },
479 url : baseURL + '/Roo/Shiphead.php'
486 totalProperty : 'total',
507 _this.grid.ds.each(function(r) {
508 r.set('shipitem_qty', 0);
518 xtype: 'ColumnModel',
520 dataIndex : 'coitem_linenumber',
524 renderer : function(v,x,r) {
525 if (r.data.coitem_subnumber * 1 > 0) {
526 return String.format('{0}.{1}', v, r.data.coitem_subnumber );
528 return String.format('{0}', v);
532 xtype: 'ColumnModel',
534 dataIndex : 'item_number',
535 header : 'Item Code',
538 renderer : function(v) { return String.format('{0}', v); }
541 xtype: 'ColumnModel',
543 dataIndex : 'item_descrip1',
544 header : 'Item Description',
546 renderer : function(v, x, r) {
549 if (r.data.coitem_memo && r.data.coitem_memo.length) {
550 vv = r.data.coitem_memo;
552 return String.format('{0}', vv);
557 xtype: 'ColumnModel',
560 dataIndex : 'coitem_qtyord',
561 header : 'Ordered Qty',
563 renderer : function(v) { return String.format('{0}', v); }
566 xtype: 'ColumnModel',
569 dataIndex : 'shipitem_shipped',
570 header : 'Remaining Qty',
572 renderer : function(v,x,r) {
574 return String.format('{0}', r.data.coitem_qtyord - v);
578 xtype: 'ColumnModel',
581 dataIndex : 'shipitem_qty',
584 renderer : function(v,x,r) {
586 var vv = parseInt(v);
587 vv = isNaN(vv) ? 0 : vv;
588 r.data.shipitem_qty = vv; // get rid of decimal.
589 if (r.data.shipitem_shipped + vv > r.data.coitem_qtyord) {
590 return String.format('<b style="background-color:red;color:yellow">{0}</b>', vv);
592 // not fully fullfilled
593 if (r.data.shipitem_shipped + vv != r.data.coitem_qtyord) {
594 return String.format('<b style="background-color:blue;color:yellow">{0}</b>', vv);
596 return String.format('{0}', vv);
603 xtype: 'NumberField',
605 allowDecimals : true,
606 allowNegative : false,
607 decimalPrecision : 0,
609 style : 'text-align:right'
618 xtype: 'LayoutRegion',
622 xtype: 'LayoutRegion',
631 click : function (_self, e)
642 click : function (_self, e)
645 Roo.Ajax.timeout = 120000; // 2 minutes timeout..
648 _this.grid.ds.each(function(r) {
650 shipitem_orderitem_id : r.data.coitem_id,
651 shipitem_qty : r.data.shipitem_qty
656 _this.form.findField('shipitems').setValue(JSON.stringify(ar));
657 _this.form.doAction("submit");
660 render : function (_self)
662 _this.saveBtn = _self;