Example #1
0
 echo date_picker('add_contract.startdate');
 echo "</td></tr>\n";
 echo "<tr><th>{$strExpiryDate}</th>";
 echo "<td><input class='required' name='expiry' size='10' ";
 if ($_SESSION['formdata']['add_contract']['expiry'] != '') {
     echo "value='{$_SESSION['formdata']['add_contract']['expiry']}'";
 }
 echo "/> " . date_picker('add_contract.expiry');
 echo "<input type='checkbox' name='noexpiry' ";
 if ($_SESSION['formdata']['add_contract']['noexpiry'] == "on") {
     echo "checked='checked' ";
 }
 echo "onclick=\"this.form.expiry.value=''\" /> {$strUnlimited}";
 echo " <span class='required'>{$strRequired}</span></td></tr>\n";
 echo "<tr><th>{$strAdminContact}</th>";
 echo "<td>" . contact_drop_down("admincontact", 0, TRUE, TRUE);
 echo " <span class='required'>{$strRequired}</span></td></tr>\n";
 echo "<tr><th>{$strNotes}</th><td><textarea cols='40' name='notes' rows='5'>{$_SESSION['formdata']['add_contract']['notes']}</textarea></td></tr>\n";
 echo "<tr><th></th><td><a href=\"javascript:void(0);\" onclick=\"\$('hidden').toggle();\">{$strMore}</a></td></tr>\n";
 echo "</thead>";
 echo "<tbody id='hiddentimed'";
 if (!$timed) {
     echo " style='display:none'";
 }
 echo ">";
 echo "<tr><th>{$strBilling}</th>";
 echo "<td>";
 echo "<label>";
 echo "<input type='radio' name='billtype' value='billperunit' onchange=\"addservice_showbilling('add_contract');\" checked='checked' /> ";
 echo "{$strPerUnit}</label>";
 echo "<label>";
    echo "<form action='{$_SERVER['PHP_SELF']}?action=delete' method='post' onsubmit='return confirm_action(\"{$strAreYouSureDeleteMaintenceContract}\")'>";
    echo "<input type='hidden' name='context' value='{$context}' />";
    echo "<table align='center' class='vertical'>";
    if (empty($maintid)) {
        echo "<tr><th>{$strContract} " . icon('contract', 16) . "</th>";
        echo "<td>";
        maintenance_drop_down("maintid", 0);
        echo "</td></tr>";
    } else {
        echo "<tr><th>{$strContract} " . icon('contract', 16) . "</th>";
        echo "<td>{$maintid} - " . contract_product($maintid) . " for " . contract_site($maintid);
        echo "<input name=\"maintid\" type=\"hidden\" value=\"{$maintid}\" /></td></tr>";
    }
    if (empty($contactid)) {
        echo "<tr><th>{$strSupport} {$strContact} " . icon('contact', 16) . "</th><td width='400'>";
        echo contact_drop_down("contactid", 0) . "</td></tr>";
    } else {
        echo "<tr><th>{$strContact} " . icon('contact', 16) . "</th><td>{$contactid} - " . contact_realname($contactid);
        echo "<input name='contactid' type='hidden' value='{$contactid}' /></td></tr>";
    }
    echo "</table>";
    echo "<p align='center'><input name='submit' type='submit' value='{$strContinue}' /></p>";
    echo "</form>";
    include APPLICATION_INCPATH . 'htmlfooter.inc.php';
} elseif ($action == "delete") {
    // Delete the chosen support contact
    $errors = 0;
    // check for blank contact
    if ($contactid == 0) {
        $errors = 1;
        $errors_string .= user_alert("{$strYouMustSelectAsupportContact}", E_USER_ERROR);
        maintenance_drop_down("maintid", 0, '', '', FALSE, TRUE);
        echo "</td></tr>";
    } else {
        $sql = "SELECT s.name, p.name FROM `{$dbMaintenance}` m, `{$dbSites}` s, `{$dbProducts}` p WHERE m.site=s.id ";
        $sql .= "AND m.product=p.id AND m.id='{$maintid}'";
        $result = mysql_query($sql);
        if (mysql_error()) {
            trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING);
        }
        list($sitename, $product) = mysql_fetch_row($result);
        echo "<tr><th>{$strContract} " . icon('contract', 16) . "</th><td>{$maintid} - {$sitename}, {$product}</td></tr>";
        echo "<input name=\"maintid\" type=\"hidden\" value=\"{$maintid}\" />";
    }
    if (empty($contactid)) {
        echo "<tr><th>{$strContact} " . icon('contact', 16) . "</th>";
        echo "<td>" . contact_drop_down("contactid", 0, TRUE) . "</td></tr>";
    } else {
        echo "<tr><th>{$strContact} " . icon('contact', 16) . "</th><td>{$contactid} - " . contact_realname($contactid) . ", " . site_name(contact_site($contactid));
        echo "<input name=\"contactid\" type=\"hidden\" value=\"{$contactid}\" />";
        echo "</td></tr>";
    }
    echo "</table>";
    echo "<p align='center'><input name='submit' type='submit' value='{$strContinue}' /></p>";
    echo "</form>";
    include APPLICATION_INCPATH . 'htmlfooter.inc.php';
} else {
    if ($action == "add") {
        // Add support contact
        $errors = 0;
        // check for blank contact
        if ($contactid == 0) {
function dashboard_watch_incidents_edit($dashletid)
{
    global $CONFIG, $sit;
    $editaction = $_REQUEST['editaction'];
    switch ($editaction) {
        case 'add':
            $type = $_REQUEST['type'];
            echo "<h2>{$GLOBALS['strWatchAddSet']}</h2>";
            echo "<form id='dwiaddform' action='{$_SERVER['PHP_SELF']}?action=do_add&type={$type}' method='post' onsubmit='return false'>";
            echo "<table class='vertical'>";
            echo "<tr><td>";
            switch ($type) {
                case '0':
                    //site
                    echo "{$GLOBALS['strSite']}: ";
                    echo site_drop_down('id', '');
                    break;
                case '1':
                    //contact
                    echo "{$GLOBALS['strContact']}: ";
                    echo contact_drop_down('id', '');
                    break;
                case '2':
                    //engineer
                    echo "{$GLOBALS['strEngineer']}: ";
                    echo user_drop_down('id', '', FALSE);
                    break;
                case '3':
                    //Incident
                    echo "{$GLOBALS['strIncident']}:";
                    echo "<input class='textbox' name='id' size='30' />";
                    break;
            }
            echo "</td><tr>";
            echo "</table>";
            echo "<p align='center'>";
            echo dashlet_link('watch_incidents', $dashletid, $GLOBALS['strAdd'], 'save', array('editaction' => 'do_add', 'type' => $type), false, 'dwiaddform');
            echo "</p>";
            break;
        case 'do_add':
            $id = $_REQUEST['id'];
            $type = $_REQUEST['type'];
            $sql = "INSERT INTO `{$CONFIG['db_tableprefix']}dashboard_watch_incidents` VALUES ({$sit[2]},'{$type}','{$id}')";
            $result = mysql_query($sql);
            if (mysql_error()) {
                trigger_error(mysql_error(), E_USER_ERROR);
            }
            if (!$result) {
                echo "<p class='error'>{$GLOBALS['strWatchAddFailed']}</p>";
            } else {
                echo "<p>{$GLOBALS['strAddedSuccessfully']}</p>";
                echo dashlet_link('watch_incidents', $dashletid, $GLOBALS['strBackToList'], '', '', TRUE);
            }
            break;
        case 'delete':
            $id = $_REQUEST['id'];
            $type = $_REQUEST['type'];
            $sql = "DELETE FROM `{$CONFIG['db_tableprefix']}dashboard_watch_incidents` WHERE id = '{$id}' AND userid = {$sit[2]} AND type = '{$type}'";
            $result = mysql_query($sql);
            if (mysql_error()) {
                trigger_error(mysql_error(), E_USER_ERROR);
            }
            if (!$result) {
                echo "<p class='error'>{$GLOBALS['strWatchDeleteFailed']}</p>";
            } else {
                echo "<p>{$GLOBALS['strSuccess']}</p>";
                echo dashlet_link('watch_incidents', $dashletid, $GLOBALS['strBackToList'], '', '', TRUE);
            }
            break;
        default:
            echo "<h3>{$GLOBALS['strEditWatchedIncidents']}</h3>";
            echo "<table align='center'>";
            for ($i = 0; $i < 4; $i++) {
                $sql = "SELECT * FROM `{$CONFIG['db_tableprefix']}dashboard_watch_incidents` WHERE userid = {$sit[2]} AND type = {$i}";
                $result = mysql_query($sql);
                if (mysql_error()) {
                    trigger_error(mysql_error(), E_USER_WARNING);
                }
                echo "<tr><td align='left'><strong>";
                switch ($i) {
                    case 0:
                        echo $GLOBALS['strSites'];
                        break;
                    case 1:
                        echo $GLOBALS['strContacts'];
                        break;
                    case 2:
                        echo $GLOBALS['strEngineers'];
                        break;
                    case 3:
                        echo $GLOBALS['strIncidents'];
                        break;
                }
                echo "</strong></td><td align='right'>";
                switch ($i) {
                    case 0:
                        $linktext = $GLOBALS['strAddSite'];
                        break;
                    case 1:
                        $linktext = $GLOBALS['strAddContact'];
                        break;
                    case 2:
                        $linktext = $GLOBALS['strAddUser'];
                        break;
                    case 3:
                        $linktext = $GLOBALS['strAddIncident'];
                        break;
                }
                echo dashlet_link('watch_incidents', $dashletid, $linktext, 'edit', array('editaction' => 'add', 'type' => $i));
                echo "</td></tr>";
                if (mysql_num_rows($result) > 0) {
                    $shade = 'shade1';
                    while ($obj = mysql_fetch_object($result)) {
                        $name = '';
                        switch ($obj->type) {
                            case 0:
                                //site
                                $sql = "SELECT name FROM `{$GLOBALS['dbSites']}` WHERE id = {$obj->id}";
                                $iresult = mysql_query($sql);
                                if (mysql_error()) {
                                    trigger_error(mysql_error(), E_USER_WARNING);
                                }
                                $iobj = mysql_fetch_object($iresult);
                                $name = $iobj->name;
                                break;
                            case 1:
                                //contact
                                $sql = "SELECT forenames, surname FROM `{$GLOBALS['dbContacts']}` WHERE id = {$obj->id}";
                                $iresult = mysql_query($sql);
                                if (mysql_error()) {
                                    trigger_error(mysql_error(), E_USER_WARNING);
                                }
                                $iobj = mysql_fetch_object($iresult);
                                $name = $iobj->forenames . ' ' . $iobj->surname;
                                break;
                            case 2:
                                //Engineer
                                $sql = "SELECT realname FROM `{$GLOBALS['dbUsers']}` WHERE id = {$obj->id}";
                                $iresult = mysql_query($sql);
                                if (mysql_error()) {
                                    trigger_error(mysql_error(), E_USER_WARNING);
                                }
                                $iobj = mysql_fetch_object($iresult);
                                $name = $iobj->realname;
                                break;
                            case 3:
                                //Incident
                                $sql = "SELECT title FROM `{$GLOBALS['dbIncidents']}` WHERE id = {$obj->id}";
                                $iresult = mysql_query($sql);
                                if (mysql_error()) {
                                    trigger_error(mysql_error(), E_USER_WARNING);
                                }
                                $iobj = mysql_fetch_object($iresult);
                                $name = "<a href=\"javascript:incident_details_window('{$obj->id}','incident{$obj->id}')\" class='info'>[{$obj->id}] {$iobj->title}</a>";
                                break;
                        }
                        echo "<tr class='{$shade}'><td>{$name}</td><td>";
                        echo dashlet_link('watch_incidents', $dashletid, $GLOBALS['strRemove'], 'edit', array('editaction' => 'delete', 'id' => $obj->id, 'type' => $i));
                        if ($shade == 'shade1') {
                            $shade = 'shade2';
                        } else {
                            $shade = 'shade1';
                        }
                    }
                } else {
                    echo "<tr><td colspan='2'>{$GLOBALS['strNoIncidentsBeingWatchOfType']}</td></tr>";
                }
            }
            echo "</table>";
            break;
    }
    return $html;
}
 echo "<td><input name='expirydate' size='10' value='";
 if ($maint['expirydate'] > 0) {
     echo ldate('Y-m-d', $maint['expirydate']);
 }
 echo "' /> " . date_picker('maintform.expirydate');
 if ($maint['expirydate'] == '-1') {
     echo "<input type='checkbox' checked='checked' name='noexpiry' /> {$strUnlimited}";
 } else {
     echo "<input type='checkbox' name='noexpiry' /> {$strUnlimited}";
 }
 echo "</td></tr>\n";
 echo "<tr><th>{$strServiceLevel}:</th><td>";
 echo servicelevel_drop_down('servicelevelid', $maint['servicelevelid'], TRUE);
 echo "</td></tr>\n";
 echo "<tr><th>{$strAdminContact}: <sup class='red'>*</sup></th><td>";
 echo contact_drop_down("admincontact", $maint["admincontact"], true);
 echo "</td></tr>\n";
 echo "<tr><th>{$strNotes}:</th><td><textarea cols='40' name='notes' rows='5'>";
 echo $maint["notes"];
 echo "</textarea></td></tr>\n";
 echo "<tr><th>{$strTerminated}:</th><td><input name='terminated' id='terminated' type='checkbox' value='yes'";
 if ($maint["term"] == "yes") {
     echo " checked";
 }
 echo " /></td></tr>\n";
 echo "<tr><th></th><td><a href=\"javascript:void(0);\" onclick=\"\$('hidden').toggle();\">{$strAdvanced}</a></td></tr>";
 echo "</thead>\n";
 echo "<tbody id='hidden' style='display:none'>";
 echo "<tr><th>{$strReseller}:</th><td>";
 echo reseller_drop_down("reseller", $maint["reseller"]);
 echo "</td></tr>\n";
 if ($incident["type"] == "Support") {
     echo "<form action='{$_SERVER['PHP_SELF']}' method='post' name='editform'>";
     echo "<table class='vertical'>";
     echo "<tr><th>{$strTitle}</th><td><input maxlength='150' name='title' size='40' type='text' value=\"" . $incident['title'] . "\" /></td></tr>\n";
     echo "<tr><th>{$strTags}</th><td><textarea rows='2' cols='40' name='tags'>" . list_tags($id, 2, false) . "</textarea></td></tr>\n";
     echo "<tr><th>{$strImportant}</th>";
     echo "<td>{$strChangingContact}. ";
     if ($incident['maintenanceid'] >= 1) {
         echo sprintf($strLoggedUnder, $incident['maintenanceid']) . ". ";
     } else {
         echo "{$strIncidentNoContract}. ";
     }
     echo "{$strToChangeContract}.";
     echo "</td></tr>\n";
     echo "<tr><th>{$strContact}</th><td>";
     echo contact_drop_down("contact", $incident["contact"], TRUE) . "</td></tr>\n";
     flush();
     $maintid = maintenance_siteid($incident['maintenanceid']);
     echo "<tr><th>{$strSite}</th><td>" . site_name($maintid) . "</td></tr>";
     echo "<tr><th>{$strSkill}</th><td>" . skill_drop_down("software", $incident["softwareid"]) . "</td></tr>\n";
     echo "<tr><th>{$strVersion}</th>";
     echo "<td><input maxlength='50' name='productversion' size='30' type='text' value=\"{$incident["productversion"]}\" /></td></tr>\n";
     echo "<tr><th>{$strServicePacksApplied}</th>";
     echo "<td><input maxlength='100' name='productservicepacks' size='30' type='text' value=\"{$incident["productservicepacks"]}\" /></td></tr>\n";
     echo "<tr><th>CC {$strEmail}</th>";
     echo "<td><input maxlength='255' name='ccemail' size='30' type='text' value=\"{$incident["ccemail"]}\" /></td></tr>\n";
     echo "<tr><th>{$strEscalation}</th>";
     echo "<td>" . escalation_path_drop_down('escalationpath', $incident['escalationpath']) . "</td></tr>";
     echo "<tr><th>{$strExternalID}</th>";
     echo "<td><input maxlength='50' name='externalid' size='30' type='text' value=\"{$incident["externalid"]}\" /></td></tr>\n";
     echo "<tr><th>{$strExternalEngineersName}</th>";