Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add scripts to help link the weberp and care2x insurance companies
- Loading branch information
1 parent
f0265b3
commit ab6179f
Showing
4 changed files
with
301 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,266 @@ | ||
<?php | ||
/* $Id$*/ | ||
/*Script to Delete all sales transactions*/ | ||
|
||
include ('includes/session.inc'); | ||
$title = _('Changes an Insurance Company Code In All Tables'); | ||
include('includes/header.inc'); | ||
|
||
if (isset($_POST['ProcessCustomerChange'])){ | ||
|
||
/*First check the customer code exists */ | ||
$result=DB_query("SELECT debtorno FROM debtorsmaster WHERE debtorno='" . $_POST['OldDebtorNo'] . "'",$db); | ||
if (DB_num_rows($result)==0){ | ||
prnMsg ('<br /><br />' . _('The customer code') . ': ' . $_POST['OldDebtorNo'] . ' ' . _('does not currently exist as a customer code in the system'),'error'); | ||
include('includes/footer.inc'); | ||
exit; | ||
} | ||
|
||
|
||
if ($_POST['NewDebtorNo']==''){ | ||
prnMsg(_('The new customer code to change the old code to must be entered as well'),'error'); | ||
include('includes/footer.inc'); | ||
exit; | ||
} | ||
/*Now check that the new code doesn't already exist */ | ||
$result=DB_query("SELECT debtorno FROM debtorsmaster WHERE debtorno='" . $_POST['NewDebtorNo'] . "'",$db); | ||
if (DB_num_rows($result)!=0){ | ||
prnMsg(_('The replacement customer code') .': ' . $_POST['NewDebtorNo'] . ' ' . _('already exists as a customer code in the system') . ' - ' . _('a unique customer code must be entered for the new code'),'error'); | ||
include('includes/footer.inc'); | ||
exit; | ||
} | ||
|
||
$result = DB_Txn_Begin($db); | ||
|
||
prnMsg(_('Inserting the new debtors master record'),'info'); | ||
$sql = "INSERT INTO debtorsmaster (`debtorno`, | ||
`name`, | ||
`address1`, | ||
`address2`, | ||
`address3`, | ||
`address4`, | ||
`currcode`, | ||
`salestype`, | ||
`clientsince`, | ||
`holdreason`, | ||
`paymentterms`, | ||
`discount`, | ||
`discountcode`, | ||
`pymtdiscount`, | ||
`lastpaid`, | ||
`lastpaiddate`, | ||
`creditlimit`, | ||
`invaddrbranch`, | ||
`ediinvoices`, | ||
`ediorders`, | ||
`edireference`, | ||
`editransport`, | ||
`ediaddress`, | ||
`ediserveruser`, | ||
`ediserverpwd`, | ||
`typeid`) | ||
SELECT '" . $_POST['NewDebtorNo'] . "', | ||
`name`, | ||
`address1`, | ||
`address2`, | ||
`address3`, | ||
`address4`, | ||
`currcode`, | ||
`salestype`, | ||
`clientsince`, | ||
`holdreason`, | ||
`paymentterms`, | ||
`discount`, | ||
`discountcode`, | ||
`pymtdiscount`, | ||
`lastpaid`, | ||
`lastpaiddate`, | ||
`creditlimit`, | ||
`invaddrbranch`, | ||
`ediinvoices`, | ||
`ediorders`, | ||
`edireference`, | ||
`editransport`, | ||
`ediaddress`, | ||
`ediserveruser`, | ||
`ediserverpwd`, | ||
`typeid` | ||
FROM debtorsmaster | ||
WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$DbgMsg =_('The SQL that failed was'); | ||
$ErrMsg = _('The SQL to insert the new debtors master record failed') . ', ' . _('the SQL statement was'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg(_('Inserting new customer branch records'),'info'); | ||
$sql = "INSERT INTO custbranch ( `branchcode`, | ||
`debtorno`, | ||
`brname`, | ||
`braddress1`, | ||
`braddress2`, | ||
`braddress3`, | ||
`braddress4`, | ||
`braddress5`, | ||
`braddress6`, | ||
`estdeliverydays`, | ||
`area`, | ||
`salesman`, | ||
`fwddate`, | ||
`phoneno`, | ||
`faxno`, | ||
`contactname`, | ||
`email`, | ||
`defaultlocation`, | ||
`taxgroupid`, | ||
`disabletrans`, | ||
`brpostaddr1`, | ||
`brpostaddr2`, | ||
`brpostaddr3`, | ||
`brpostaddr4`, | ||
`brpostaddr5`, | ||
`brpostaddr6`, | ||
`defaultshipvia`, | ||
`custbranchcode`) | ||
SELECT branchcode, | ||
'" . $_POST['NewDebtorNo'] . "', | ||
`brname`, | ||
`braddress1`, | ||
`braddress2`, | ||
`braddress3`, | ||
`braddress4`, | ||
`braddress5`, | ||
`braddress6`, | ||
`estdeliverydays`, | ||
`area`, | ||
`salesman`, | ||
`fwddate`, | ||
`phoneno`, | ||
`faxno`, | ||
`contactname`, | ||
`email`, | ||
`defaultlocation`, | ||
`taxgroupid`, | ||
`disabletrans`, | ||
`brpostaddr1`, | ||
`brpostaddr2`, | ||
`brpostaddr3`, | ||
`brpostaddr4`, | ||
`brpostaddr5`, | ||
`brpostaddr6`, | ||
`defaultshipvia`, | ||
`custbranchcode` | ||
FROM custbranch | ||
WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to insert new customer branch records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
prnMsg(_('Changing debtor transaction records'),'info'); | ||
|
||
$sql = "UPDATE debtortrans SET debtorNo='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update debtor transaction records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg(_('Changing sales analysis records'),'info'); | ||
|
||
$sql = "UPDATE salesanalysis SET cust='" . $_POST['NewDebtorNo'] . "' WHERE cust='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update Sales Analysis records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg (_('Changing order delivery differences records'),'info'); | ||
$sql = "UPDATE orderdeliverydifferenceslog SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
$ErrMsg = _('The SQL to update order delivery differences records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
|
||
prnMsg(_('Changing pricing records'),'info'); | ||
$sql = "UPDATE prices SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update the pricing records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg(_('Changing sales orders records'),'info'); | ||
$sql = "UPDATE salesorders SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update the sales order header records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg( _('Changing stock movement records'),'info'); | ||
$sql = "UPDATE stockmoves SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
$ErrMsg = _('The SQL to update the sales order header records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg(_('Changing user default customer records'),'info'); | ||
$sql = "UPDATE www_users SET customerid='" . $_POST['NewDebtorNo'] . "' WHERE customerid='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update the user records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
prnMsg(_('Changing the customer code in contract header records'),'info'); | ||
$sql = "UPDATE contracts SET debtorno='" . $_POST['NewDebtorNo'] . "' WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to update contract header records failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
$result = DB_IgnoreForeignKeys($db); | ||
|
||
prnMsg(_('Deleting the old customer branch records from the CustBranch table'),'info'); | ||
$sql = "DELETE FROM custbranch WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
$ErrMsg = _('The SQL to delete the old CustBranch records for the old debtor record failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
|
||
prnMsg(_('Deleting the customer code from the DebtorsMaster table'),'info'); | ||
$sql = "DELETE FROM debtorsmaster WHERE debtorno='" . $_POST['OldDebtorNo'] . "'"; | ||
|
||
$ErrMsg = _('The SQL to delete the old debtor record failed'); | ||
$result = DB_query($sql,$db,$ErrMsg,$DbgMsg,true); | ||
|
||
|
||
$result = DB_Txn_Commit($db); | ||
$result = DB_ReinstateForeignKeys($db); | ||
|
||
} | ||
|
||
echo '<form action="' . htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, 'UTF-8') . '" method="post">'; | ||
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />'; | ||
echo '<p class="page_title_text"><img src="'.$rootpath.'/css/'.$theme.'/images/customer.png" title="' . _('Customer') . '" alt="" />' . ' ' . $title . '</p>'; | ||
|
||
$sql="SELECT debtorno, name FROM debtorsmaster WHERE debtorno not like '10%'"; | ||
$result = DB_query($sql, $db); | ||
echo '<br /><table class="selection">'; | ||
echo '<tr><td>' . _('Existing Debtor Code') . ':</td>'; | ||
echo '<td><select name="OldDebtorNo">'; | ||
echo '<option value=""></option>'; | ||
while ($myrow=DB_fetch_array($result)) { | ||
if (ctype_alpha($myrow['debtorno'][0])) { | ||
echo '<option value="' . $myrow['debtorno'] . '">' . $myrow['debtorno'] . ' - ' . $myrow['name'] . '</option>'; | ||
} | ||
} | ||
echo '</select></td></tr>'; | ||
|
||
$sql = "SELECT id, | ||
name | ||
FROM ".$_SESSION['Care2xDatabase'].".care_tz_company"; | ||
$result = DB_query($sql, $db); | ||
echo '<tr> | ||
<td>' . _('Insurance Company From Care2x') . ':</td> | ||
<td><select tabindex="1" name="NewDebtorNo">'; | ||
echo '<option value=""></option>'; | ||
while ($myrow=DB_fetch_array($result)) { | ||
$CheckSQL="SELECT debtorno FROM debtorsmaster WHERE debtorno='" . $myrow['id'] . "'"; | ||
$CheckResult=DB_query($CheckSQL, $db); | ||
if (DB_num_rows($CheckResult)==0) { | ||
echo '<option value="' . $myrow['id'] . '">' . $myrow['id'] . ' - ' . $myrow['name'] . '</option>'; | ||
} | ||
} | ||
echo '</select></td></tr></table>'; | ||
|
||
echo '<br /><div class="centre"><button type="submit" name="ProcessCustomerChange">' . _('Process') . '</button></div>'; | ||
|
||
echo '</form>'; | ||
|
||
include('includes/footer.inc'); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
/* Include the new script for printing quotations in Portrait | ||
*/ | ||
|
||
InsertRecord('pagesecurity', array('script', 'security'), array('Z_ChangeInsuranceCompanyCode.php',1), array('script', 'security'), array('Z_ChangeInsuranceCompanyCode.php',1), $db); | ||
|
||
UpdateDBNo(121, $db); | ||
|
||
?> |