/**
  * Creates the part of the fieldset for touch conditions
  * @return string html for part
  */
 function createConditionsPart($cid)
 {
     $db = DB::getSingleton();
     $cont = '<h2>conditions</h2>';
     $ownid = $_SESSION['user']->contact['id'];
     if ($cid) {
         $db->query("SELECT * FROM " . INTOUCH_TABLE_CONDS . " AS conds WHERE ownerID = {$ownid} AND touchedID = {$cid}");
     }
     for ($i = 0; $i < ($cid ? $db->rowsAffected() : 0) + 2; $i++) {
         if (!($val = $db->next())) {
             $val = array('initiative' => 'active', 'distance' => 'remote', 'type' => '%', 'days' => '');
         }
         $cont .= '<div>';
         $cont .= HTMLHelper::createDropdownValuesAreKeys("inTouch[conds][{$i}][initiative]", null, array('active', 'passive'), $val['initiative'], null, false);
         $cont .= HTMLHelper::createDropdownValuesAreKeys("inTouch[conds][{$i}][distance]", null, array('remote', 'local'), $val['distance'], null, false);
         $cont .= HTMLHelper::createTextField("inTouch[conds][{$i}][type]", null, $val['type'], null, false);
         $cont .= HTMLHelper::createTextField("inTouch[conds][{$i}][days]", null, $val['days'], 'edit-property-label', false);
         $cont .= '</div>';
     }
     return $cont;
 }
 /**
  * create the goto text-box
  * @return string html-content
  * @global array custom searchtypes defined in config.php
  */
 function createSearchInterface()
 {
     global $CONFIG_SEARCH_CUSTOM;
     $this->addHeaderSection('<style type="text/css"> label { display: block; } table { width:100%; } td { vertical-align: top; } </style>');
     $cont = '<br/><form method="post" action="../contact/searchlist.php">';
     $cont .= "\n<table><tr><td>";
     $projPos = array('', 'Project Manager', 'UTC Project Specialist', 'IUTC Project Specialist', 'PT Project Specialist', 'Parking Project Specialist', 'Technical Engineer', 'Civil Engineer', 'Traffic Signal Specialist', 'UTC System Specialist');
     $projCat = array('', 'Urban Traffic', 'Interurban Traffic', 'Public / Freight', 'Transport', 'Tunnel', 'Infomobility', 'Service / Maintenance');
     $projCon = array('', 'Prime Contractor', 'Subcontractor', 'Managing Contractor', 'Partner in a joint venture');
     // Projects
     $cont .= "\n<br/><h3>Project Reference Search</h3>";
     $cont .= HTMLHelper::createDropdownValuesAreKeys('p-category', 'Project Category', $projCat, isset($_POST['p-category']) ? $_POST['p-category'] : '');
     $cont .= HTMLHelper::createDropdownValuesAreKeys('p-role', 'Contract Role', $projCon, isset($_POST['p-role']) ? $_POST['p-role'] : '');
     $cont .= HTMLHelper::createTextField('p-company', 'Lead Company', isset($_POST['p-company']) ? $_POST['p-company'] : '');
     $cont .= HTMLHelper::createTextField('p-value', 'Value of SWARCO part more than (EUR)', isset($_POST['p-value']) ? $_POST['p-value'] : '');
     $cont .= HTMLHelper::createTextField('p-after', 'Projects completed after', isset($_POST['p-after']) ? $_POST['p-after'] : '');
     // Project Ops
     $cont .= "</td><td>\n<br/><h3>Project Opportunity Search</h3>";
     $cont .= HTMLHelper::createDropdownValuesAreKeys('o-category', 'Project Category', $projCat, isset($_POST['o-category']) ? $_POST['o-category'] : '');
     $projCon = array('', 'Prime Contractor', 'Subcontractor', 'Managing Contractor', 'Partner in a joint venture');
     $cont .= HTMLHelper::createDropdownValuesAreKeys('o-role', 'Contract Role', $projCon, isset($_POST['o-role']) ? $_POST['o-role'] : '');
     $cont .= HTMLHelper::createTextField('o-company', 'Lead Company', isset($_POST['o-company']) ? $_POST['o-company'] : '');
     $cont .= HTMLHelper::createTextField('o-value', 'Value of SWARCO part more than (EUR)', isset($_POST['o-value']) ? $_POST['o-value'] : '');
     // Candidates
     $cont .= "</td><td>\n<br/><h3>Project Candidate Search</h3>";
     $cont .= HTMLHelper::createDropdownValuesAreKeys('c-position', 'Project Position', $projPos, isset($_POST['c-position']) ? $_POST['c-position'] : '');
     $cont .= HTMLHelper::createTextField('c-experience', 'Experience with the Project Position since', isset($_POST['c-experience']) ? $_POST['c-experience'] : '');
     //$cont .= HTMLHelper::createDropdownValuesAreKeys('c-category','SWARCO Project Category',$projCat,'');
     //$cont .= HTMLHelper::createTextField('c-value','Value of SWARCO part more than (EUR)');
     //$cont .= HTMLHelper::createTextField('c-after','Projects completed after');
     $cont .= '</td></tr><tr><td colspan="2" style="text-align: right;">' . HTMLHelper::createButton('clear', 'button', 'onclick="window.location=\'' . $_SERVER['PHP_SELF'] . '\';"') . '</td><td style="text-align: right;">' . HTMLHelper::createButton('search') . '</td><td style="text-align: right;">' . HTMLHelper::createButton('export', 'submit', 'name="export"') . '</td></tr>';
     $cont .= '</table><br>';
     // make some space ...
     $cont .= '</form>';
     return $cont;
 }
 /**
  * create the fieldset that allows user to select the groups of the contact, and whether the contact is hidden or not
  * @return string html-content
  * @global DB used to query database for groups
  */
 function createGroupsFieldset()
 {
     global $db;
     $cont = '<fieldset class="edit-groups">';
     $cont .= '<legend>Groups</legend>';
     $gr = $this->contact->getValueGroup('groups');
     $groups = array();
     foreach ($gr as $g) {
         $groups[] = $g['groupname'];
     }
     $db->query('SELECT * FROM ' . TABLE_GROUPLIST . ' ORDER BY groupname ASC');
     $cont .= '<div class="edit-line">';
     while ($r = $db->next()) {
         $cont .= HTMLHelper::createCheckbox("groups[{$r['groupname']}]", $r['groupname'], in_array($r['groupname'], $groups), 'edit-input-checkbox');
     }
     $cont .= '</div>';
     $cont .= '<div class="edit-line">';
     $cont .= HTMLHelper::createTextField('newgroup', 'Add new group', '', 'edit-input');
     if ($_SESSION['user']->isAtLeast('admin')) {
         global $CONFIG_INSTALL_SUBDIR;
         // find .xls files without dash (type-edit.xsl)
         $func = create_function('$val', 'return strpos($val,"-")===FALSE;');
         $files = array_filter(FileHelper::scanDirectory($CONFIG_INSTALL_SUBDIR . 'lib/xslt', '.xsl'), $func);
         if (count($files) > 0) {
             FileHelper::removeExtensions($files);
             $files = array_merge(array(''), $files);
             $xs = isset($this->contact->contact['xsltDisplayType']) ? $this->contact->contact['xsltDisplayType'] : '';
             $cont .= HTMLHelper::createDropdownValuesAreKeys('contact[xsltDisplayType]', 'XSLT stylesheet', $files, $xs, 'edit-input', false);
         }
         $cont .= HTMLHelper::createCheckbox('contact[hidden]', 'Hide this entry', isset($this->contact->contact['hidden']) ? $this->contact->contact['hidden'] : 0, 'edit-input-checkbox-hide');
     }
     $cont .= '</div>';
     $cont .= '</fieldset>';
     return $cont;
 }
 function editContactInterface(&$contact, $location)
 {
     global $CONFIG_CA_OU_CHOICES, $CONF_CERT_REQUEST_TEXT;
     if ($location != 'otherInfo' || false == $_SESSION['user']->isAtLeast('manager')) {
         return "";
     }
     if (!isset($contact->contact['organizationalUnit'])) {
         // add new entry menu ... prepare default
         $contact->contact['organizationalUnit'] = $CONFIG_CA_OU_CHOICES[0];
     }
     if (in_array($contact->contact['organizationalUnit'], $CONFIG_CA_OU_CHOICES)) {
         $cont = HTMLHelper::createDropdownValuesAreKeys('contact[organizationalUnit]', 'Organizational Unit', $CONFIG_CA_OU_CHOICES, $contact->contact['organizationalUnit'], 'edit-input');
     } else {
         $cont = HTMLHelper::createDropdownValuesAreKeys('contact[organizationalUnit]', 'Organizational Unit', array_merge($CONFIG_CA_OU_CHOICES, array($contact->contact['organizationalUnit'])), $contact->contact['organizationalUnit'], 'edit-input');
     }
     $cont .= HTMLHelper::createCheckbox('AdminCertificateAuthority_new_cert_request', empty($CONF_CERT_REQUEST_TEXT) ? "<span style='color: red;'>REQUEST SSL CERTIFICATE WHEN SAVING</span>" : $CONF_CERT_REQUEST_TEXT, false, 'edit-input-checkbox');
     return $cont;
 }