1 select xt.install_js('XM','Contact','xtuple', $$
2 /* Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
3 See www.xm.ple.com/CPAL for the full text of the software license. */
7 XM.Contact.isDispatchable = true,
9 XM.Contact.merge = function(sourceContactId, targetContactId, purge) {
11 sql = "select cntctmerge(src.cntct_id, tgt.cntct_id, $3) AS result " +
12 "from cntct src, cntct tgt " +
13 "where src.cntct_number = $1 " +
14 " and tgt.cntct_number = $2;";
16 if (!data.checkPrivilege("MergeContacts")) {
17 err = "Access denied."
18 } else if (sourceContactId === undefined) {
20 } else if (targetContactId === undefined) {
22 } else if (purge === undefined) {
26 return plv8.execute(sql, [sourceContactId, targetContactId, purge])[0].result;
31 XM.Contact.restore = function(mergeContactId) {
33 sql = "select cntctrestore(cntct_id) AS result from cntct where cntct_number = $1;"
35 data = Object.create(XT.Data);
37 if(!data.checkPrivilege("MergeContacts")) {
38 err = "Access denied."
39 } else if (mergeContactId === undefined) {
43 return plv8.execute(sql, [mergeContactId])[0].result;
48 XM.Contact.used = function(id) {
49 return plv8.execute("select cntctused(cntct_id) AS result from cntct where cntct_number = $1;", [id])[0].result;