function show($orderBy = 'short')
 {
     global $dcl_info, $g_oSec;
     if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_VIEW)) {
         return PrintPermissionDenied();
     }
     commonHeader();
     $oView = CreateObject('dcl.boView');
     $oView->startrow = 0;
     $oView->numrows = 25;
     $filterActive = '';
     if (isset($_REQUEST['filterActive'])) {
         $filterActive = DCL_Sanitize::ToYN($_REQUEST['filterActive']);
     }
     $oView->table = 'dcl_contact';
     $oView->title = 'Browse Contacts';
     $oView->AddDef('columnhdrs', '', array('ID', 'Last Name', 'First Name', 'Phone', 'Email', 'Internet'));
     $oView->AddDef('columns', '', array('contact_id', 'last_name', 'first_name', 'dcl_contact_phone.phone_number', 'dcl_contact_email.email_addr', 'dcl_contact_url.url_addr'));
     $oView->AddDef('order', '', array('last_name', 'first_name'));
     if ($filterActive == 'Y' || $filterActive == 'N') {
         $oView->AddDef('filter', 'active', "'{$filterActive}'");
     }
     $oHtml = CreateObject('dcl.htmlContactBrowse');
     $oHtml->Render($oView);
 }
 function submitModify()
 {
     global $g_oSession, $dcl_info, $g_oSec;
     if (!$g_oSec->HasPerm(DCL_ENTITY_PREFS, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     $bHasChanges = false;
     $o = CreateObject('dcl.dbPreferences');
     $o->personnel_id = $GLOBALS['DCLID'];
     $o->preferences_data = $g_oSession->Value('dcl_preferences');
     if (!isset($o->preferences_data) || !is_array($o->preferences_data) || count($o->preferences_data) < 1) {
         $o->preferences_data = array('DCL_PREF_TEMPLATE_SET' => $dcl_info['DCL_DEF_TEMPLATE_SET'], 'DCL_PREF_LANGUAGE' => $dcl_info['DCL_DEFAULT_LANGUAGE'], 'DCL_PREF_NOTIFY_DEFAULT' => 'N', 'DCL_PREF_CREATED_WATCH_OPTION' => 4);
         $o->Add();
         $bHasChanges = true;
     }
     $sOldTpl = $o->preferences_data['DCL_PREF_TEMPLATE_SET'];
     foreach ($_REQUEST as $pref => $setting) {
         if (substr($pref, 0, 9) != 'DCL_PREF_') {
             continue;
         }
         if ($pref == 'DCL_PREF_NOTIFY_DEFAULT') {
             $setting = DCL_Sanitize::ToYN($_REQUEST['DCL_PREF_NOTIFY_DEFAULT']);
         }
         if ($o->Value($pref) != $setting) {
             $bHasChanges = true;
             $o->Register($pref, $setting);
         }
     }
     if (!isset($_REQUEST['DCL_PREF_NOTIFY_DEFAULT'])) {
         $bHasChanges = true;
         $o->Register('DCL_PREF_NOTIFY_DEFAULT', 'N');
     }
     if ($bHasChanges) {
         $o->Edit();
         $g_oSession->Register('dcl_preferences', $o->preferences_data);
         $g_oSession->Edit();
     }
     // Template change?
     $sNewTpl = $o->preferences_data['DCL_PREF_TEMPLATE_SET'];
     if ($sNewTpl != $sOldTpl) {
         // Do we need to break out of frames?
         $menuAction = 'menuAction=htmlPreferences.modify';
         $sNewIsFramed = file_exists(DCL_ROOT . 'templates/' . $sNewTpl . '/frameset.php');
         $sOldIsFramed = file_exists(DCL_ROOT . 'templates/' . $sOldTpl . '/frameset.php');
         if ($sOldIsFramed) {
             if ($sNewIsFramed) {
                 RefreshTop(menuLink(DCL_WWW_ROOT . 'templates/' . $sNewTpl . '/frameset.php', $menuAction));
             } else {
                 RefreshTop(menuLink('', $menuAction));
             }
         } else {
             if ($sNewIsFramed) {
                 RefreshTop(menuLink(DCL_WWW_ROOT . 'templates/' . $sNewTpl . '/frameset.php', $menuAction));
             }
         }
     }
     $this->modify();
 }
 function modify($aSource)
 {
     $aSource['active'] = @DCL_Sanitize::ToYN($aSource['active']);
     parent::modify($aSource);
     $oWSP = CreateObject('dcl.dbWorkspaceProduct');
     $oWSP->serialize($aSource['workspace_id'], $aSource['products'], false);
     $oWSU = CreateObject('dcl.dbWorkspaceUser');
     $oWSU->serialize($this->oDB->workspace_id, $aSource['users'], false);
 }
 function dbmodify()
 {
     global $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_FAQ, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     $obj =& CreateObject('dcl.dbFaq');
     $obj->InitFromGlobals();
     $obj->active = @DCL_Sanitize::ToYN($_REQUEST['active']);
     $obj->modifyby = $GLOBALS['DCLID'];
     $obj->modifyon = DCL_NOW;
     $obj->Edit();
     $objH =& CreateObject('dcl.htmlFaq');
     $objH->ShowFaq($obj);
 }
 function modify($aSource)
 {
     global $g_oSec;
     if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     $aSource['active'] = @DCL_Sanitize::ToYN($aSource['active']);
     parent::modify($aSource);
     $sTypes = join(',', $aSource['contact_type_id']);
     $sql = 'DELETE FROM dcl_contact_type_xref WHERE contact_id = ' . $aSource['contact_id'];
     if (count($aSource['contact_type_id']) > 0) {
         $sql .= ' AND contact_type_id NOT IN (' . $sTypes . ')';
     }
     $this->oDB->Execute($sql);
     $oContactTypeXref =& CreateObject('dcl.boContactTypeXref');
     foreach ($aSource['contact_type_id'] as $contact_type_id) {
         if (!$oContactTypeXref->exists(array('contact_id' => $aSource['contact_id'], 'contact_type_id' => $contact_type_id))) {
             $oContactTypeXref->Add(array('contact_id' => $aSource['contact_id'], 'contact_type_id' => $contact_type_id));
         }
     }
 }
 function submitToggle()
 {
     global $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_WORKORDER, DCL_PERM_ACTION)) {
         return PrintPermissionDenied();
     }
     if (($wo_task_id = DCL_Sanitize::ToInt($_REQUEST['wo_task_id'])) === null) {
         trigger_error('Data sanitize failed.');
         return;
     }
     $task_complete = @DCL_Sanitize::ToYN($_REQUEST['task_complete']);
     $obj = CreateObject('dcl.boWorkOrderTask');
     $aSource = array('wo_task_id' => $wo_task_id, 'task_complete' => $task_complete);
     $obj->toggleComplete($aSource);
     $objWO =& CreateObject('dcl.htmlWorkOrderDetail');
     $objWO->Show($obj->oDB->wo_id, $obj->oDB->seq);
 }
 function modify($aSource)
 {
     $aSource['active'] = @DCL_Sanitize::ToYN($aSource['active']);
     parent::modify($aSource);
 }
 function dbsearch()
 {
     commonHeader();
     $personnel = isset($_REQUEST['personnel']) && is_array($_REQUEST['personnel']) ? $_REQUEST['personnel'] : array();
     $type = @DCL_Sanitize::ToIntArray($_REQUEST['type']);
     $priority = @DCL_Sanitize::ToIntArray($_REQUEST['priority']);
     $status = @$_REQUEST['status'];
     $account = @DCL_Sanitize::ToIntArray($_REQUEST['account']);
     $is_public = @$_REQUEST['is_public'];
     $entity_source_id = @DCL_Sanitize::ToIntArray($_REQUEST['entity_source_id']);
     $createdon = @$_REQUEST['createdon'];
     $closedon = @$_REQUEST['closedon'];
     $statuson = @$_REQUEST['statuson'];
     $lastactionon = @$_REQUEST['lastactionon'];
     $module_id = isset($_REQUEST['module_id']) && is_array($_REQUEST['module_id']) ? $_REQUEST['module_id'] : array();
     $tags = $_REQUEST['tags'];
     $searchText = $_REQUEST['searchText'];
     $columns = $_REQUEST['columns'];
     $groups = $_REQUEST['groups'];
     $order = $_REQUEST['order'];
     $columnhdrs = $_REQUEST['columnhdrs'];
     $dcl_status_type = @DCL_Sanitize::ToIntArray($_REQUEST['dcl_status_type']);
     $product = @DCL_Sanitize::ToIntArray($_REQUEST['product']);
     $department = @DCL_Sanitize::ToIntArray($_REQUEST['department']);
     $dateFrom = DCL_Sanitize::ToDate($_REQUEST['dateFrom']);
     $dateTo = DCL_Sanitize::ToDate($_REQUEST['dateTo']);
     $oDB = new dclDB();
     if (strlen($columnhdrs) > 0) {
         $columnhdrs = explode(',', $columnhdrs);
     } else {
         $columnhdrs = array();
     }
     if (strlen($columns) > 0) {
         $columns = explode(',', $columns);
     } else {
         $columns = array();
     }
     if (strlen($groups) > 0) {
         $groups = explode(',', $groups);
     } else {
         $groups = array();
     }
     if (strlen($order) > 0) {
         $order = explode(',', $order);
     } else {
         $order = array();
     }
     $objView =& CreateObject('dcl.boView');
     $objView->table = 'tickets';
     if (count($personnel) > 0 || count($department) > 0) {
         $fieldList = array('responsible', 'createdby', 'closedby');
         $bStrippedDepartments = false;
         $pers_sel = array();
         foreach ($fieldList as $field) {
             if (!isset($_REQUEST[$field]) || $_REQUEST[$field] != '1') {
                 continue;
             }
             if (count($personnel) > 0) {
                 if (!$bStrippedDepartments) {
                     $bStrippedDepartments = true;
                     // Have actual personnel?  If so, only set personnel for their associated departments instead of the department
                     // then unset the department from the array
                     foreach ($personnel as $encoded_pers) {
                         list($dpt_id, $pers_id) = explode(',', $encoded_pers);
                         $pers_sel[count($pers_sel)] = $pers_id;
                         if (count($department) > 0 && in_array($dpt_id, $department)) {
                             foreach ($department as $key => $department_id) {
                                 if ($department_id == $dpt_id) {
                                     unset($department[$key]);
                                     break;
                                 }
                             }
                         }
                     }
                 }
                 $pers_sel = DCL_Sanitize::ToIntArray($pers_sel);
                 if (count($pers_sel) > 0) {
                     $objView->AddDef('filter', $field, $pers_sel);
                 }
             }
             if (count($department) > 0) {
                 $objView->AddDef('filter', $field . '.department', $department);
             }
         }
     }
     $fieldList = array('priority', 'type', 'account', 'entity_source_id');
     while (list($key, $field) = each($fieldList)) {
         ${$field} = DCL_Sanitize::ToIntArray(${$field});
         if (count(${$field}) > 0) {
             $objView->AddDef('filter', $field, ${$field});
         }
     }
     if (trim($tags) != '') {
         $objView->AddDef('filter', 'dcl_tag.tag_desc', $tags);
     }
     if (count($is_public) > 0) {
         foreach ($is_public as $publicValue) {
             $objView->AddDef('filter', 'is_public', $oDB->Quote(DCL_Sanitize::ToYN($publicValue)));
         }
     }
     if (count($module_id) > 0) {
         // Have modules?  If so, only set module IDs for their associated products instead of the product ID
         // then unset the product id from the array
         $module = array();
         foreach ($module_id as $encoded_mod) {
             list($mod_prod_id, $mod_id) = explode(',', $encoded_mod);
             $module[count($module)] = $mod_id;
             if (count($product) > 0 && in_array($mod_prod_id, $product)) {
                 foreach ($product as $key => $product_id) {
                     if ($product_id == $mod_prod_id) {
                         unset($product[$key]);
                         break;
                     }
                 }
             }
         }
         $module = DCL_Sanitize::ToIntArray($module);
         if (count($module) > 0) {
             $objView->AddDef('filter', 'module_id', $module);
         }
     }
     if (count($product) > 0) {
         $objView->AddDef('filter', 'product', $product);
     }
     if (count($status) > 0) {
         // Have statuses?  If so, only set status IDs for their associated types instead of the status type ID
         // then unset the status type id from the array
         $statuses = array();
         foreach ($status as $encoded_status) {
             list($type_id, $status_id) = explode(',', $encoded_status);
             if (($type_id = DCL_Sanitize::ToInt($type_id)) !== null && ($status_id = DCL_Sanitize::ToInt($status_id)) !== null) {
                 $statuses[count($statuses)] = $status_id;
                 if (count($dcl_status_type) > 0 && in_array($type_id, $dcl_status_type)) {
                     foreach ($dcl_status_type as $key => $status_type_id) {
                         if ($status_type_id == $type_id) {
                             unset($dcl_status_type[$key]);
                             break;
                         }
                     }
                 }
             }
         }
         $objView->AddDef('filter', 'status', $statuses);
     }
     if (count($dcl_status_type) > 0) {
         $objView->AddDef('filter', 'statuses.dcl_status_type', $dcl_status_type);
     }
     if ($dateFrom !== null || $dateTo !== null) {
         if ($dateFrom !== null) {
             $dateFrom .= ' 00:00:00';
         } else {
             $dateFrom = '';
         }
         if ($dateTo !== null) {
             $dateTo .= ' 23:59:59';
         } else {
             $dateTo = '';
         }
         $fieldList = array('createdon', 'closedon', 'statuson', 'lastactionon');
         foreach ($fieldList as $field) {
             if (${$field} == '1') {
                 $objView->AddDef('filterdate', $field, array($dateFrom, $dateTo));
             }
         }
     }
     if ($searchText != '') {
         $objView->AddDef('filterlike', 'issue', $searchText);
         $objView->AddDef('filterlike', 'summary', $searchText);
     }
     if (count($columns) > 0) {
         $objView->AddDef('columns', '', $columns);
     } else {
         $objView->AddDef('columns', '', array('ticketid', 'responsible', 'product', 'account', 'status', 'contact', 'contactphone', 'summary'));
     }
     if (count($groups) > 0) {
         foreach ($groups as $key => $groupField) {
             if ($groupField == 'priorities.name') {
                 $groups[$key] = 'priorities.weight';
             } else {
                 if ($groupField == 'severities.name') {
                     $groups[$key] = 'severities.weight';
                 }
             }
         }
         $objView->AddDef('groups', '', $groups);
     }
     if (count($columnhdrs) > 0) {
         $objView->AddDef('columnhdrs', '', $columnhdrs);
     }
     if (count($order) > 0) {
         foreach ($order as $key => $orderField) {
             if ($orderField == 'priorities.name') {
                 $order[$key] = 'priorities.weight';
             } else {
                 if ($orderField == 'severities.name') {
                     $order[$key] = 'severities.weight';
                 }
             }
         }
         $objView->AddDef('order', '', $order);
     } else {
         $objView->AddDef('order', '', array('ticketid'));
     }
     $objView->style = 'report';
     if (isset($_REQUEST['title']) && $_REQUEST['title'] != '') {
         $objView->title = $oDB->GPCStripSlashes($_REQUEST['title']);
     } else {
         $objView->title = STR_TCK_TICKETSEARCHRESULTS;
     }
     $obj =& CreateObject('dcl.htmlTicketResults');
     $obj->Render($objView);
 }
 function show()
 {
     global $dcl_info, $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_CONTACT, DCL_PERM_VIEW)) {
         return PrintPermissionDenied();
     }
     CleanArray($_REQUEST);
     $oDB = new dclDB();
     $oView = CreateObject('dcl.boView');
     $oView->table = 'dcl_contact';
     $oView->AddDef('columnhdrs', '', array(STR_CMMN_ID, STR_CMMN_ACTIVE, STR_CMMN_LASTNAME, STR_CMMN_FIRSTNAME, 'Organization', 'Phone', 'Email', 'Internet'));
     $oView->AddDef('columns', '', array('contact_id', 'active', 'last_name', 'first_name'));
     $oView->AddDef('order', '', array('last_name', 'first_name', 'contact_id'));
     $oView->numrows = 25;
     $filterActive = DCL_Sanitize::ToYN($_REQUEST['filterActive']);
     if ($filterActive == 'Y' || $filterActive == 'N') {
         $oView->AddDef('filter', 'active', "'{$filterActive}'");
     }
     $filterSearch = isset($_REQUEST['filterSearch']) ? $_REQUEST['filterSearch'] : '';
     if ($filterSearch != '') {
         $oView->AddDef('filterlike', 'last_name', $filterSearch);
     }
     $filterStartsWith = isset($_REQUEST['filterStartsWith']) ? $_REQUEST['filterStartsWith'] : '';
     if ($filterStartsWith != '') {
         $oView->AddDef('filterstart', 'last_name', $filterStartsWith);
     }
     $filterOrgID = isset($_REQUEST['org_id']) ? DCL_Sanitize::ToInt($_REQUEST['org_id']) : null;
     if ($filterOrgID !== null) {
         $oView->AddDef('filter', 'dcl_org_contact.org_id', $filterOrgID);
     }
     $this->sColumnTitle = STR_CMMN_OPTIONS;
     $this->bShowPager = true;
     $this->Render($oView);
 }
 function modify($aSource)
 {
     $aSource['preferred'] = @DCL_Sanitize::ToYN($aSource['preferred']);
     parent::modify($aSource);
 }
 function dbmodify()
 {
     global $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_FAQQUESTION, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     if (($iID = @DCL_Sanitize::ToInt($_REQUEST['topicid'])) === null) {
         trigger_error('Data sanitize failed.');
         return;
     }
     $objF =& CreateObject('dcl.dbFaqtopics');
     if ($objF->Load($iID) == -1) {
         return;
     }
     $obj =& CreateObject('dcl.dbFaqquestions');
     $obj->InitFromGlobals();
     $obj->active = @DCL_Sanitize::ToYN($_REQUEST['active']);
     $obj->modifyby = $GLOBALS['DCLID'];
     $obj->modifyon = DCL_NOW;
     $obj->Edit();
     $objH =& CreateObject('dcl.htmlFaqtopics');
     $objH->ShowTopic($objF);
 }
 function modify(&$aSource)
 {
     global $dcl_info, $g_oSec;
     commonHeader();
     if ($this->oDB->Load($aSource['resid']) == -1) {
         return;
     }
     if (!$g_oSec->HasPerm(DCL_ENTITY_RESOLUTION, DCL_PERM_MODIFY, $this->oDB->ticketid)) {
         return PrintPermissionDenied();
     }
     $iOrigStatus = $this->oDB->status;
     $this->oDB->InitFromArray($aSource);
     $this->oDB->is_public = @DCL_Sanitize::ToYN($_REQUEST['is_public']);
     $oTicket =& CreateObject('dcl.dbTickets');
     $oTicket->Load($this->oDB->ticketid);
     $oTicket->lastactionon = DCL_NOW;
     $notify = '4';
     if ($oTicket->IsLastResolution($this->oDB->ticketid, $this->oDB->resid)) {
         if ($this->oDB->status != $oTicket->status) {
             $oStatus =& CreateObject('dcl.dbStatuses');
             $notify .= ',3';
             $oTicket->statuson = DCL_NOW;
             if ($oStatus->GetStatusType($this->oDB->status) == 2) {
                 $notify .= ',2';
                 $oTicket->closedby = $GLOBALS['DCLID'];
                 $oTicket->closedon = DCL_NOW;
             } else {
                 if ($oStatus->GetStatusType($this->oDB->status) == 1) {
                     $notify .= ',1';
                 }
             }
             $oTicket->status = $this->oDB->status;
         } else {
             $this->oDB->status = $iOrigStatus;
         }
     }
     $this->oDB->BeginTransaction();
     $this->oDB->Edit();
     $oTicket->Edit();
     $this->oDB->EndTransaction();
     $objWtch =& CreateObject('dcl.boWatches');
     $objWtch->sendTicketNotification($oTicket, $notify);
     @$this->sendCustomerResponseEmail($oTicket);
 }
 function submitModify()
 {
     global $g_oSec;
     commonHeader();
     if (($id = DCL_Sanitize::ToInt($_REQUEST['hotlist_id'])) === null) {
         trigger_error('Data sanitize failed.');
         return;
     }
     if (!$g_oSec->HasPerm(DCL_ENTITY_HOTLIST, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     $obj = CreateObject('dcl.boHotlist');
     CleanArray($_REQUEST);
     $active = @DCL_Sanitize::ToYN($_REQUEST['active']);
     $obj->modify(array('hotlist_id' => $id, 'hotlist_tag' => $_REQUEST['hotlist_tag'], 'active' => $active, 'hotlist_desc' => $_REQUEST['hotlist_desc'], 'closed_by' => $active == 'Y' ? null : $GLOBALS['DCLID'], 'closed_on' => $active == 'Y' ? null : DCL_NOW));
     $oWS = createObject('dcl.htmlHotlistBrowse');
     $oWS->show();
 }
 function modify($aSource)
 {
     $aSource['contact_type_is_main'] = @DCL_Sanitize::ToYN($aSource['contact_type_is_main']);
     parent::modify($aSource);
 }
 function dbmodify()
 {
     global $dcl_info, $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_FORMTEMPLATES, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     if (($iID = @DCL_Sanitize::ToInt($_REQUEST['dcl_chklst_tpl_id'])) === null) {
         trigger_error('Data sanitize failed.');
         return;
     }
     $o =& CreateObject('dcl.dbChklstTpl');
     if ($o->Load($iID) != -1) {
         $sFileName = @DCL_Sanitize::ToFileName('userfile');
         if ($sFileName !== null) {
             $sName = '';
             $oXML =& CreateObject('dcl.xmlDoc');
             $oXML->ParseFile($sFileName);
             $oXML->FindChildNode($oXML->root, 'Name');
             if ($oXML->currentNode != NULL) {
                 $sName = $oXML->currentNode->data;
                 $oXML->FindChildNode($oXML->root, 'Version');
                 if ($oXML->currentNode != NULL) {
                     if ($sName != '') {
                         $sName .= ' ';
                     }
                     $sName .= $oXML->currentNode->data;
                 }
                 $o->dcl_chklst_tpl_name = $sName;
             }
         }
         $o->dcl_chklst_tpl_active = @DCL_Sanitize::ToYN($_REQUEST['dcl_chklst_tpl_active']);
         $o->BeginTransaction();
         $o->Edit();
         if ($sFileName !== null) {
             // Insert successful, now stow file in its place
             $filePath = $this->GetTplPath($o->dcl_chklst_tpl_id, true);
             if (copy($sFileName, $filePath)) {
                 $o->EndTransaction();
             } else {
                 $o->RollbackTransaction();
                 echo STR_BO_UPLOADERR;
             }
         } else {
             $o->EndTransaction();
         }
     }
     $this->show();
 }
 function show()
 {
     global $dcl_info, $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_ORG, DCL_PERM_VIEW)) {
         return PrintPermissionDenied();
     }
     $oView = CreateObject('dcl.boView');
     $oView->table = 'dcl_org';
     $oView->AddDef('columnhdrs', '', array(STR_CMMN_ID, STR_CMMN_ACTIVE, STR_CMMN_NAME, 'Phone', 'Email', 'Internet'));
     $oView->AddDef('columns', '', array('org_id', 'active', 'name', 'dcl_org_phone.phone_number', 'dcl_org_email.email_addr', 'dcl_org_url.url_addr'));
     $oView->AddDef('order', '', array('name'));
     $oView->numrows = 25;
     $filterActive = @DCL_Sanitize::ToYN($_REQUEST['filterActive']);
     if ($filterActive == 'Y' || $filterActive == 'N') {
         $oView->AddDef('filter', 'active', "'{$filterActive}'");
     }
     $filterSearch = isset($_REQUEST['filterSearch']) ? $_REQUEST['filterSearch'] : '';
     if ($filterSearch != '') {
         $oView->AddDef('filterlike', 'name', $filterSearch);
     }
     $filterStartsWith = isset($_REQUEST['filterStartsWith']) ? $_REQUEST['filterStartsWith'] : '';
     if ($filterStartsWith != '') {
         $oView->AddDef('filterstart', 'name', $filterStartsWith);
     }
     $this->sColumnTitle = STR_CMMN_OPTIONS;
     $this->bShowPager = true;
     $this->Render($oView);
 }
 function dbmodify()
 {
     global $dcl_info, $g_oSec;
     commonHeader();
     if (!$g_oSec->HasPerm(DCL_ENTITY_TIMECARD, DCL_PERM_MODIFY)) {
         return PrintPermissionDenied();
     }
     $objTC =& CreateObject('dcl.dbTimeCards');
     $objOldTC =& CreateObject('dcl.dbTimeCards');
     $objTC->InitFromGlobals();
     if ($g_oSec->IsPublicUser()) {
         $objTC->is_public = 'Y';
     } else {
         $objTC->is_public = @DCL_Sanitize::ToYN($_REQUEST['is_public']);
     }
     if ($objOldTC->Load($objTC->id) == -1) {
         return;
     }
     if ($g_oSec->IsPublicUser() && $objOldTC->is_public == 'N') {
         return PrintPermissionDenied();
     }
     // If the hours change, we'll need to adjust the workorder
     $hoursDiff = $objTC->hours - $objOldTC->hours;
     $objWO =& CreateObject('dcl.dbWorkorders');
     if ($objWO->Load($objTC->jcn, $objTC->seq) == -1) {
         return;
     }
     $woChanged = false;
     $notify = '4';
     // See if any time cards were issued after this one.  If not, assume
     // that this time card was the last one entered and affected the work order
     // status when input.  In other words, adjust as needed.
     if ($objTC->status != $objOldTC->status) {
         $notify .= ',3';
         $objQueryTC =& CreateObject('dcl.dbTimeCards');
         if ($objQueryTC->IsLastTimeCard($objTC->id, $objTC->jcn, $objTC->seq)) {
             // We're the last one!  This does (of course) assume that time cards
             // are entered sequentially in correct chronological order.
             if ($objTC->status != $objWO->status) {
                 $objWO->status = $objTC->status;
                 $objWO->statuson = date($dcl_info['DCL_TIMESTAMP_FORMAT']);
                 $woChanged = true;
                 $oStatus =& CreateObject('dcl.dbStatuses');
                 if ($oStatus->GetStatusType($objTC->status) == 2) {
                     $objWO->closedby = $objTC->actionby;
                     $objWO->closedon = $objTC->actionon;
                     $objWO->etchours = 0.0;
                     $notify .= ',2';
                     // also need to close all incomplete tasks and warn user if it happens
                     $this->closeIncompleteTasks($objTC->jcn, $objTC->seq);
                 }
             }
         } else {
             // Don't allow status change if more are left.  Last time card controls status of WO
             $objTC->status = $objOldTC->status;
         }
     }
     if ($hoursDiff != 0) {
         $objWO->totalhours += $hoursDiff;
         $woChanged = true;
     }
     if ($woChanged) {
         $objTC->BeginTransaction();
     }
     $objTC->Edit();
     if ($woChanged) {
         $objWO->edit();
         $objTC->EndTransaction();
     }
     $objWtch =& CreateObject('dcl.boWatches');
     $objWtch->sendNotification($objWO, $notify);
     $obj =& CreateObject('dcl.htmlWorkOrderDetail');
     $obj->Show($objTC->jcn, $objTC->seq);
 }
 function sendTicketNotification($obj, $actions, $bShowNotifyMsg = true)
 {
     global $dcl_info, $g_oSession;
     if ($dcl_info['DCL_SMTP_ENABLED'] != 'Y' || !is_object($obj)) {
         return;
     }
     $oMail =& CreateObject('dcl.boSMTP');
     $oMail->isHtml = $dcl_info['DCL_TCK_NOTIFICATION_HTML'] == 'Y';
     // Got the message constructed, so send it!
     $objWtch =& CreateObject('dcl.dbWatches');
     $query = "select distinct email_addr, whoid from personnel " . $objWtch->JoinKeyword . " dcl_contact_email ON personnel.contact_id=dcl_contact_email.contact_id AND dcl_contact_email.preferred = 'Y' ";
     $query .= $objWtch->JoinKeyword . ' watches ON id=whoid ';
     $query .= "where id = whoid AND actions in ({$actions}) and (";
     $query .= sprintf('(typeid=4 AND whatid1=%d)', $obj->product);
     $query .= sprintf(' or (typeid=5 and whatid1=%d)', $obj->ticketid);
     if ($obj->account > 0) {
         $query .= " or (typeid = 7 and whatid1 = {$obj->account})";
     }
     $query .= sprintf(') AND whoid != %d', $GLOBALS['DCLID']);
     $query .= " AND active = 'Y'";
     $arrEmail = array();
     $arrPublicEmail = array();
     $mailFrom = '';
     if ($g_oSession->Value('USEREMAIL') != '') {
         $mailFrom = '<' . $g_oSession->Value('USEREMAIL') . '>';
     }
     if ($this->oMeta == null) {
         $this->oMeta =& CreateObject('dcl.DCL_MetadataDisplay');
     }
     $bIsPublic = false;
     if ($obj->responsible != $GLOBALS['DCLID'] && $this->oMeta->GetPersonnel($obj->responsible) != '' && $this->oMeta->oPersonnel->active == 'Y') {
         $aContact = $this->oMeta->GetContact($this->oMeta->oPersonnel->contact_id);
         if (isset($aContact['email']) && !isset($arrEmail[$aContact['email']]) && $obj->CanView($obj, $obj->responsible, $bIsPublic)) {
             if ($bIsPublic) {
                 $arrPublicEmail[$aContact['email']] = 1;
             } else {
                 $arrEmail[$aContact['email']] = 1;
             }
         }
     }
     if ($obj->createdby != $GLOBALS['DCLID'] && $this->oMeta->GetPersonnel($obj->createdby) != '' && $this->oMeta->oPersonnel->active == 'Y') {
         $aContact = $this->oMeta->GetContact($this->oMeta->oPersonnel->contact_id);
         if (isset($aContact['email']) && !isset($arrEmail[$aContact['email']]) && $obj->CanView($obj, $obj->createdby, $bIsPublic)) {
             $oPrefs = CreateObject('dcl.dbPreferences');
             if ($oPrefs->Load($obj->createdby) == -1 || $oPrefs->Value('DCL_PREF_CREATED_WATCH_OPTION') == '' || strpos($actions, $oPrefs->Value('DCL_PREF_CREATED_WATCH_OPTION')) !== false) {
                 if ($bIsPublic) {
                     $arrPublicEmail[$aContact['email']] = 1;
                 } else {
                     $arrEmail[$aContact['email']] = 1;
                 }
             }
         }
     }
     if ('Y' == @DCL_Sanitize::ToYN($_REQUEST['copy_me_on_notification']) && $g_oSession->Value('USEREMAIL') != '') {
         if (!isset($arrEmail[$g_oSession->Value('USEREMAIL')]) && !isset($arrPublicEmail[$g_oSession->Value('USEREMAIL')])) {
             if ($obj->CanView($obj, $GLOBALS['DCLID'], $bIsPublic)) {
                 if ($bIsPublic) {
                     $arrPublicEmail[$g_oSession->Value('USEREMAIL')] = 1;
                 } else {
                     $arrEmail[$g_oSession->Value('USEREMAIL')] = 1;
                 }
             }
         }
     }
     if ($objWtch->Query($query) != -1) {
         while ($objWtch->next_record()) {
             if (!isset($arrEmail[$objWtch->f(0)])) {
                 if ($obj->CanView($obj, $objWtch->f(1), $bIsPublic)) {
                     if ($bIsPublic) {
                         $arrPublicEmail[$objWtch->f(0)] = 1;
                     } else {
                         $arrEmail[$objWtch->f(0)] = 1;
                     }
                 }
             }
         }
     }
     if (count($arrEmail) == 0 && count($arrPublicEmail) == 0) {
         return;
     }
     if (count($arrEmail) > 0 && count($arrPublicEmail) > 0) {
         foreach ($arrPublicEmail as $sEmail => $junk) {
             if (isset($arrEmail[$sEmail])) {
                 unset($arrEmail[$sEmail]);
             }
         }
     }
     // Here we go!
     $toAddr = '';
     if ($this->oMeta->GetPriority($obj->priority) != '' && $this->oMeta->oPriority->weight == 1) {
         $oMail->AddHeader('X-Priority: 1');
     }
     $oMail->from = $mailFrom;
     $oMail->subject = sprintf('[%s %d] [%s] [%s] %s', STR_TCK_TICKET, $obj->ticketid, $this->oMeta->GetPersonnel($obj->responsible), $this->oMeta->GetStatus($obj->status), $obj->summary);
     $oMail->body = $this->GetTicketNotificationBody($obj, true);
     $oMail->to = array();
     foreach ($arrEmail as $email => $junk) {
         $oMail->to[] = '<' . $email . '>';
         if ($toAddr != '') {
             $toAddr .= ', ';
         }
         $toAddr .= $email;
     }
     if (count($oMail->to) > 0) {
         $bSuccess = $oMail->Send();
         if ($bShowNotifyMsg && $toAddr != '') {
             if ($bSuccess) {
                 trigger_error(sprintf(STR_BO_MAILSENT, $toAddr), E_USER_NOTICE);
             } else {
                 trigger_error('Could not send email notification.', E_USER_ERROR);
             }
         }
     }
     if ($obj->is_public == 'Y' && count($arrPublicEmail) > 0) {
         $oMail->body = $this->GetTicketNotificationBody($obj, true);
         $oMail->to = array();
         foreach ($arrPublicEmail as $email => $junk) {
             $oMail->to[] = '<' . $email . '>';
             if ($toAddr != '') {
                 $toAddr .= ', ';
             }
             $toAddr .= $email;
         }
         if (count($oMail->to) < 1) {
             return;
         }
         $bSuccess = $oMail->Send();
         if ($bShowNotifyMsg && $toAddr != '') {
             if ($bSuccess) {
                 trigger_error(sprintf(STR_BO_MAILSENT, $toAddr), E_USER_NOTICE);
             } else {
                 trigger_error('Could not send email notification.', E_USER_ERROR);
             }
         }
     }
 }