home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / addressbook / edit_contact.inc < prev    next >
Text File  |  2004-03-08  |  13KB  |  413 lines

  1. <input type="hidden" name="source_id" value="<?php echo $contact['source_id']; ?>" />
  2. <table border="0" cellpadding="0" cellspacing="0">
  3. <tr>
  4.     <td>
  5.         <?php if (isset($feedback)) echo $feedback; ?>
  6.         <table border=0 cellpadding="2" cellspacing="0">
  7.         <tr>
  8.         <td valign="top">
  9.         <table border="0" cellpadding="0" cellspacing="3">
  10.         <tr>
  11.             <td align="right" nowrap>
  12.             <?php echo $strFirstName; ?>*: 
  13.             </td>
  14.             <td>
  15.             <input type="text" class="textbox"  name="first_name" size="40" value="<?php echo $contact['first_name']; ?>" maxlength="50">
  16.             </td>
  17.         </tr>
  18.         <tr heigth="25">
  19.             <td align="right" nowrap><?php echo $strMiddleName; ?>: </td>
  20.             <td width="100%"><input type="text" class="textbox"  name="middle_name" size="40" maxlength="50" value="<?php echo $contact["middle_name"]; ?>"></td>
  21.         </tr>
  22.         <tr>
  23.             <td align="right" nowrap>
  24.             <?php echo $strLastName; ?>*: 
  25.             </td>
  26.             <td>
  27.             <input type="text" class="textbox"  name="last_name" size="40" value="<?php echo $contact['last_name']; ?>" maxlength="50">
  28.             </td>
  29.         </tr>
  30.         <tr heigth="25">
  31.             <td align="right" nowrap><?php echo $strTitle; ?> / <?php echo $strInitials; ?>: </td>
  32.             <td width="100%"><input type="text" class="textbox"  name="title" size="11" maxlength="10" value="<?php echo $contact['title']; ?>" /> / <input type="text" class="textbox"  name="initials" size="11" maxlength="10" value="<?php echo $contact['initials']; ?>" /></td>
  33.         </tr>
  34.         <tr>
  35.             <td align="right" nowrap><?php echo $strSex; ?>:</td>
  36.             <td>
  37.             <?php
  38.             $radiolist = new radio_list('sex', $contact['sex']);
  39.             $radiolist->add_option('M', 'M', $strSexes['M']);
  40.             echo ' ';
  41.             $radiolist->add_option('F', 'F', $strSexes['F']);
  42.             ?>
  43.             </td>
  44.         </tr>
  45.         <tr>
  46.             <td align="right" nowrap><?php echo $strBirthday; ?>:</td>
  47.             <td>
  48.             <?php
  49.  
  50.             $datepicker->print_date_picker('birthday', $_SESSION['GO_SESSION']['date_format'], $birthday);
  51.             ?>
  52.             </td>
  53.         </tr>
  54.         <tr><td colspan="2"> </td></tr>
  55.         <tr>
  56.             <td align="right" nowrap>
  57.             <?php echo $strAddress; ?>: 
  58.             </td>
  59.             <td>
  60.             <input type="text" class="textbox"  name="address" size="40" value="<?php if(isset($contact['address'])) echo $contact['address']; ?>" maxlength="100">
  61.             </td>
  62.         </tr>
  63.  
  64.         <tr>
  65.             <td align="right" nowrap>
  66.             <?php echo $strZip; ?>: 
  67.             </td>
  68.             <td>
  69.             <input type="text" class="textbox"  name="zip" size="40" value="<?php if(isset($contact['zip'])) echo $contact['zip']; ?>" maxlength="20">
  70.             </td>
  71.         </tr>
  72.         <tr>
  73.             <td align="right" nowrap>
  74.             <?php echo $strCity; ?>: 
  75.             </td>
  76.             <td>
  77.             <input type="text" class="textbox"  name="city" size="40" value="<?php if(isset($contact['city'])) echo $contact['city']; ?>" maxlength="50">
  78.             </td>
  79.         </tr>
  80.  
  81.  
  82.         <tr>
  83.             <td align="right" nowrap>
  84.             <?php echo $strState; ?>: 
  85.             </td>
  86.             <td>
  87.             <input type="text" class="textbox"  name="state" size="40" value="<?php if(isset($contact['state'])) echo $contact['state']; ?>" maxlength="50">
  88.             </td>
  89.         </tr>
  90.  
  91.         <tr>
  92.             <td align="right" nowrap>
  93.             <?php echo $strCountry; ?>: 
  94.             </td>
  95.             <td>
  96.             <input type="text" class="textbox"  name="country" size="40" value="<?php if(isset($contact['country'])) echo $contact['country']; ?>" maxlength="50">
  97.             </td>
  98.         </tr>
  99.         <tr>
  100.             <td colspan="2"> </td>
  101.         </tr>
  102.  
  103.         <tr>
  104.             <td align="right"><?php echo $ab_comment; ?>:</td>
  105.             <td><input type="text" class="textbox"  name="comment" size="40" value="<?php if(isset($contact['comment'])) echo $contact['comment']; ?>" maxlength="50" /></td>
  106.         </tr>
  107.         </table>
  108.         </td>
  109.         <td valign="top">
  110.             <table border="0" cellpadding="0" cellspacing="3">
  111.             <tr>
  112.                 <td align="right" nowrap>
  113.                 <?php echo $strPhone; ?>: 
  114.                 </td>
  115.                 <td>
  116.                 <input type="text" class="textbox"  name="home_phone" size="40" value="<?php if(isset($contact['home_phone'])) echo $contact['home_phone']; ?>" maxlength="20">
  117.                 </td>
  118.             </tr>
  119.             <tr>
  120.                 <td align="right" nowrap>
  121.                 <?php echo $strFax; ?>: 
  122.                 </td>
  123.                 <td>
  124.                 <input type="text" class="textbox"  name="fax" size="40" value="<?php if(isset($contact['fax'])) echo $contact['fax']; ?>" maxlength="20">
  125.                 </td>
  126.             </tr>
  127.             <tr>
  128.                 <td align="right" nowrap>
  129.                 <?php echo $strCellular; ?>: 
  130.                 </td>
  131.                 <td>
  132.                 <input type="text" class="textbox"  name="cellular" size="40" value="<?php if(isset($contact['cellular'])) echo $contact['cellular']; ?>" maxlength="20">
  133.                 </td>
  134.             </tr>
  135.             <?php
  136.             if (isset($val->error["email"]))
  137.             {
  138.             ?>
  139.             <tr>
  140.                 <td colspan="2" class="Error">
  141.                     <?php echo $val->error["email"]; ?>
  142.                 </td>
  143.             </tr>
  144.             <?php } ?>
  145.             <tr>
  146.                 <td align="right" nowrap>
  147.                 <?php echo $strEmail; ?>*: 
  148.                 </td>
  149.                 <td class="small">
  150.                 <input type="text" class="textbox"  name="email" size="40" value="<?php if(isset($contact['email'])) echo $contact['email']; ?>" maxlength="75">
  151.                 </td>
  152.             </tr>
  153.             <tr>
  154.                 <td colspan="2"> </td>
  155.             </tr>
  156.             <tr>
  157.                 <td align="right" nowrap>
  158.                 <?php echo $strCompany; ?>: 
  159.                 </td>
  160.                 <td nowrap>
  161.  
  162.                 <?php
  163.  
  164.                 if ($task == 'search_company')
  165.                 {
  166.                     $contact['company_id'] = "0";
  167.                     $company_results = new dropbox();
  168.                     //$dropbox->add_value(0, $ab_no_company);
  169.  
  170.                     if($ab->search_company(trim($_POST['company_name']), $contact['addressbook_id']))
  171.                     {
  172.                         while($ab->next_record())
  173.                         {
  174.  
  175.                             if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab->f('acl_write')) || $GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab->f('acl_read')))
  176.                             {
  177.                                 if ($contact['company_id'] == 0)
  178.                                 {
  179.                                     $contact['company_id'] = $ab->f('id');
  180.                                 }
  181.                                 $company_results->add_value($ab->f('id'), $ab->f('name'));
  182.                             }
  183.                         }
  184.                     }
  185.  
  186.                     if ($company_results->count_options())
  187.                     {
  188.                         $company_results->print_dropbox('company_id', 0);
  189.                     }else
  190.                     {
  191.                         echo '<input type="text" class="textbox"  name="company_name" size="40" value="'.$ab_no_company_found.'" maxlength="50" />';
  192.                         echo '<input type="hidden"  name="company_id" value="0" />';
  193.                     }
  194.                 }else
  195.                 {
  196.                     $contact['company_name'] = isset($contact['company_name']) ? $contact['company_name'] : '';
  197.                     echo '<input type="hidden"  name="company_id" value="'.$contact['company_id'].'" />';
  198.                     echo '<input type="text" class="textbox"  name="company_name" size="40" value="'.$contact['company_name'].'" maxlength="50"';
  199.  
  200.  
  201.                     if ($contact['company_id'] > 0)
  202.                     {
  203.                         echo 'disabled ';
  204.                     }
  205.                     echo '/>';
  206.                     if ($contact['company_id'] > 0)
  207.                     {
  208.                         echo '<a href="javascript:company_properties()" title="'.$ab_edit_company.'">';
  209.                         echo '<img src="'.$GO_THEME->images['edit'].'" border="0" height="16" width="16" align="absmiddle" style="margin: 2px;" /></a>';
  210.                     }
  211.                 }
  212.  
  213.                 echo '<a href="javascript:search_company()" title="'.$ab_search_company.'">';
  214.                 echo '<img src="'.$GO_THEME->images['magnifier'].'" border="0" height="16" width="16" align="absmiddle" style="margin: 2px;" /></a>';
  215.                 ?>
  216.                 </td>
  217.             </tr>
  218.             <tr>
  219.                 <td align="right" nowrap>
  220.                 <?php echo $strDepartment; ?>: 
  221.                 </td>
  222.                 <td>
  223.                 <input type="text" class="textbox"  name="department" size="40" value="<?php if(isset($contact['department'])) echo $contact['department']; ?>" maxlength="50">
  224.                 </td>
  225.             </tr>
  226.  
  227.             <tr>
  228.                 <td align="right" nowrap>
  229.                 <?php echo $strFunction; ?>: 
  230.                 </td>
  231.                 <td>
  232.                 <input type="text" class="textbox"  name="function" size="40" value="<?php if(isset($contact['function'])) echo $contact['function']; ?>" maxlength="50">
  233.                 </td>
  234.             </tr>
  235.  
  236.  
  237.  
  238.             <tr>
  239.                 <td align="right" nowrap>
  240.                 <?php echo $strWorkphone; ?>: 
  241.                 </td>
  242.                 <td>
  243.                 <input type="text" class="textbox"  name="work_phone" size="40" value="<?php if(isset($contact['work_phone'])) echo $contact['work_phone']; ?>" maxlength="20">
  244.                 </td>
  245.             </tr>
  246.             <tr>
  247.                 <td align="right" nowrap>
  248.                 <?php echo $strWorkFax; ?>: 
  249.                 </td>
  250.                 <td>
  251.                 <input type="text" class="textbox"  name="work_fax" size="40" value="<?php if(isset($contact['work_fax'])) echo $contact['work_fax']; ?>" maxlength="20">
  252.                 </td>
  253.             </tr>
  254.  
  255.             <tr>
  256.                 <td colspan="2"> </td>
  257.             </tr>
  258.             <?php
  259.             echo '<tr><td align="right" nowrap>'.$contacts_color.': </td><td>';
  260.             $contact['color'] = isset($contact['color']) ? $contact['color'] : '000000';
  261.             $color_selector = new color_selector();
  262.             $color_selector->add_color('000000');
  263.             $color_selector->add_color('FF0000');
  264.             $color_selector->add_color('089600');
  265.             $color_selector->add_color('3300FF');
  266.             $color_selector->add_color('FF00FF');
  267.             $color_selector->add_color('FF9900');
  268.             $color_selector->add_color('996600');
  269.             $color_selector->print_color_selector('color', $contact['color']);
  270.             echo '</td></tr>';
  271.  
  272.             //get all writable user addressbooks and add them to a dropdownbox
  273.             $ab->get_subscribed_addressbooks($GO_SECURITY->user_id);
  274.             $subscribed_addressbooks = new dropbox();
  275.             while ($ab->next_record())
  276.             {
  277.                 if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $ab->f('acl_write')))
  278.                 {
  279.                     //remember the first ab that is writable
  280.                     if(!isset($first_writable_ab))
  281.                     {
  282.                         $first_writable_ab = $ab->f('id');
  283.                     }
  284.                     $subscribed_addressbooks->add_value($ab->f('id'), $ab->f('name'));
  285.  
  286.                 }
  287.             }
  288.  
  289.             //get the given addressbook_id
  290.             if ($addressbook_id > 0)
  291.             {
  292.                  $addressbook = $ab->get_addressbook($addressbook_id);
  293.             }
  294.  
  295.             //if there was no or a read only addressbook given then change to the first writable
  296.             if (!$addressbook || !$GO_SECURITY->has_permission($GO_SECURITY->user_id, $addressbook['acl_write']))
  297.             {
  298.                 //there is no writable addressbook so add one
  299.                 if (!isset($first_writable_ab))
  300.                 {
  301.                     $ab_name = $_SESSION['GO_SESSION']['name'];
  302.                     $new_ab_name = $ab_name;
  303.                     $x = 1;
  304.                     while($ab->get_addressbook_by_name($new_ab_name))
  305.                     {
  306.                         $new_ab_name = $ab_name.' ('.$x.')';
  307.                         $x++;
  308.                     }
  309.                     $addressbook_id = $ab->add_addressbook($GO_SECURITY->user_id, $new_ab_name);
  310.                     $subscribed_addressbooks->add_value($addressbook_id, $new_ab_name);
  311.                 }else
  312.                 {
  313.                     $contact['addressbook_id'] = $first_writable_ab;
  314.                 }
  315.             }
  316.  
  317.             //print the writable addressbooks
  318.             echo '<tr><td align="right">'.$ab_addressbook.':</td><td>';
  319.             $subscribed_addressbooks->print_dropbox('addressbook_id', $addressbook_id, 'onchange="javascript:document.forms[0].submit()"');
  320.             echo '</td></tr>';
  321.             if ($ab->get_groups($addressbook_id) > 0)
  322.             {
  323.                 echo '<tr><td align="right" nowrap>'.$contacts_group.': </td><td>';
  324.                 $dropbox = new dropbox();
  325.                 $dropbox->add_value('0',$contacts_other);
  326.                 $dropbox->add_sql_data('ab','id','name');
  327.                 $dropbox->print_dropbox('group_id',$contact['group_id']);
  328.                 echo '</td></tr>';
  329.             }
  330.             ?>
  331.             </table>
  332.             </td>
  333.         </tr>
  334.         <tr heigth="25">
  335.             <td colspan="2">
  336.             <br />
  337.             <?php
  338.             if (isset($return_to))
  339.             {
  340.                 $button = new button($cmdOk, 'javascript:ok_add()');
  341.                 echo '  ';
  342.             }
  343.             $button = new button($cmdApply, 'javascript:apply_add()');
  344.             echo '  ';
  345.             if ($contact["source_id"] > 0 && $contact_id > 0)
  346.             {
  347.                 $button = new button($cmdUpdate, 'javascript:update()');
  348.                 echo '  ';
  349.             }
  350.             if (isset($return_to))
  351.             {
  352.                 $button = new button($cmdClose, "javascript:document.location='".$return_to."'");
  353.             }
  354.             ?>
  355.             </td>
  356.         </tr>
  357.         </table>
  358.         </td>
  359. </tr>
  360. </table>
  361. <script type="text/javascript" language="javascript">
  362.  
  363. function company_properties()
  364. {
  365.     document.location='<?php echo $GO_MODULES->url; ?>company.php?addressbook_id=<?php echo $addressbook_id; ?>&company_id='+document.forms[0].company_id.value+'&return_to=<?php echo urlencode($link_back); ?>';
  366. }
  367.  
  368. function search_company()
  369. {
  370.     <?php
  371.     if ($task != 'search_company')
  372.     {
  373.         ?>
  374.         if (document.forms[0].company_name.disabled)
  375.         {
  376.             document.forms[0].company_name.disabled = false;
  377.         }else
  378.         {
  379.     <?php
  380.     }
  381.     ?>
  382.     document.forms[0].task.value='<?php if ($task != 'search_company') echo 'search_company'; ?>';
  383.     document.forms[0].submit();
  384.     <?php
  385.     if ($task != 'search_company')
  386.     {
  387.         echo '}';
  388.     }
  389.     ?>
  390.  
  391. }
  392.  
  393. function ok_add()
  394. {
  395.     document.forms[0].close.value='true';
  396.     document.forms[0].task.value='save';
  397.     document.forms[0].submit();
  398. }
  399.  
  400. function apply_add()
  401. {
  402.     document.forms[0].task.value='save';
  403.     document.forms[0].submit();
  404. }
  405. function update()
  406. {
  407.     document.add.task.value = "update";
  408.     document.add.submit();
  409. }
  410.  
  411. document.forms[0].first_name.focus();
  412. </script>
  413.