I've wrote a mod that should work for you. It would use the normal open page for osticket. I basically added a new tab in the admin page called clients. You can add, update, and delete client information in the tab. I have attached the two new files for the tab. Its not the prettiest code, but from the testing I did, it works.
include/staff/client.inc.php (see attachments)
include/staff/clients.inc.php (see attachments)
in include/class.nav.php ~ line 35 ADD
$tabs=array('desc'=>'Clients','href'=>'admin.php?t=clients','title'=>'Clients');
in main.inc.php ~ line 107 AFTER
define('TOPIC_TABLE',TABLE_PREFIX.'help_topic');
define('GROUP_TABLE',TABLE_PREFIX.'groups');
ADD
define('CLIENT_TABLE',TABLE_PREFIX.'clients');
in scp/admin.php ~ line 719 AFTER
break;
default:
$errors='Unknown Dept action';
}
break;
ADD
case 'clients':
$page2 = 'client.inc.php';
$firstname = strip_tags($_POST);
$lastname = strip_tags($_POST);
$email = strip_tags($_POST);
$phone = eregi_replace("","",strip_tags($_POST));
$phone_ext = strip_tags($_POST);
$mobile = eregi_replace("","",strip_tags($_POST));
$company = strip_tags($_POST);
$client_id = strip_tags($_POST);
$delete = $_POST;
if(!$_POST) $errors = "First name required. ";
if(!$_POST) $errors = " Last name required. ";
$phone_length = strlen((string)$phone);
$tmp = "(";
for($j=0; $j<$phone_length; $j++) {
if(ctype_digit($phone)) $tmp .= $phone;
}
if((int)strlen($tmp)>11||(int)strlen($tmp)<(int)11) $errors = "Phone# (xxx)xxx-xxxx ";
else for($k=0; $k<11; $k++) {
if($k==4) $phone .= ")";
if($k==7) $phone .= "-";
if($k==0) $phone = $tmp;
else $phone .= $tmp;
}
if($mobile) {
$mobile_length = strlen((string)$mobile);
$tmp = "(";
for($j=0; $j<$mobile_length; $j++) {
if(ctype_digit($mobile)) $tmp .= $mobile;
}
for($k=0; $k<11; $k++) {
if($k==4) $mobile .= ")";
if($k==7) $mobile .= "-";
if($k==0) $mobile = $tmp;
else $mobile .= $tmp;
}
}
if($_POST=="update" && !$errors) {
$query = "UPDATE ".CLIENT_TABLE." SET firstname = '$firstname', lastname = '$lastname', email = '$email', phone = '$phone', phone_ext = '$phone_ext', mobile = '$mobile', company = '$company' WHERE client_id = '$client_id'";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Updated';
}
else $msg = "Client update failed.";
}
if($_POST=="new" && !$errors) {
$query = "INSERT INTO ".CLIENT_TABLE." (firstname, lastname, email, phone, phone_ext, mobile, company) VALUES ('$firstname', '$lastname', '$email', '$phone', '$phone_ext', '$mobile', '$company')";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Created';
}
else $msg = "Client creation failed.";
}
if($_POST=="delete") {
$delete_count = count($delete);
for($i=0; $i<$delete_count; $i++) {
$client_id = strip_tags($delete);
$query = "DELETE FROM ".CLIENT_TABLE." WHERE '$client_id' LIKE client_id";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Deleted';
}
else $msg = "Client deletion failed.";
}
}
break;
If you don't want the phone number validation, us this instead
case 'clients':
$page2 = 'client.inc.php';
$firstname = strip_tags($_POST);
$lastname = strip_tags($_POST);
$email = strip_tags($_POST);
$phone = eregi_replace("","",strip_tags($_POST));
$phone_ext = strip_tags($_POST);
$mobile = eregi_replace("","",strip_tags($_POST));
$company = strip_tags($_POST);
$client_id = strip_tags($_POST);
$delete = $_POST;
if(!$_POST) $errors = "First name required. ";
if(!$_POST) $errors = " Last name required. ";
if($_POST=="update" && !$errors) {
$query = "UPDATE ".CLIENT_TABLE." SET firstname = '$firstname', lastname = '$lastname', email = '$email', phone = '$phone', phone_ext = '$phone_ext', mobile = '$mobile', company = '$company' WHERE client_id = '$client_id'";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Updated';
}
else $msg = "Client update failed.";
}
if($_POST=="new" && !$errors) {
$query = "INSERT INTO ".CLIENT_TABLE." (firstname, lastname, email, phone, phone_ext, mobile, company) VALUES ('$firstname', '$lastname', '$email', '$phone', '$phone_ext', '$mobile', '$company')";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Created';
}
else $msg = "Client creation failed.";
}
if($_POST=="delete") {
$delete_count = count($delete);
for($i=0; $i<$delete_count; $i++) {
$client_id = strip_tags($delete);
$query = "DELETE FROM ".CLIENT_TABLE." WHERE '$client_id' LIKE client_id";
if(mysql_query($query)) {
$page2='clients.inc.php';
$msg = 'Client Deleted';
}
else $msg = "Client deletion failed.";
}
}
break;
in scp/admin.php ~ line 916 AFTER
$page=($dept or ($_REQUEST=='new' && !$deptID))?'dept.inc.php':'depts.inc.php';
$nav->setTabActive('depts');
$nav->addSubMenu(array('desc'=>'Departments','href'=>'admin.php?t=depts','iconclass'=>'departments'));
$nav->addSubMenu(array('desc'=>'Add New Dept.','href'=>'admin.php?t=depts&a=new','iconclass'=>'newDepartment'));
break;
ADD
case 'client':
case 'clients':
$clients = null;
$nav->setTabActive('clients'); $nav->addSubMenu(array('desc'=>'Clients','href'=>'admin.php?t=clients','iconclass'=>'departments'));
$nav->addSubMenu(array('desc'=>'Add New Client','href'=>'admin.php?t=clients&a=new','iconclass'=>'newDepartment'));
$page = $page2;
if($_GET=="update" || $_GET=="new") $page='client.inc.php';
if(!$_GET&&!$_POST&&!$page) $page='clients.inc.php';
break;
That should do it for the backend side, now we just need to make it work for the open.php and open.inc.php
I made a drop down when I first installed osticket that referenced the staff list (we use it internally) so I am not sure what the original code was.
in include/client/open.inc.php ~ line 23 CHANGE
Full Name:
Select One
<? $services= db_query('SELECT firstname,lastname,company FROM '.CLIENT_TABLE.' ORDER BY firstname');
while (list($firstname,$lastname,$company) = db_fetch_row($services)){?>
<?=$lastname?>" <?
if($_POST==$company.'-'.$firstname." ".$lastname) echo 'selected="selected"';
?>><?=
$company?>-<?=$firstname?> <?=$lastname?>
<? } ?>
* <?=$errors?>
I then deleted the rows for email, and phone number.
In open.php ~ line 24 AFTER
if($_POST):
$_POST=$_POST=0; //Just Making sure we don't accept crap...only topicId is expected.
//Ticket:...checks for errors..
ADD
$tmp_name = $_POST;
$services= mysql_query("SELECT email, phone FROM ".CLIENT_TABLE." WHERE concat(firstname,' ',lastname) LIKE '$tmp_name' ORDER BY firstname") or die("the query returned an error: " . mysql_error());
list($email,$phone) = db_fetch_row($services);
$_POST=$email;
$_POST=$phone;
The above part adds in the variables after a name has been selected, but before errors are checked.
[client.inc.php.txt](https://forum.osticket.com/assets/files/migrated/e/71144fdefd328c06801580449e65636.txt)
[clients.inc.php.txt](https://forum.osticket.com/assets/files/migrated/8/ce35512eae6fdb3b92280e89b87b02a.txt)