<?/*
Copyright (C) 2003 Media Net Link, Inc. Danville, CA 94526 USA

This file is part of AthenaRMS.

AthenaRMS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

AthenaRMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/?>
<div class="athenatitleshadow">Edit RMS Settings<div class="athenatitle">Edit RMS Settings</div></div>
<br />
<?php
  $crm_id = $REMOTE_USER_CRM_ID;

  require_once "crm.php";
  require_once "problem_type.php";
  require_once "source.php";
  require_once "person.php";
  require_once 'server_functions.php';

  globalize_request_keys('crm_name');

  $crm = new CRM ();
  $pt = new Problem_Type ();
  $src = new Source ();
  $person = new Person ();

  $crm_r = $crm->Select_by_CRM_ID ($crm_id);
  if (!$crm_r->Get('crm_name')) die($crm_r->error);

  if ($crm_name) {
    foreach (array (
      'default_problem_id',
      'default_source_id',
      'email_source_id',
      'default_support_person_id',
      'default_escalated_to_id',
      'crm_name',
      'crm_short_name',
      'email_domain',
      'web_domain',
      'web_path',
      'users_url',
      'email_sig',
      'backup_email',
      'extended_email_sig',
      'new_ticket_notify',
      'confirmation_url',
    ) as $set) {
      $crm_r->Set ($set, $_REQUEST[$set]);
    }

    foreach (array('email_domain','web_domain') as $set) {
      $crm_r->Set( $set, strtolower($crm_r->Get($set)) );
    }

    if (!$crm_r->Update ()) die('edit_crm: ' . $crm_r->error);
  }

  $pt_dd = $pt->Multi_Array_Drop_Down ($pt->List_All (), $crm_r->Get('default_problem_id'));
  $src_dd = $src->Multi_Array_Drop_Down ($src->List_All (), $crm_r->Get ('default_source_id'));
  $em_src_dd = $src->Multi_Array_Drop_Down ($src->List_All (), $crm_r->Get ('email_source_id'));
  $supp_dd = $person->Multi_Array_Drop_Down ($person->List_By ('Support', 3, '', ''), $crm_r->Get ('default_support_person_id'));
  $esc_dd = $person->Multi_Array_Drop_Down ($person->List_By ('Escalated Support', 3, '', ''), $crm_r->Get ('default_escalated_to_id'));

  require_once "dd.php";
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<table border="0">
<tr>
  <td class="text">RMS Name</td>
  <td class="text"><input type="text" name="crm_name" value="<?php echo $crm_r->Get('crm_name'); ?>" /></td>
</tr>
<tr>
  <td class="text">RMS Short Name</td>
  <td class="text"><input type="text" name="crm_short_name" value="<?php echo $crm_r->Get('crm_short_name'); ?>" /></td>
</tr>
<tr>
  <td class="text">Default Problem</td>
  <td class="text"><select name="default_problem_id"><?php echo $pt_dd; ?></select> <a href="edit_problems">edit/add</a></td>
</tr>
<tr>
  <td class="text">Default Source</td>
  <td class="text"><select name="default_source_id"><?php echo $src_dd; ?></select> <a href="edit_sources">edit/add</a></td>
</tr>
<tr>
  <td class="text">Default Email Source</td>
  <td class="text"><select name="email_source_id"><?php echo $em_src_dd; ?></select> <a href="edit_sources">edit/add</a></td>
</tr>
<tr>
  <td class="text">Default Support Person</td>
  <td class="text"><select name="default_support_person_id"><?php echo $supp_dd; ?></select> <a href="person_edit">edit/add</a></td>
</tr>
<tr>
  <td class="text">Default Escalated Person</td>
  <td class="text"><select name="default_escalated_to_id"><?php echo $esc_dd; ?></select> <a href="person_edit">edit/add</a></td>
</tr>
<tr>
  <td class="text">Email Domain</td>
  <td class="text"><input type="text" name="email_domain" value="<?php echo $crm_r->Get('email_domain'); ?>" /></td>
</tr>
<tr>
  <td class="text">Web Domain</td>
  <td class="text"><input type="text" name="web_domain" value="<?php echo $crm_r->Get('web_domain'); ?>" /></td>
</tr>
<tr>
  <td class="text">Web Path</td>
  <td class="text"><input type="text" name="web_path" value="<?php echo $crm_r->Get('web_path'); ?>" /></td>
</tr>
<!--
<tr>
  <td class="text">crypt key</td>
  <td class="text"><?php echo $crm_r->Get('key'); ?></td>
</tr>
-->
<tr>
  <td class="text">Users URL</td>
  <td class="text"><input type="text" name="users_url" value="<?php echo $crm_r->Get('users_url'); ?>" /></td>
</tr>
<tr>
  <td class="text">Email Signature</td>
  <td class="text"><input type="text" name="email_sig" value="<?php echo $crm_r->Get('email_sig'); ?>" /></td>
</tr>
<tr>
  <td class="text">Extended Email Signature</td>
  <td class="text"><textarea name="extended_email_sig" rows="6" cols="58"><?php echo $crm_r->Get('extended_email_sig'); ?></textarea></td>
</tr>
<tr>
  <td class="text">Confirmation URL</td>
  <td class="text"><input type="text" name="confirmation_url" value="<?php echo $crm_r->Get('confirmation_url'); ?>" /></td>
</tr>
<tr>
  <td class="text">Backup Email</td>
  <td class="text"><input type="text" name="backup_email" value="<?php echo $crm_r->Get('backup_email'); ?>" /></td>
</tr>
<tr>
  <td class="text">New Ticket Notification</td>
  <td class="text"><select name="new_ticket_notify"><?php echo $dd->yes_no ($crm_r->Get ('new_ticket_notify')); ?></select></td>
</tr>
</table>

<input type="submit" name="submit" value="Submit" />

</form>
