Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change Supplier Code Missing Fields - SOLVED?
12-13-2018, 02:23 AM (This post was last modified: 12-13-2018 02:36 AM by VortecCPI.)
Post: #1
Change Supplier Code Missing Fields - SOLVED?
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 "'"

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
12-13-2018, 09:47 PM
Post: #2
RE: Change Supplier Code Missing Fields - SOLVED?
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
Visit this user's website Find all posts by this user
Quote this message in a reply
12-13-2018, 10:16 PM
Post: #3
RE: Change Supplier Code Missing Fields - SOLVED?
Agreed. Very simple and elegant solution in my opinion. Also eliminates any maintenance issues due to extensions.

https://www.linkedin.com/in/eclipsepaulbecker
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 2 Guest(s)