示例#1
0
 function createExceptionPolicy($company_id)
 {
     $epcf = new ExceptionPolicyControlFactory();
     $epcf->setCompany($company_id);
     $epcf->setName('Default');
     if ($epcf->isValid()) {
         $epc_id = $epcf->Save();
         Debug::Text('aException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
         if ($epc_id === TRUE) {
             $epc_id = $data['id'];
         }
         Debug::Text('bException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
         $data['exceptions'] = array('S1' => array('active' => TRUE, 'severity_id' => 10), 'S2' => array('active' => TRUE, 'severity_id' => 30), 'S3' => array('active' => TRUE, 'severity_id' => 10, 'grace' => 300, 'watch_window' => 3600), 'S4' => array('active' => TRUE, 'severity_id' => 20, 'grace' => 300, 'watch_window' => 3600), 'S5' => array('active' => TRUE, 'severity_id' => 20, 'grace' => 300, 'watch_window' => 3600), 'S6' => array('active' => TRUE, 'severity_id' => 10, 'grace' => 300, 'watch_window' => 3600), 'S7' => array('active' => TRUE, 'severity_id' => 30), 'S8' => array('active' => TRUE, 'severity_id' => 10), 'M1' => array('active' => TRUE, 'severity_id' => 30), 'M2' => array('active' => TRUE, 'severity_id' => 30), 'L3' => array('active' => TRUE, 'severity_id' => 30), 'M3' => array('active' => TRUE, 'severity_id' => 30));
         if (count($data['exceptions']) > 0) {
             foreach ($data['exceptions'] as $code => $exception_data) {
                 Debug::Text('Looping Code: ' . $code, __FILE__, __LINE__, __METHOD__, 10);
                 $epf = new ExceptionPolicyFactory();
                 $epf->setExceptionPolicyControl($epc_id);
                 if (isset($exception_data['active'])) {
                     $epf->setActive(TRUE);
                 } else {
                     $epf->setActive(FALSE);
                 }
                 $epf->setType($code);
                 $epf->setSeverity($exception_data['severity_id']);
                 if (isset($exception_data['demerit']) and $exception_data['demerit'] != '') {
                     $epf->setDemerit($exception_data['demerit']);
                 }
                 if (isset($exception_data['grace']) and $exception_data['grace'] != '') {
                     $epf->setGrace($exception_data['grace']);
                 }
                 if (isset($exception_data['watch_window']) and $exception_data['watch_window'] != '') {
                     $epf->setWatchWindow($exception_data['watch_window']);
                 }
                 if ($epf->isValid()) {
                     $epf->Save();
                 }
             }
             Debug::Text('Creating Exception Policy ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
             return $epc_id;
         }
     }
     Debug::Text('Failed Creating Exception Policy!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
                 } else {
                     $epf->setActive(FALSE);
                 }
                 $epf->setType($code);
                 $epf->setSeverity($exception_data['severity_id']);
                 $epf->setEmailNotification($exception_data['email_notification_id']);
                 if (isset($exception_data['demerit']) and $exception_data['demerit'] != '') {
                     $epf->setDemerit($exception_data['demerit']);
                 }
                 if (isset($exception_data['grace']) and $exception_data['grace'] != '') {
                     $epf->setGrace($exception_data['grace']);
                 }
                 if (isset($exception_data['watch_window']) and $exception_data['watch_window'] != '') {
                     $epf->setWatchWindow($exception_data['watch_window']);
                 }
                 if ($epf->isValid()) {
                     $epf->Save();
                 }
             }
         }
         Redirect::Page(URLBuilder::getURL(NULL, 'ExceptionPolicyControlList.php'));
         break;
     }
 default:
     $type_options = $epf->getTypeOptions($current_company->getProductEdition());
     if (isset($id) and $id != '') {
         BreadCrumb::setCrumb($title);
         $epclf = new ExceptionPolicyControlListFactory();
         $epclf->getByIdAndCompanyID($id, $current_company->getID());
         foreach ($epclf as $epc_obj) {
             //Debug::Arr($station,'Department', __FILE__, __LINE__, __METHOD__,10);