1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
5 Pman.Dialog.XtuplePurchaseOrder = {
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',
36 this.layout.getRegion('center').showPanel(0);
44 title : "New Purchase Order",
48 xtype: 'ContentPanel',
51 title : "Order Details",
57 actioncomplete : function(_self,action)
59 if (action.type == 'setdata') {
60 _this.uploadBtn.disabled = false;
61 if(!_this.data.pohead_id && Pman.Login.authUser.name.length){
63 _this.form.findField('pohead_agent_username').setValue(Pman.Login.authUser.name);
64 _this.form.findField('pohead_orderdate').setValue(new Date());
65 _this.form.findField('pohead_bg_arrival_est_day').setValue(new Date());
66 _this.form.findField('pohead_bg_available_est_day').setValue(new Date());
67 _this.form.findField('pohead_bg_available_latest_day').setValue(new Date());
70 _this.dialog.setTitle("Edit Purchase Order");
72 '_id' : _this.data.pohead_id
74 if(_this.data.office){
75 params['_roo_office'] = _this.data.office;
78 this.load({ method: 'GET', params: params});
81 if (action.type == 'load') {
82 _this.dontClose = false;
83 if(_this.data.office){
84 _this.uploadBtn.disabled = true;
87 if (action.result.data.pohead_status == 'U') {
90 var cn = _this.form.findField('pohead_curr_id');
92 if (action.result.data.pohead_id * 1 < 1) {
93 cn.setDisabled(false);
97 _this.grid.footer.onClick('first');
102 if (action.type =='submit') {
105 var cid = this.findField('pohead_id').getValue()*1;
106 if (cid && !_this.dontClose) {
110 if (_this.callback) {
111 _this.callback.call(_this, _this.form.getValues());
117 _this.dontClose = false;
118 _this.data.pohead_id = action.result.data.pohead_id;
119 this.fireEvent('actioncomplete', this, {
122 pohead_id : action.result.data.pohead_id
129 rendered : function (form)
133 actionfailed : function (_self, action)
135 _this.dialog.el.unmask();
136 if (action.failureType == 'client') {
137 Roo.MessageBox.alert("Error", "Please fill in all the required fields");
139 if (action.failureType == 'server') {
140 Roo.MessageBox.alert("Error", action.result.errorMsg);
142 _this.dialog.layout.getRegion('center').showPanel(0);
148 style : 'margin:10px;',
149 url : baseURL + '/Xtuple/Roo/Pohead.php',
154 emptyText : "Automatic",
155 fieldLabel : 'Order #',
156 name : 'pohead_number',
164 fieldLabel : 'Order Date',
166 name : 'pohead_orderdate',
172 fieldLabel : 'Estimated Arrival Date',
174 name : 'pohead_bg_arrival_est_day',
180 fieldLabel : 'Estimated Available Date',
182 name : 'pohead_bg_available_est_day',
188 fieldLabel : 'Latest Estimated Available Date',
190 name : 'pohead_bg_available_latest_day',
197 name : 'pohead_bg_va',
203 fieldLabel : 'Vendor',
204 name : 'pohead_vend_id_vend_name',
212 displayField : 'fname',
214 fieldLabel : 'Status',
215 hiddenName : 'pohead_status',
218 name : 'pohead_status',
220 tpl : '<div class="x-grid-cell-text x-btn button"><b>{fname}</b> </div>',
221 triggerAction : 'all',
223 valueField : 'ftype',
226 xtype: 'SimpleStore',
229 [ 'U', "Unreleased"],
233 fields : [ 'ftype', 'fname']
240 displayField : 'curr_name',
242 emptyText : "Select Currency",
243 fieldLabel : 'Currency',
244 forceSelection : true,
245 hiddenName : 'pohead_curr_id',
247 loadingText : "Searching...",
249 name : 'pohead_curr_id_curr_name',
251 qtip : "Select Currency",
252 queryParam : 'query[curr_name]',
253 selectOnFocus : true,
254 tpl : '<div class="x-grid-cell-text x-btn button"><b>{curr_name}</b> </div>',
255 triggerAction : 'all',
257 valueField : 'curr_id',
263 beforeload : function (_self, o){
264 o.params = o.params || {};
268 sortInfo : { direction : 'ASC', field: 'curr_id' },
273 url : baseURL + '/Roo/curr_symbol.php'
280 totalProperty : 'total',
282 {"name":"curr_id","type":"int"},
283 {"name":"curr_name","type":"string"}
292 displayField : 'location_name',
294 emptyText : "Select a location",
295 fieldLabel : 'Location',
296 forceSelection : true,
297 hiddenName : 'pohead_location_id',
299 loadingText : "Searching...",
301 name : 'pohead_location_id_location_name',
303 qtip : "Select terms",
304 queryParam : 'query[location_name]',
305 selectOnFocus : true,
306 tpl : '<div class="x-grid-cell-text x-btn button"><b>{location_name}</b> </div>',
307 triggerAction : 'all',
309 valueField : 'location_id',
315 beforeload : function (_self, o){
316 o.params = o.params || {};
318 o.params.location_netable = 1;
319 o.params._viewType = 'local';
323 sortInfo : { direction : 'ASC', field: 'location_name' },
328 url : baseURL + '/Roo/location.php'
335 totalProperty : 'total',
336 fields : [{"name":"location_id","type":"int"},"location_name"]
344 displayField : 'terms_descrip',
346 emptyText : "Select Terms",
347 fieldLabel : 'Terms',
348 forceSelection : true,
349 hiddenName : 'pohead_terms_id',
351 loadingText : "Searching...",
353 name : 'pohead_terms_id_terms_descrip',
355 qtip : "Select Terms",
356 queryParam : 'query[terms_descrip]',
357 selectOnFocus : true,
358 tpl : '<div class="x-grid-cell-text x-btn button"><b>{terms_descrip}</b> </div>',
359 triggerAction : 'all',
361 valueField : 'terms_id',
367 beforeload : function (_self, o){
368 o.params = o.params || {};
372 sortInfo : { direction : 'ASC', field: 'terms_descrip' },
377 url : baseURL + '/Roo/Terms.php'
384 totalProperty : 'total',
386 {"name":"terms_id","type":"int"},
387 {"name":"terms_descrip","type":"string"}
396 displayField : 'taxzone_descrip',
398 emptyText : "Select Tax Zone",
399 fieldLabel : 'Tax Zone',
400 forceSelection : true,
401 hiddenName : 'pohead_taxzone_id',
403 loadingText : "Searching...",
405 name : 'pohead_taxzone_id_taxzone_descrip',
407 qtip : "Select Tax Zone",
408 queryParam : 'query[taxzone_descrip]',
409 selectOnFocus : true,
410 tpl : '<div class="x-grid-cell-text x-btn button"><b>{taxzone_descrip}</b> </div>',
411 triggerAction : 'all',
413 valueField : 'taxzone_id',
419 beforeload : function (_self, o){
420 o.params = o.params || {};
424 sortInfo : { direction : 'ASC', field: 'taxzone_id' },
429 url : baseURL + '/Roo/Taxzone.php'
436 totalProperty : 'total',
438 {"name":"taxzone_id","type":"int"},
439 {"name":"taxzone_descrip","type":"string"}
448 displayField : 'emp_name',
450 emptyText : "Select Purchasing Agent",
451 fieldLabel : 'Purchase Agent',
452 forceSelection : true,
453 hiddenName : 'pohead_agent_username',
455 loadingText : "Searching...",
457 name : 'pohead_agent_username',
459 qtip : "Select Purchasing Agent",
460 queryParam : 'query[emp_name]',
461 selectOnFocus : true,
462 tpl : '<div class="x-grid-cell-text x-btn button"><b>{emp_name}</b> </div>',
463 triggerAction : 'all',
465 valueField : 'emp_name',
471 beforeload : function (_self, o){
472 o.params = o.params || {};
476 sortInfo : { direction : 'ASC', field: 'emp_id' },
481 url : baseURL + '/Roo/Emp.php'
488 totalProperty : 'total',
490 {"name":"emp_id","type":"int"},
491 {"name":"emp_name","type":"string"}
499 fieldLabel : 'Comments',
501 name : 'pohead_comments',
507 name : 'pohead_vend_id'
527 activate : function() {
531 var pid = _this.form.findField('pohead_id').getValue() * 1;
533 Roo.MessageBox.alert("Save First", "Please save the purchase order first, before adding items");
534 _this.dialog.layout.getRegion('center').showPanel(0);
539 _this.grid.footer.onClick('first');
542 deactivate : function (_self)
547 _this.grid.ds.each(function(r) {
549 poitem_id : r.data.poitem_id,
550 poitem_itemsite_id : r.data.poitem_itemsite_id,
551 poitem_unitprice : r.data.poitem_unitprice,
552 poitem_qty_ordered : r.data.poitem_qty_ordered
557 _this.form.findField('items').setValue(JSON.stringify(ar));
559 _this.dontClose = true;
560 _this.form.doAction("submit");
568 tableName : 'poitem',
569 title : "Order Items",
577 //_this.dialog = Pman.Dialog.FILL_IN
578 if (_this.panel.active) {
579 this.footer.onClick('first');
582 beforeedit : function (e)
584 var r = e.record.data.poitem_qty_received * 1;
587 Roo.MessageBox.alert("Error", "This item has been receipted");
591 var status = _this.form.findField('pohead_status').getValue();
594 Roo.MessageBox.alert("Error", "This PO has been closed");
601 autoExpandColumn : 'item_descrip1',
608 beforeload : function (_self, o){
609 o.params = o.params || {};
610 var hid = _this.form.findField('pohead_id').getValue();
616 o.params.poitem_pohead_id = hid;
617 o.params._with_item = 1;
618 o.params._roo_office = _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2);
621 load : function (_self, records, options)
623 _this.grid.footer.updateSummary();
627 sortInfo : { field : 'poitem_linenumber', direction: 'ASC' },
633 url : baseURL + '/Xtuple/Roo/Poitem.php'
640 totalProperty : 'total',
659 var status = _this.form.findField('pohead_status').getValue();
662 Roo.MessageBox.alert("Error", "This PO has been closed");
666 var ct = _this.grid.ds.getCount();
668 var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;
670 var dt = _this.form.findField('pohead_orderdate').getValue();
672 var nr = _this.grid.ds.reader.newRow({
674 poitem_linenumber : last,
678 poitem_qty_ordered : 1,
682 _this.grid.stopEditing();
683 _this.grid.ds.insert(_this.grid.ds.getCount(), nr);
684 _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
687 cls : 'x-btn-text-icon',
689 icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
697 var status = _this.form.findField('pohead_status').getValue();
700 Roo.MessageBox.alert("Error", "This PO has been closed");
704 var cs = _this.grid.getSelectionModel().getSelectedCell();
706 Roo.MessageBox.alert("Error", "Select a cell");
709 _this.grid.stopEditing();
710 var r = _this.grid.ds.getAt(cs[0]);
712 if(r.data.poitem_qty_received * 1 > 0){
713 Roo.MessageBox.alert("Error", "This item has been receipted");
718 _this.grid.ds.remove(r);
722 cls : 'x-btn-text-icon',
724 icon : rootURL + '/Pman/templates/images/trash.gif'
729 xtype: 'PagingToolbar',
732 emptyMsg : "No Item found",
734 updateSummary : function() {
738 url : baseURL + '/Xtuple/Roo/Poitem',
\r
741 _roo_office : _this.data.office ? _this.data.office : baseURL.split('/').pop().substr(0,2),
\r
743 poitem_pohead_id : _this.form.findField('pohead_id').getValue()
\r
745 success : function(d) {
747 f.displayEl.update(String.format(
\r
748 "{0} items | Total : {1} {2}",
\r
749 d.data[0].count_item,
\r
750 _this.form.findField('pohead_curr_id').el.dom.value,
\r
761 xtype: 'ColumnModel',
764 dataIndex : 'poitem_linenumber',
767 renderer : function(v) { return String.format('{0}', v); }
770 xtype: 'ColumnModel',
772 dataIndex : 'item_number',
773 header : 'Item code',
775 renderer : function(v) { return String.format('{0}', v); },
783 beforeselect : function (combo, record, index)
785 var ar = _this.grid.activeEditor.record;
788 ar.set('item_descrip1', record.data.itemsite_item_id_item_descrip1);
789 ar.set('poitem_itemsite_id', record.data.itemsite_id);
795 displayField : 'itemsite_item_id_item_number',
797 emptyText : "Select item",
798 forceSelection : true,
799 hiddenName : 'itemsite_item_id_item_number',
801 loadingText : "Searching...",
803 name : 'item_number',
805 qtip : "Select item",
806 queryParam : 'query[number]',
807 selectOnFocus : true,
808 tpl : '<div class="x-grid-cell-text x-btn button"><b>{itemsite_item_id_item_number}</b> - {itemsite_item_id_item_descrip1} </div>',
809 triggerAction : 'all',
811 valueField : 'item_number',
816 beforeload : function (_self, o){
817 o.params = o.params || {};
818 o.params.itemsite_posupply = 1;
822 sortInfo : { direction : 'ASC', field: 'item_number' },
827 url : baseURL + '/Roo/itemsite.php'
834 totalProperty : 'total',
835 fields : [{"name":"item_id","type":"int"},"item_number"]
842 xtype: 'ColumnModel',
844 dataIndex : 'item_descrip1',
845 header : 'Item description',
847 renderer : function(v) { return String.format('{0}', v); }
850 xtype: 'ColumnModel',
852 dataIndex : 'poitem_duedate',
855 renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
858 xtype: 'ColumnModel',
861 dataIndex : 'poitem_qty_ordered',
864 renderer : function(v) { return String.format('{0}', v); },
869 xtype: 'NumberField',
871 allowDecimals : false,
872 decimalPrecision : 0,
874 style : 'text-align:right'
879 xtype: 'ColumnModel',
882 dataIndex : 'poitem_qty_received',
885 renderer : function(v,x,r) {
886 return String.format(
887 r.data.poitem_qty_ordered != (v-r.data.poitem_qty_returned) ? '<span style="color:red">{0}</span>': '{0}',
888 v - r.data.poitem_qty_returned);
892 xtype: 'ColumnModel',
895 dataIndex : 'poitem_qty_vouchered',
896 header : 'Vouchered',
898 renderer : function(v,x,r) {
899 return String.format(
900 r.data.poitem_qty_ordered != v ? '<span style="color:red">{0}</span>': '{0}',
905 xtype: 'ColumnModel',
908 dataIndex : 'poitem_unitprice',
909 header : 'Unit price',
911 renderer : function(v) { return String.format('{0}', (v || v == 0) ? parseFloat(v).toFixed(3) : ''); },
916 xtype: 'NumberField',
918 allowDecimals : false,
919 decimalPrecision : 0,
921 style : 'text-align:right'
929 xtype: 'NestedLayoutPanel',
934 xtype: 'BorderLayout',
941 activate : function() {
942 _this.itempanel = this;
945 if (_this.itemgrid) {
946 _this.itemgrid.footer.onClick('first');
954 tableName : 'poitem',
962 _this.itemgrid = this;
963 //_this.dialog = Pman.Dialog.FILL_IN
964 if (_this.itempanel.active) {
965 this.footer.onClick('first');
968 rowclick : function (_self, rowIndex, e)
971 _this.gltransgrid.footer.onClick('first');
974 autoExpandColumn : 'item_number',
984 click : function (_self, e)
988 url : baseURL + '/Roo/Metasql',
992 _group : 'gltrans_stock',
994 'pohead_number:text' : _this.form.findField('pohead_number').getValue(),
1002 text : "PO analysis"
1007 xtype: 'RowSelectionModel',
1015 beforeload : function (_self, o)
1017 o.params = o.params || {};
1018 var hid = _this.form.findField('pohead_id').getValue();
1024 o.params.poitem_pohead_id = hid;
1026 o.params._with_item = 1;
1029 load : function (_self, records, options)
1031 _this.gltransgrid.footer.onClick('first');
1035 sortInfo : { field : 'poitem_id', direction: 'ASC' },
1040 url : baseURL + '/Roo/poitem.php'
1043 xtype: 'JsonReader',
1045 totalProperty : 'total',
1066 'name': 'leader_id',
1070 'name': 'leader_office_id',
1074 'name': 'leader_name',
1078 'name': 'leader_phone',
1082 'name': 'leader_fax',
1086 'name': 'leader_email',
1090 'name': 'leader_company_id',
1094 'name': 'leader_role',
1098 'name': 'leader_active',
1102 'name': 'leader_remarks',
1106 'name': 'leader_passwd',
1110 'name': 'leader_owner_id',
1114 'name': 'leader_lang',
1118 'name': 'leader_no_reset_sent',
1122 'name': 'leader_action_type',
1126 'name': 'leader_project_id',
1130 'name': 'leader_deleted_by',
1134 'name': 'leader_deleted_dt',
1138 'name': 'leader_firstname',
1142 'name': 'leader_lastname',
1146 'name': 'leader_name_facebook',
1150 'name': 'leader_url_blog',
1154 'name': 'leader_url_twitter',
1158 'name': 'leader_url_linkedin',
1162 'name': 'leader_crm_lead_percentage',
1166 'name': 'leader_crm_industry_id',
1170 'name': 'leader_crm_updated_action_id',
1174 'name': 'leader_crm_created_action_id',
1178 'name': 'leader_crm_type_id',
1185 xtype: 'PagingToolbar',
1187 displayInfo : false,
1188 displayMsg : "Displaying poitem{0} - {1} of {2}",
1189 emptyMsg : "No item found",
1194 xtype: 'ColumnModel',
1196 dataIndex : 'poitem_linenumber',
1199 renderer : function(v) { return String.format('{0}', v); }
1202 xtype: 'ColumnModel',
1204 dataIndex : 'item_number',
1207 renderer : function(v) { return String.format('{0}', v); }
1210 xtype: 'ColumnModel',
1212 dataIndex : 'poitem_qty_ordered',
1215 renderer : function(v) { return String.format('{0}', v); }
1218 xtype: 'ColumnModel',
1220 dataIndex : 'poitem_qty_received',
1221 header : 'Received',
1223 renderer : function(v,x,r)
1227 var recv = (v- r.data.poitem_qty_returned);
1228 if (recv != r.data.tx_qty) {
1229 return String.format('<s style="color:red;font-weight:bold">{0}</s>{1} ', recv,
1230 (r.data.tx_qty *1).toFixed(0) ) ;
1232 return String.format('{0}', (v- r.data.poitem_qty_returned)) ;
1237 xtype: 'ColumnModel',
1239 dataIndex : 'poitem_unitprice',
1240 header : 'Unit Price',
1242 renderer : function(v,x,r)
1245 return String.format('{0}', (v- r.data.poitem_qty_returned) ? parseFloat(v- r.data.poitem_qty_returned).toFixed(3) : '') ;
1256 activate : function() {
1257 _this.gltranspanel = this;
1258 //if (_this.gltransgrid) {
1259 // _this.gltransgrid.footer.onClick('first');
1264 fitContainer : true,
1267 tableName : 'Gltrans',
1275 _this.gltransgrid = this;
1276 //_this.dialog = Pman.Dialog.FILL_IN
1277 // if (_this.gltranspanel.active) {
1278 // this.footer.onClick('first');
1282 autoExpandColumn : 'gltrans_notes',
1285 xtype: 'RowSelectionModel',
1293 beforeload : function (_self, o)
1295 o.params = o.params || {};
1297 var s = _this.itemgrid.getSelectionModel().getSelected();
1303 o.params._poview = 1;
1304 o.params.gltrans_deleted = 0;
1305 o.params.gltrans_doctype = 'PO';
1306 o.params._linenumber = s.data.poitem_linenumber;
1307 o.params._item = s.data.item_number;
1308 o.params._ponumber = _this.form.findField('pohead_number').getValue();
1313 sortInfo : { field : 'gltrans_id', direction: 'ASC' },
1318 url : baseURL + '/Roo/gltrans.php'
1321 xtype: 'JsonReader',
1323 totalProperty : 'total',
1344 'name': 'leader_id',
1348 'name': 'leader_office_id',
1352 'name': 'leader_name',
1356 'name': 'leader_phone',
1360 'name': 'leader_fax',
1364 'name': 'leader_email',
1368 'name': 'leader_company_id',
1372 'name': 'leader_role',
1376 'name': 'leader_active',
1380 'name': 'leader_remarks',
1384 'name': 'leader_passwd',
1388 'name': 'leader_owner_id',
1392 'name': 'leader_lang',
1396 'name': 'leader_no_reset_sent',
1400 'name': 'leader_action_type',
1404 'name': 'leader_project_id',
1408 'name': 'leader_deleted_by',
1412 'name': 'leader_deleted_dt',
1416 'name': 'leader_firstname',
1420 'name': 'leader_lastname',
1424 'name': 'leader_name_facebook',
1428 'name': 'leader_url_blog',
1432 'name': 'leader_url_twitter',
1436 'name': 'leader_url_linkedin',
1440 'name': 'leader_crm_lead_percentage',
1444 'name': 'leader_crm_industry_id',
1448 'name': 'leader_crm_updated_action_id',
1452 'name': 'leader_crm_created_action_id',
1456 'name': 'leader_crm_type_id',
1463 xtype: 'PagingToolbar',
1466 displayMsg : "Displaying gltrans{0} - {1} of {2}",
1467 emptyMsg : "No gltrans found",
1481 text : "Apply fixes",
1492 var pohead_number = _this.form.findField('pohead_number').getValue();
1493 var pohead_id = _this.form.findField('pohead_id').getValue();
1497 url : baseURL + '/Roo/pohead.php',
1501 pohead_id : pohead_id,
1505 success : function(res) {
1506 Roo.MessageBox.alert('Notice', 'DONE');
1516 cls : 'x-btn-text-icon',
1517 text : "Repost goods reciept",
1518 icon : rootURL + '/Pman/templates/images/trash.gif'
1530 var pohead_number = _this.form.findField('pohead_number').getValue();
1531 var pohead_id = _this.form.findField('pohead_id').getValue();
1533 var fixit = function(){
1535 url : baseURL + '/Roo/pohead.php',
1538 pohead_id : pohead_id,
1542 success : function(res) {
1543 Roo.MessageBox.alert('Notice', 'DONE');
1548 Roo.MessageBox.confirm(
1550 "Are you sure to fix the unit cost of " + pohead_number + " ?",
1564 cls : 'x-btn-text-icon',
1565 text : "Fix Unit Cost",
1566 icon : rootURL + '/Pman/templates/images/trash.gif'
1578 var pohead_number = _this.form.findField('pohead_number').getValue();
1579 var pohead_id = _this.form.findField('pohead_id').getValue();
1581 var addv = function(){
1583 url : baseURL + '/Roo/pohead.php',
1586 pohead_id : pohead_id,
1590 success : function(res) {
1591 Roo.MessageBox.alert('Notice', 'DONE');
1596 Roo.MessageBox.confirm(
1598 "Are you sure to add all the variance for " + pohead_number + " ?",
1612 cls : 'x-btn-text-icon',
1613 text : "Add All Variance",
1614 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
1622 var s = _this.gltransgrid.getSelectionModel().getSelected();
1625 Roo.MessageBox.alert('Error','Please select a transaction');
1629 if(s.data.gltrans_misc_id != -1){
1630 Roo.MessageBox.alert('Error','Just allow to delete the variance');
1634 var delit = function(){
1636 url : baseURL + '/Roo/Gltrans.php',
1639 gltrans_id : s.data.gltrans_id,
1643 success : function(res) {
1644 _this.gltransgrid.footer.onClick('refresh');
1650 Roo.MessageBox.confirm(
1652 "Are you sure to delete ?",
1666 cls : 'x-btn-text-icon',
1667 text : "Delete Variance",
1668 icon : rootURL + '/Pman/templates/images/trash.gif'
1676 var pohead_number = _this.form.findField('pohead_number').getValue();
1677 var pohead_id = _this.form.findField('pohead_id').getValue();
1679 var delv = function(){
1681 url : baseURL + '/Roo/pohead.php',
1684 pohead_id : pohead_id,
1688 success : function(res) {
1689 Roo.MessageBox.alert('Notice', 'DONE');
1694 Roo.MessageBox.confirm(
1696 "Are you sure to delete the variance on voucher of " + pohead_number + " ?",
1710 cls : 'x-btn-text-icon',
1711 text : "Delete Varinace on voucher",
1712 icon : rootURL + '/Pman/templates/images/trash.gif'
1723 var s = _this.gltransgrid.selModel.getSelected();
1725 Roo.MessageBox.alert("Error", "Select an item to reverse");
1729 var fixit = function(){
1731 url : baseURL + '/Roo/invdetail.php',
1735 _reverse : s.data.invdetail_id
1737 success : function(res) {
1738 Roo.MessageBox.alert('Notice', 'DONE');
1743 Roo.MessageBox.confirm(
1745 "Are you sure to reverse that line",
1759 cls : 'x-btn-text-icon',
1761 icon : rootURL + '/Pman/templates/images/trash.gif'
1767 xtype: 'ColumnModel',
1769 dataIndex : 'gltrans_id',
1772 renderer : function(v) { return String.format('{0}', v); }
1775 xtype: 'ColumnModel',
1777 dataIndex : 'gltrans_date',
1780 renderer : function(v) { return String.format('{0}', v ? v.format('Y-m-d') : ''); }
1783 xtype: 'ColumnModel',
1785 dataIndex : 'gltrans_docnumber',
1788 renderer : function(v) { return String.format('{0}', v); }
1791 xtype: 'ColumnModel',
1794 dataIndex : 'invdetail_qty',
1797 renderer : function(v,x,r) {
1798 var f = r.data.invfifo_void * 1 ? '<s>{0}</s>' : '{0}';
1800 return String.format(f, (v*1).toFixed(0));
1805 xtype: 'ColumnModel',
1808 dataIndex : 'gltrans_amount',
1811 renderer : function(v,x,r) {
1812 return String.format('{0}', v);
1817 xtype: 'ColumnModel',
1820 dataIndex : 'invdetail_qty',
1823 renderer : function(v,x,r) {
1824 var f = r.data.invfifo_void * 1 ? '<s>{0}</s>' : '{0}';
1826 return String.format(f, (v*1).toFixed(0));
1831 xtype: 'ColumnModel',
1833 dataIndex : 'gltrans_notes',
1836 renderer : function(v) { return String.format('{0}', v); }
1843 xtype: 'LayoutRegion',
1847 xtype: 'LayoutRegion',
1855 xtype: 'NestedLayoutPanel',
1860 xtype: 'BorderLayout',
1867 activate : function() {
1868 _this.gltxpanel = this;
1869 if (_this.gltxgrid) {
1870 _this.gltxgrid.footer.onClick('first');
1875 fitContainer : true,
1878 tableName : 'invdetail',
1879 title : "invdetail",
1886 _this.gltxgrid = this;
1887 //_this.dialog = Pman.Dialog.FILL_IN
1888 if (_this.gltxpanel.active) {
1889 this.footer.onClick('first');
1892 cellclick : function (_self, rowIndex, columnIndex, e)
1894 if (columnIndex > 0) {
1897 var rec = this.ds.getAt(rowIndex);
1898 rec.set('gltrans_as_summary', rec.data.gltrans_as_summary *1 ? 0 : 1);
1899 _this.gltxdgrid.footer.onClick('first');
1902 autoExpandColumn : 'gltrans_accnt_id_accnt_descrip',
1905 xtype: 'RowSelectionModel',
1908 selectionchange : function (_self)
1910 _this.gltxdgrid.footer.onClick('first');;
1919 beforeload : function (_self, o)
1921 o.params.pohead_id = _this.form.findField('pohead_id').getValue();
1922 if (! o.params.pohead_id ) {
1926 o.params._split_sales = _this.glsalesbtn.pressed ? 1 : 0;
1928 load : function (_self, records, options)
1930 _this.gltxdgrid.footer.onClick('first');
1934 sortInfo : { field : 'item_number', direction: 'ASC' },
1939 url : baseURL + '/Roo/gltrans.php'
1942 xtype: 'JsonReader',
1944 totalProperty : 'total',
1949 'name': 'invdetail_id',
1953 'name': 'invdetail_transtype',
1957 'name': 'invdetail_invhist_id',
1961 'name': 'invdetail_location_id',
1965 'name': 'invdetail_qty',
1969 'name': 'invdetail_comments',
1973 'name': 'invdetail_qty_before',
1977 'name': 'invdetail_qty_after',
1981 'name': 'invdetail_invcitem_id',
1985 'name': 'invdetail_expiration',
1987 'dateFormat': 'Y-m-d'
1990 'name': 'invdetail_warrpurc',
1992 'dateFormat': 'Y-m-d'
1995 'name': 'invdetail_ls_id',
2002 xtype: 'PagingToolbar',
2005 displayMsg : "Displaying invdetail{0} - {1} of {2}",
2006 emptyMsg : "No invdetail found",
2013 render : function (_self)
2015 _this.glsalesbtn = _self;
2017 click : function (_self, e)
2019 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
2022 enableToggle : true,
2024 text : "Split sales"
2030 xtype: 'ColumnModel',
2032 dataIndex : 'gltrans_as_summary',
2035 renderer : function(v,x,r) {
2037 var state = v*1 ? '-checked' : '';
2039 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
2043 xtype: 'ColumnModel',
2045 dataIndex : 'gltrans_accnt_id_accnt_descrip',
2048 renderer : function(v) { return String.format('{0}', v); }
2051 xtype: 'ColumnModel',
2054 dataIndex : 'gltrans_amount_credit',
2057 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
2060 xtype: 'ColumnModel',
2063 dataIndex : 'gltrans_amount_debit',
2066 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
2069 xtype: 'ColumnModel',
2072 dataIndex : 'gltrans_amount_total',
2075 renderer : function(v) { return String.format('<b>{0}</b>', Roo.util.Format.number(v,3)); }
2078 xtype: 'ColumnModel',
2081 dataIndex : 'gltrans_amount_total_unposted',
2082 header : 'Unposted',
2084 renderer : function(v) { return String.format('<span style="color:red">{0}</span>', Roo.util.Format.number(v,3)); }
2093 activate : function() {
2094 _this.gltxdpanel = this;
2095 if (_this.gltxdgrid) {
2096 _this.gltxdgrid.footer.onClick('first');
2101 fitContainer : true,
2104 tableName : 'invdetail',
2105 title : "invdetail",
2112 _this.gltxdgrid = this;
2113 //_this.dialog = Pman.Dialog.FILL_IN
2114 if (_this.gltxdpanel.active) {
2115 this.footer.onClick('first');
2118 cellclick : function (_self, ri, ci, e)
2121 var deleteSel = function() {
2125 url : baseURL + '/Roo/gltrans',
2129 gltrans_id : rec.data.gltrans_id
2132 success : function() {
2133 rec.set('gltrans_posted', false);
2134 rec.set('gltrans_deleted', true);
2135 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
2136 _this.gltxgrid.footer.onClick('first');
2141 var undeleteSel = function() {
2145 url : baseURL + '/Roo/gltrans',
2149 gltrans_id : rec.data.gltrans_id
2152 success : function() {
2153 rec.set('gltrans_posted', true);
2154 rec.set('gltrans_deleted', false);
2155 rec.set('gltrans_docnumber', rec.data.gltrans_docnumber);
2156 _this.gltxgrid.footer.onClick('first');
2162 var di = this.colModel.config[ci].dataIndex;
2163 if (di != 'gltrans_posted') {
2169 var rec = this.ds.getAt(ri);
2170 if (rec.data.gltrans_deleted) {
2172 Roo.MessageBox.confirm(
2174 "This should only be used by System Administrators - are you sure you know what you are doing!",
2188 if (!rec.data.gltrans_posted) {
2194 url : baseURL + '/Roo/gltrans',
2198 gltrans_id : rec.data.gltrans_id
2200 success : function (res)
2202 rec.set('gltrans_posted', true);
2203 _this.gltxgrid.footer.onClick('first');
2212 // we have a posted transaction.
2213 // only allow recalled to be deleted..
2214 if (!rec.data.gltrans_notes.match(/(Recall|Ship Order)/)) {
2223 Roo.MessageBox.confirm(
2225 "This should only be used by System Administrators - are you sure you know what you are doing!",
2238 autoExpandColumn : 'gltrans_notes',
2248 render : function (_self)
2250 _this.glvoidshow = _self;
2252 click : function (_self, e)
2254 (function() { _this.gltxgrid.footer.onClick('first'); }).defer(100);
2257 enableToggle : true,
2269 click : function (_self, e)
2272 url : baseURL + '/Roo/Gltrans',
2276 pohead_id : _this.form.findField('pohead_id').getValue(),
2279 success : function() {
2280 _this.gltxpanel.footer.onClick('first');
2295 beforeload : function (_self, o)
2297 o.params.pohead_id = _this.form.findField('pohead_id').getValue();
2298 var s = _this.gltxgrid.selModel.getSelected();
2303 o.params.gltrans_accnt_id = s.data.gltrans_accnt_id;
2304 o.params.gltrans_is_ship = s.data.gltrans_is_ship;
2305 o.params.gltrans_as_summary = s.data.gltrans_as_summary;
2306 o.params._hide_void = _this.glvoidshow.pressed ? 1 : 0;
2312 sortInfo : { field : 'gltrans_docnumber', direction: 'ASC' },
2317 url : baseURL + '/Roo/gltrans.php'
2320 xtype: 'JsonReader',
2322 totalProperty : 'total',
2327 'name': 'invdetail_id',
2331 'name': 'invdetail_transtype',
2335 'name': 'invdetail_invhist_id',
2339 'name': 'invdetail_location_id',
2343 'name': 'invdetail_qty',
2347 'name': 'invdetail_comments',
2351 'name': 'invdetail_qty_before',
2355 'name': 'invdetail_qty_after',
2359 'name': 'invdetail_invcitem_id',
2363 'name': 'invdetail_expiration',
2365 'dateFormat': 'Y-m-d'
2368 'name': 'invdetail_warrpurc',
2370 'dateFormat': 'Y-m-d'
2373 'name': 'invdetail_ls_id',
2380 xtype: 'PagingToolbar',
2383 displayMsg : "Displaying invdetail{0} - {1} of {2}",
2384 emptyMsg : "No invdetail found",
2391 click : function (_self, e)
2393 new Pman.Download( {
2394 grid : _this.gltxdgrid
2405 xtype: 'ColumnModel',
2407 dataIndex : 'gltrans_id',
2411 renderer : function(v) { return String.format('{0}', v ); }
2414 xtype: 'ColumnModel',
2416 dataIndex : 'gltrans_date',
2419 renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
2422 xtype: 'ColumnModel',
2424 dataIndex : 'gltrans_docnumber',
2427 renderer : function(v,x,r) {
2430 if (r.data.gltrans_misc_id > 0 && (r.data.invdetail_id *1) < 1) {
2431 style = ' style="color:red;font-weight:bold"';
2433 if (r.data.gltrans_deleted) {
2434 return String.format('<s'+style+'>{0}</s>', v);
2436 return String.format('<span' + style + '>{0}</span>', v);
2440 xtype: 'ColumnModel',
2442 dataIndex : 'gltrans_source',
2445 renderer : function(v) { return String.format('{0}', v); }
2448 xtype: 'ColumnModel',
2450 dataIndex : 'gltrans_notes',
2453 renderer : function(v) { return String.format('{0}', v); }
2456 xtype: 'ColumnModel',
2459 dataIndex : 'gltrans_amount',
2462 renderer : function(v) { return String.format('{0}', Roo.util.Format.number(v,3)); }
2465 xtype: 'ColumnModel',
2467 dataIndex : 'gltrans_posted',
2470 renderer : function(v,x,r) {
2472 var state = v ? '-checked' : '';
2474 return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
2482 xtype: 'LayoutRegion',
2486 xtype: 'LayoutRegion',
2495 xtype: 'LayoutRegion',
2497 alwaysShowTabs : true,
2498 tabPosition : 'top',
2513 var hid = _this.form.findField('pohead_id').getValue();
2516 Roo.MessageBox.alert("Error", "Please save your purchase order first");
2522 _dialog.layout.showPanel(1);
2529 var doit = function () {
2539 cls : 'x-btn-text-icon',
2540 text : "Download Purchase Order Items (Excel)",
2541 icon : rootURL + '/Pman/templates/images/save.gif'
2547 render : function (_self)
2549 _this.uploadBtn = _self;
2552 text : "Upload Purchase Order",
2561 click : function (_self, e)
2563 var hid = _this.form.findField('pohead_id').getValue();
2566 Roo.MessageBox.alert("Error", "Please save your purchase order first");
2569 Pman.Dialog.Image.show(
2572 _url : baseURL+'/Xtuple/Import/PurchaseOrder?' + Roo.urlEncode({'pohead_id' : hid})
2577 _this.grid.footer.onClick('first');
2579 Roo.MessageBox.alert("Notice", 'UPLOADED');
2584 text : "Upload Standard Excel"
2590 click : function (_self, e)
2593 var hid = _this.form.findField('pohead_id').getValue();
2596 Roo.MessageBox.alert("Error", "Please save your purchase order first");
2600 Pman.Dialog.Image.show(
2602 _url : baseURL+'/Xtuple/Import/AUPurchaseOrder?' + Roo.urlEncode({'pohead_id' :hid})
2607 _this.grid.footer.onClick('first');
2609 Roo.MessageBox.alert("Notice", 'IMPORTED');
2614 text : "Upload AU Import Excel"
2627 click : function (_self, e)
2629 _this.dialog.hide();
2638 click : function (_self, e)
2643 _this.grid.ds.each(function(r) {
2645 poitem_id : r.data.poitem_id,
2646 poitem_itemsite_id : r.data.poitem_itemsite_id,
2647 poitem_unitprice : r.data.poitem_unitprice,
2648 poitem_qty_ordered : r.data.poitem_qty_ordered
2653 _this.form.findField('items').setValue(JSON.stringify(ar));
2656 _this.form.doAction("submit");
2659 render : function (_self)
2661 _this.saveBtn = _self;