<? include('includes/main.php'); ?>
<? include('includes/arfunctions.php'); ?>
<script language="JavaScript" src="js/validatephone.js">
</script>
<script language="JavaScript">
function checkChoice(i) {
if (document.mainform.salesman.checked == false) {
if (document.mainform.servicerep.checked == false) {
if (i=="1") {
document.mainform.servicerep.checked = true;
} else {
document.mainform.salesman.checked = true;
}
}
}
}
</script>
<?
echo texttitle(STR_SALES_PERSONNEL_UPDATE);
if ($id) { //if sales person selected
if ($delete) { //if sales person should be deleted
$conn->BeginTrans();
if (arcompanydelete($id)&&arsalesmandelete($id)) {
$conn->CommitTrans();
die(); //OK
};
$conn->RollbackTrans();
} elseif ($name) { //if sales person should be updated
$conn->BeginTrans();
if (arcompanyupdate($id, $address1, $address2, $city, $state, $zip, $country, $phone1, $phone1comment, $phone2, $phone2comment, $phone3, $phone3comment, $phone4, $phone4comment, $email1, $email1comment, $email2, $email2comment, $website, $federalid, $name, $mailstop, $lastchangedate)&&arsalesmanupdate($id, $payrollid, $commissionrate, $commissionbase, $servicerep, $salesman)) {
$conn->CommitTrans();
} else {
$conn->RollbackTrans();
};
};
//edit sales person
echo '<form action="adminarsalesmanupd.php" method="post" name="mainform"><input type="hidden" name="nonprintable" value="1"><table>';
echo '<input type="hidden" name="id" value="'.$id.'">';
formarsalesmanupdate($id);
echo '</table><input type="submit" value="'.STR_SAVE_CHANGES.'"></form><a href="javascript:confirmdelete(\'adminarsalesmanupd.php?delete=1&id='.$id.'\')">'.STR_DELETE_THIS_SALESPERSON.'</a>';
} else { //select sales person
echo '<form action="adminarsalesmanupd.php" method="post"><table>';
if (formarsalesmanselect('id')) echo '<input type="submit" value="'.STR_EDIT_SELECTION.'">';
echo '</table></form><a href="adminarsalesmanadd.php">'.STR_ADD_NEW_SALES_PERSON.'</a>';
};
?>
<? include('includes/footer.php'); ?>