Sourced wnframework-modules from Google Code as erpnext

This commit is contained in:
Pratik Vyas
2011-06-08 14:37:15 +05:30
commit c1e6e4c752
1680 changed files with 162635 additions and 0 deletions

View File

View File

@@ -0,0 +1,2 @@
<div id="trash_header">&nbsp;</div>
<div id="trash_div" style="margin: 0px;">&nbsp;</div>

128
tools/page/trash/trash.js Normal file
View File

@@ -0,0 +1,128 @@
pscript['onload_Trash'] = function() {
// header and toolbar
var h = new PageHeader('trash_header','Trash Bin','Restore the documents that you have trashed')
if(!pscript.trash_bin) pscript.trash_bin = new pscript.Trash();
}
pscript.Trash = function() {
// create UI elements
this.wrapper = $i('trash_div');
this.head = $a(this.wrapper, 'div');
this.body = $a(this.wrapper, 'div');
$y(this.body, {margin:'8px'})
this.make_head();
this.load_masters();
}
// Make Button
// ------------
pscript.Trash.prototype.make_button = function(label, area){
var me = this;
var w = $a(area, 'div', '', {margin:'8px'});
var t = make_table(w,1,1,'400px',['50%','50%']);
var s = $a($td(t,0,0),'button');
s.innerHTML = label;
s.wrapper = w;
return s;
}
// Make Head
// -------------
pscript.Trash.prototype.make_head = function() {
var me = this;
var make_select = function(label) {
var w = $a(me.head, 'div', '', {margin:'8px'});
var t = make_table(w,1,2,'400px',['50%','50%']);
$td(t,0,0).innerHTML = label;
var s = $a($td(t,0,1),'select','',{width:'140px'});
s.wrapper = w;
return s;
}
// Select Master Name
this.master_select = make_select('Select Master');
var me = this;
// Get Records
this.get_records_button = me.make_button('Get Records', me.head);
this.get_records_button.onclick = function() {
me.get_records();
}
}
// Load Masters
// -------------
pscript.Trash.prototype.load_masters = function(){
var me = this;
var callback = function(r, rt){
// Masters
empty_select(me.master_select);
add_sel_options(me.master_select,add_lists(['All'], r.message), 'All');
}
$c_obj('Trash Control','get_masters','',callback);
}
// Get Records
// -----------
pscript.Trash.prototype.get_records = function(){
var me = this;
me.body.innerHTML = '';
var callback = function(r, rt){
if(r.message) me.generate_trash_records(r.message);
else msgprint("No Records Found");
}
$c_obj('Trash Control','get_trash_records',sel_val(me.master_select),callback);
}
// Generate Trash Records
// -----------------------
pscript.Trash.prototype.generate_trash_records = function(rec_dict){
var me = this;
pscript.all_checkboxes = [];
mnames = keys(rec_dict).sort();
for(var i = 0; i < mnames.length; i ++){
var head = $a(me.body, 'h3'); head.innerHTML = mnames[i];
var rec_table = make_table(me.body,rec_dict[mnames[i]].length,2,'375px',['350px','25px'],{border:'1px solid #AAA',padding:'2px'});
for(var j = 0; j < rec_dict[mnames[i]].length; j++){
$a_input($td(rec_table,j,0), 'data');
$td(rec_table,j,0).innerHTML = rec_dict[mnames[i]][j];
var chk = $a_input($td(rec_table,j,1), 'checkbox');
chk.master = mnames[i];
chk.record = rec_dict[mnames[i]][j];
pscript.all_checkboxes.push(chk);
}
}
this.restore_button = me.make_button('Restore Selected', me.body);
this.restore_button.onclick = function() {
me.restore_records(0);
}
this.restore_all_button = me.make_button('Restore All', me.body);
this.restore_all_button.onclick = function() {
me.restore_records(1);
}
}
// Restore Records
// ---------------
pscript.Trash.prototype.restore_records = function(restore_all){
var me = this;
var out = {};
for(i in pscript.all_checkboxes) {
c = pscript.all_checkboxes[i];
if (restore_all || (!restore_all && c.checked)) {
if(!out[c.master]) out[c.master] = [c.record];
else {out[c.master].push(c.record);}
}
}
$c_obj('Trash Control','restore_records',JSON.stringify(out),function(r, rt){me.get_records();})
}

View File

@@ -0,0 +1 @@
[{'creation': '2010-04-17 14:36:24', 'module': 'Tools', 'doctype': 'Page', 'owner': 'Administrator', 'style': None, 'modified_by': 'saumil@webnotestech.com', 'script': None, 'show_in_menu': 0, 'content': None, 'page_name': 'Trash', 'menu_index': None, 'docstatus': 0, 'parent': None, 'standard': 'Yes', 'icon': None, 'name': 'Trash', 'idx': None, 'static_content': None, 'modified': '2010-09-25 00:00:00', 'parenttype': None, 'parent_node': None, 'parentfield': None}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000122', 'parent': 'Trash', 'creation': '2010-04-19 10:03:20', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 1, 'parenttype': 'Page', 'role': 'Administrator', 'owner': 'Administrator', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000123', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 2, 'parenttype': 'Page', 'role': 'Sales Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000124', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 3, 'parenttype': 'Page', 'role': 'Material Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000125', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 4, 'parenttype': 'Page', 'role': 'Purchase Master Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}, {'modified_by': 'saumil@webnotestech.com', 'name': 'PR000126', 'parent': 'Trash', 'creation': '2010-04-21 10:33:38', 'modified': '2010-09-16 16:50:16', 'doctype': 'Page Role', 'idx': 5, 'parenttype': 'Page', 'role': 'Accounts Manager', 'owner': 'saumil@webnotestech.com', 'docstatus': 0, 'parentfield': 'roles'}]