webERP Forum
Change Supplier Code Missing Fields - SOLVED? - Printable Version

+- webERP Forum (http://www.weberp.org/forum)
+-- Forum: webERP Discussion (http://www.weberp.org/forum/forumdisplay.php?fid=1)
+--- Forum: Problems / Bugs? (http://www.weberp.org/forum/forumdisplay.php?fid=8)
+--- Thread: Change Supplier Code Missing Fields - SOLVED? (/showthread.php?tid=8300)



Change Supplier Code Missing Fields - SOLVED? - VortecCPI - 12-13-2018

Z_ChangeSupplierCode.php

This script is missing the following fields:

+ url
+ defaultshipper
+ defaultgl

I think this should do it:

PHP Code:
$sql "INSERT INTO suppliers (`supplierid`,
        `suppname`,  `address1`, `address2`, `address3`,
        `address4`,  `address5`,  `address6`, `supptype`, `lat`, `lng`,
        `currcode`,  `suppliersince`, `paymentterms`, `lastpaid`,
        `lastpaiddate`, `bankact`, `bankref`, `bankpartics`,
        `remittance`, `taxgroupid`, `factorcompanyid`, `taxref`,
        `phn`, `port`, `email`, `fax`, `telephone`, `url`,
        `defaultshipper`, `defaultgl`)
    SELECT '" 
$newCode "',
        `suppname`,  `address1`, `address2`, `address3`,
        `address4`,  `address5`,  `address6`, `supptype`, `lat`, `lng`,
        `currcode`,  `suppliersince`, `paymentterms`, `lastpaid`,
        `lastpaiddate`, `bankact`, `bankref`, `bankpartics`,
        `remittance`, `taxgroupid`, `factorcompanyid`, `taxref`,
        `phn`, `port`, `email`, `fax`, `telephone`, `url`,
        `defaultshipper`, `defaultgl`
        FROM suppliers WHERE supplierid='" 
$oldCode "'"



RE: Change Supplier Code Missing Fields - SOLVED? - TimSchofield - 12-13-2018

Why don't we do something like:
PHP Code:
DB_IgnoreForeignKeys()
$Result DB_query("UPDATE suppliers SET supplierid='" $NewCode "' WHERE supplierid='" $OldCode "'");

.....

DB_ReinstateForeignKeys() 

Gets rid of the need for developers to remember this script when adding a new field to the suppliers table.

Tim


RE: Change Supplier Code Missing Fields - SOLVED? - VortecCPI - 12-13-2018

Agreed. Very simple and elegant solution in my opinion. Also eliminates any maintenance issues due to extensions.