/** * Called by {@link PluginManager} to append a user interface section to the edit contact form. * The result is delivered to the changedContactRecord() method in $_POST['PluginName'] * @return string XHTML content */ function editContactInterface(&$contact, $location) { //die("?????????????"); if ($location != 'ownFieldset') { return ""; } //if(!$_SESSION['user']->isAtLeast('manager')) // return ""; $content = '<fieldset class="edit-names">'; $content .= '<legend>Relationships</legend>'; // create dropdown selector box from all contacts (might be HUGE) global $CONFIG_DB_PREFIX; $db = DB::getSingleton(); // fetch dropdown $dropdown = $this->getDropdown($db); $id = $contact->contact['id']; $i = 0; // list existing relationships if not a new/added contact if (!empty($id)) { $db->query("SELECT r.* FROM `{$CONFIG_DB_PREFIX}Relationships` as r, `{$CONFIG_DB_PREFIX}contact` as c WHERE r.ownerId={$id} AND c.id=r.ownerId AND c.hidden=0", 'Relationships'); while ($r = $db->next('Relationships')) { $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown('Relationship[' . $i . '][relatedToId]', 'Relationship to', $dropdown, $r['relatedToId'], 'edit-input'); $content .= HTMLHelper::createTextField('Relationship[' . $i . '][relationship]', 'Relationship Type', $r['relationship'], 'edit-property-value', false); $content .= '</div>'; $i++; } } for ($k = $i; $k < $i + 2; $k++) { $content .= '<div class="edit-line">'; $content .= HTMLHelper::createDropdown('Relationship[' . $k . '][relatedToId]', 'Relationship to', $dropdown, ' ', 'edit-input'); $content .= HTMLHelper::createTextField('Relationship[' . $k . '][relationship]', 'Relationship Type', '', 'edit-property-value', false); $content .= '</div>'; } return $content . '</fieldset>'; }
/** * create the fieldset that allows user to the addresses of the contact * @global array list of country names and acronyms * @global Options used to determine the country default * @return string html-content */ function createAddressFieldset() { global $country, $options; $cont = '<fieldset class="edit-address">'; $cont .= '<legend>Addresses</legend>'; $cont .= '<div class="context-help" id="editHelp' . $this->htmlId . '"><a href="#" onclick="Element.hide(\'editHelp' . $this->htmlId . '\'); Effect.Appear(\'editHint' . $this->htmlId . '\',{duration:1.2}); return false;">?</a></div><div class="context-help" id="editHint' . $this->htmlId++ . '" style="display: none;">All fields are optional. An address will be saved if either of the following are provided: type, address lines, city, state, zip code, or a phone number. If Primary Address is selected, the address will be displayed in the contact list. To obtain more than 2 additional blank address sections, save this entry and edit it again.</div>'; $addr = $this->contact->getValueGroup('addresses'); $n = max(count($addr), 1); // initially 3 blank adresses // write out all existing addresses plus 2 blank address for ($i = 0; $i < $n + 2; $i++) { $a = array_key_exists($i, $addr) ? $addr[$i] : null; // generate additional blank entries if ($i >= $n) { // hide the blank addresses by default $cont .= '<div class="edit-single-address" id="anotherAddress' . $i . '" style="display: none;"><br>'; } else { $cont .= '<div class="edit-single-address">'; } if (!$this->add) { $cont .= '<input type="hidden" name="address[' . $i . '][refid]" value="' . $a['refid'] . '" />'; } $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][type]", 'Type', $a['type'], 'edit-input'); $cont .= HTMLHelper::createRadioButton("address_primary", 'Set as primary address', $i, isset($this->contact->contact['primaryAddress']) && $a['refid'] == $this->contact->contact['primaryAddress'], 'edit-input-radio'); if (!$i >= $n) { $cont .= '<div class="edit-input-link"><a href="javascript:deleteAddress(' . $i . ');">Delete this address</a></div>'; } $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][line1]", 'Address (Line 1)', $a['line1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][line2]", 'Address (Line 2)', $a['line2'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][city]", 'City', $a['city'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][state]", 'State', $a['state'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][zip]", 'Zip-code', $a['zip'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][phone1]", 'Phone 1', $a['phone1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][phone2]", 'Phone 2', $a['phone2'], 'edit-input'); $cont .= HTMLHelper::createDropdown("address[{$i}][country]", 'Country', $country, $a === null ? $options->getOption('countryDefault') : $a['country'], 'edit-input'); $cont .= '</div>'; if ($i >= $n - 1 && $i != $n + 1) { // include the add more link in the previous div $cont .= "\n" . '<div id="addAddressLink' . ($i + 1) . '"><a href="#" onclick="Element.hide(\'addAddressLink' . ($i + 1) . '\'); Effect.SlideDown(\'anotherAddress' . ($i + 1) . '\',{duration:1.2}); return false;">add address</a></div>'; } $cont .= '</div>'; } $cont .= '</fieldset>'; return $cont; }
/** * 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 fieldset that allows user to the addresses of the contact * @global array list of country names and acronyms * @global Options used to determine the country default * @return string html-content * @TODO If a contact gets bounced (missing mandatory value) 2 additional unhidden blank addresses show. This is because in the previous step 3 blank addresses were created and by reediting the same contact without storing it the blank addresses are not removed. */ function createAddressFieldset() { global $country, $options; $cont = '<fieldset class="edit-address">'; $cont .= '<legend>Addresses</legend>'; $cont .= $this->contextHelp('address'); $addr = $this->contact->getValueGroup('addresses'); $n = max(count($addr), 1); // initially 3 blank adresses // write out all existing addresses plus 2 blank address for ($i = 0; $i < $n + 2; $i++) { $a = array_key_exists($i, $addr) ? $addr[$i] : null; // generate additional blank entries if (!isset($a['refid'])) { // if someone leaves the lastname blank we reedit the same contact - would cause tons of warnings $a = null; } if ($a !== null) { $this->valueGroups['phone'][$a['refid']] = $this->contact->getValueGroup('phone', $a['refid']); $this->valueGroups['email'][$a['refid']] = $this->contact->getValueGroup('email', $a['refid']); $this->valueGroups['chat'][$a['refid']] = $this->contact->getValueGroup('chat', $a['refid']); $this->valueGroups['www'][$a['refid']] = $this->contact->getValueGroup('www', $a['refid']); $this->valueGroups['other'][$a['refid']] = $this->contact->getValueGroup('other', $a['refid']); } if ($i >= $n) { // hide the blank addresses by default $cont .= '<div class="edit-single-address" id="anotherAddress' . $i . '" style="display: none;"><br>'; } else { $cont .= '<div class="edit-single-address">'; } if (!$this->add) { $cont .= '<input type="hidden" name="address[' . $i . '][refid]" value="' . $a['refid'] . '" />'; } $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][type]", 'Address type', $a['type'], 'edit-input'); $cont .= HTMLHelper::createRadioButton("address_primary", 'Set as primary address', $i, isset($this->contact->contact['primaryAddress']) && $a['refid'] == $this->contact->contact['primaryAddress'], 'edit-input-radio'); if ($i < $n) { $cont .= '<div class="edit-input-link"><a href="javascript:deleteAddress(' . $i . ');">Delete this address</a></div>'; } $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][line1]", 'Address (Line 1)', $a['line1'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][line2]", 'Address (Line 2)', $a['line2'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; $cont .= HTMLHelper::createTextField("address[{$i}][city]", 'City', $a['city'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][state]", 'State', $a['state'], 'edit-input'); $cont .= HTMLHelper::createTextField("address[{$i}][zip]", 'Zip-code', $a['zip'], 'edit-input'); $cont .= '</div>'; $cont .= '<div class="edit-line">'; // $cont .= HTMLHelper::createTextField("address[$i][phone1]",'Phone 1',$a['phone1'],'edit-input'); // $cont .= HTMLHelper::createTextField("address[$i][phone2]",'Phone 2',$a['phone2'],'edit-input'); $cont .= HTMLHelper::createDropdown("address[{$i}][country]", 'Country', $country, $a === null ? $options->getOption('countryDefault') : $a['country'], 'edit-input'); $cont .= '</div>'; if ($a !== null) { $cont .= '<div><label>Communications</label>'; $opt = array('email' => 'email', 'phone' => 'phone', 'chat' => 'chat', 'other' => 'other', 'www' => 'url', ' ' => 'delete'); $cont .= $this->createNormalProperties($opt, 'email', $a['refid']); $cont .= $this->createNormalProperties($opt, 'phone', $a['refid']); $cont .= $this->createNormalProperties($opt, 'chat', $a['refid']); $cont .= $this->createNormalProperties($opt, 'www', $a['refid']); $cont .= $this->createNormalProperties($opt, 'other', $a['refid']); $cont .= '</div>'; } if ($i >= $n - 1 && $i != $n + 1) { // include the add more link in the previous div $cont .= "\n" . '<div id="addAddressLink' . ($i + 1) . '"><a href="#" onclick="Element.hide(\'addAddressLink' . ($i + 1) . '\'); Effect.SlideDown(\'anotherAddress' . ($i + 1) . '\',{duration:1.2}); return false;">add address</a></div>'; } $cont .= '</div>'; } $cont .= '</fieldset>'; 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; }
function editContactInterface(&$contact, $location) { global $CONFIG_ADMIN_REQUEST_INTERFACE; if ($location != 'ownFieldset') { return ""; } if (!$_SESSION['user']->isAtLeast('manager')) { return ""; } $content = '<fieldset class="edit-names">'; $content .= '<legend>Administrative Requests</legend>'; foreach ($CONFIG_ADMIN_REQUEST_INTERFACE as $k => $v) { switch ($v['interface']) { case 'textfield': $content .= HTMLHelper::createTextField('AdminRequest[' . $k . ']', $v['label'], $v['default'], 'edit-input'); break; case 'checkbox': $content .= HTMLHelper::createCheckbox('AdminRequest[' . $k . ']', $v['label'], $v['default'], 'edit-input-checkbox'); break; case 'html': $content .= $v['html']; break; } } return $content . '</fieldset>'; }