Example #1
0
function alerts_list()
{
    //Go through all the hosts and determine if any alerts should be created
    global $hosts;
    $h = new Host();
    $hosts = $h->find();
    $alerts = new Alert();
    foreach ($hosts as $host) {
        foreach ($host->ports() as $port) {
            $status = $host->get_port_status($port, true);
            if ($status == 0) {
                if ($alert = $alerts->find("WHERE host_id = " . $host->id . " AND port = " . $port)) {
                    //There is already an alert for this, go through each user and see what their preference for this port is
                    send_user_alerts($host->id, $port, $alert->id, 'all');
                } else {
                    $alert = new alert();
                    $alert->message = "HOST: " . $host->name . "PORT: " . $port . "";
                    $alert->user_id = 1;
                    $alert->host_id = $host->id;
                    $alert->port = $port;
                    $alert->sent_on = time();
                    $alert->save();
                    send_user_alerts($host->id, $port, $alert->id, 'single');
                    //Go through each user and determine what their preference for this port is.
                }
            } else {
                //The port is up, but we need to set up reports if there is an existing one!
                if ($alert = $alerts->find("WHERE host_id = " . $host->id . " AND port = " . $port)) {
                    //There is already an alert for this, go through each user and see what their preference for this port is
                    send_user_alerts($host->id, $port, $alert->id, 'single');
                }
            }
        }
    }
    render();
}
		}
		$file = preg_replace($pattern3,$str3,$file);	
	//reject plan display
		$pattern5 ="/<!--rejectplan_start-->(.*?)<!--rejectplan_end-->/s";
		if(count($rejres)==0)
		{
			$file = preg_replace($pattern5,$space,$file);
		}
	//Rejected Plan
		$pattern2 = "/<{rejected_loopstart(.*?)<{rejected_loopend}>/s";
		preg_match($pattern2,$file,$arr2);
		$match2 = $arr2[0];
		$str2="";
		for($i=0;$i<count($rejres);$i++)
		{
			$uid = $rejres[$i];
			$selqry = "select username from $user where user_id='$uid'";
			$selres = $db_object->get_a_line($selqry);
			$uname = $selres['username'];
			$str2.=preg_replace("/<{(.*?)}>/e","$$1",$match2);
		}
		$file = preg_replace($pattern2,$str2,$file);
		$file = $common->direct_replace($db_object,$file,$val);
		echo $file;			
		}//end view
	}//end class
	$ob = new alert;
	$ob->view($db_object,$common,$user_id,$error_msg);
include_once("footer.php");
?>
Example #3
0
 function form_ccdev_breastfeed()
 {
     if (func_num_args() > 0) {
         $arg_list = func_get_args();
         $menu_id = $arg_list[0];
         $post_vars = $arg_list[1];
         $get_vars = $arg_list[2];
         $validuser = $arg_list[3];
         $isadmin = $arg_list[4];
     }
     $patient_id = healthcenter::get_patient_id($get_vars["consult_id"]);
     $ccdev_id = ccdev::registry_record_exists($patient_id);
     $q_dob = mysql_query("SELECT patient_dob FROM m_patient where patient_id='{$patient_id}'") or die("Cannot query 419 " . mysql_error());
     list($patient_dob) = mysql_fetch_array($q_dob);
     if ($ccdev_id == '0') {
         print "<font color='red'>" . LBL_NO_REGISTRY_ID . "</font><br/>";
     } else {
         echo "<form name='form_ccdev_bfed' action = '" . $_SERVER["SELF"] . "?page=" . $get_vars["page"] . "&menu_id={$menu_id}&consult_id=" . $get_vars["consult_id"] . "&ptmenu=" . $get_vars["ptmenu"] . "&module=" . $get_vars["module"] . "&ccdev=BFED' method='post'>";
         echo "<table width='400'>";
         echo "<tr><td><b>BREASTFEEDING STATUS</b></td></tr>";
         echo "<tr><td><span class='tinylight'>Please tick the month if mother exclusively breastfed this\tchild. To set month 6 date to blank, just delete the contents of the date box. Dates at the end of the months are projected as well.</spans></td></tr>";
         for ($i = 1; $i < 7; $i++) {
             $field = 'bfed_month' . $i;
             $buffer_day = $i * 30;
             $month_date = alert::compute_buffer_date($patient_dob, $buffer_day);
             $q_field = mysql_query("SELECT {$field}, bfed_month6_date FROM m_patient_ccdev WHERE ccdev_id='{$ccdev_id}'") or die("Cannot query: 433");
             list($bfed_status, $bfed_date) = mysql_fetch_array($q_field);
             echo "<tr><td>";
             if ($bfed_status == 'Y') {
                 echo "<input type='checkbox' name='bfed_month[]' value='{$i}' checked>Month {$i} ({$month_date})</input>";
             } else {
                 echo "<input type='checkbox' name='bfed_month[]' value='{$i}'><font color='red'>Month {$i} ({$month_date})</font></input>";
             }
             if ($i == 6) {
                 if ($bfed_date == '0000-00-00') {
                     $bfed_six_value = '';
                 } else {
                     list($y, $m, $d) = explode('-', $bfed_date);
                     $bfed_six_value = $m . '/' . $d . '/' . $y;
                 }
                 echo "&nbsp;&nbsp;&nbsp;<input type='text' name='date_bfed_six' size='7' value='{$bfed_six_value}'>&nbsp;";
                 echo "<a href=\"javascript:show_calendar4('document.form_ccdev_bfed.date_bfed_six', document.form_ccdev_bfed.date_bfed_six.value);\"><img src='../images/cal.gif' width='16' height='16' border='0' alt='Click Here to Pick up the date'></a><br>";
                 echo "</input>";
             }
             echo "</td></tr>";
         }
         echo "<tr><td><input type='submit' name='submitccdev' value='Save Breastfeeding Status' style='border: 1px solid #000000'>&nbsp;<input type='reset' name='reset' value='Reset' style='border: 1px solid #000000'></td></tr>";
         echo "</table>";
         echo "</form>";
     }
 }
Example #4
0
<?php

// BEGIN SERVER CODE: DO NOT EDIT
// Server generated code
// Generated 2010-10-08 00:36:56
// Module: _module.php
// Author: Herman Tolentino MD
//
if (file_exists('../modules/alert/class.alert.php')) {
    include '../modules/alert/class.alert.php';
    $alert = new alert();
    if (!$module->activated('alert') && $initmod) {
        $alert->init_sql();
        $alert->init_menu();
        $alert->init_deps();
        $alert->init_lang();
        $alert->init_help();
    }
}
if (file_exists('../modules/appointment/class.appointment.php')) {
    include '../modules/appointment/class.appointment.php';
    $appointment = new appointment();
    if (!$module->activated('appointment') && $initmod) {
        $appointment->init_sql();
        $appointment->init_menu();
        $appointment->init_deps();
        $appointment->init_lang();
        $appointment->init_help();
    }
}
if (file_exists('../modules/barangay/class.barangay.php')) {
Example #5
0
 function check_sms_alert($date_passed)
 {
     $alert = new alert();
     $arr_alert = array();
     $include_wkend = 0;
     if (isset($date_passed)) {
         $today = $date_passed;
     } else {
         $today = date('Y-m-d');
         if (date('l', strtotime($today)) == 'Friday') {
             $include_wkend = 1;
         }
     }
     //echo $today;
     //echo date('l',strtotime($today));
     for ($i = 1; $i <= 2; $i++) {
         $date = strtotime("+{$i} day", strtotime($today));
         //echo date("Y-m-d", $date)."<br>";
     }
     $q_sms_alert = mysql_query("SELECT sms_id FROM m_lib_sms_alert WHERE alert_date='{$today}'") or die("Cannot query 732: " . mysql_error());
     $q_fam_id = mysql_query("SELECT DISTINCT a.family_id FROM m_family_address a, m_family_members b, m_lib_barangay c WHERE a.family_id=b.family_id AND a.barangay_id=c.barangay_id ORDER by c.barangay_name ASC") or die("Cannot query 1576: " . mysql_error());
     while ($r_fam = mysql_fetch_array($q_fam_id)) {
         if ($alert->check_px_enrolled_sms($r_fam['family_id'])) {
             array_push($arr_alert, $alert->determine_alert_hh($r_fam['family_id']));
         }
         //echo $r_fam[family_id].' ';
         //print_r($arr_alert);
         //echo "<br><br><br>";
     }
     if (mysql_num_rows($q_sms_alert) == 0) {
         foreach ($arr_alert as $key1 => $value1) {
             foreach ($value1 as $key2 => $value2) {
                 foreach ($value2 as $key3 => $value3) {
                     foreach ($value3 as $key4 => $value4) {
                         foreach ($value4 as $key5 => $value5) {
                             foreach ($value5 as $key6 => $value6) {
                                 //key6 is the patient_id
                                 $q_name = mysql_query("SELECT patient_lastname,patient_firstname FROM m_patient WHERE patient_id='{$key6}'") or die("Cannot query 1545: " . mysql_error());
                                 list($lname, $fname) = mysql_fetch_array($q_name);
                                 $ngalan = $lname . ', ' . $fname;
                                 foreach ($value6 as $key7 => $alert_details) {
                                     //echo $key7.'<br>';
                                     //print_r($value6).'<br><br>';
                                     foreach ($alert_details as $alert_id => $arr_alert) {
                                         //arr_alert[0] is the program_id, arr_alert[1] is the base date
                                         if ($alert->determine_px_enrollment($key6, $alert_id)) {
                                             $arr_alert_msg = $alert->check_alert_msg($alert_id, $arr_alert[1], $key6);
                                             if (count($arr_alert_msg) != 0) {
                                                 //print_r($arr_alert_msg);
                                                 //$day_diff = $alert->get_date_diff_days(date('Y-m-d'),$arr_alert[1]);
                                                 $day_diff = $alert->get_date_diff_days($today, $arr_alert[1]);
                                                 //echo $arr_alert[1];
                                                 //echo $key6.' '.$arr_alert[1].'  '.$day_diff.'<br>';
                                                 $mensahe = $alert->get_message($day_diff, $arr_alert_msg, $ngalan, $arr_alert[1]);
                                                 //echo $day_diff.'/'.$ngalan.'/'.$mensahe.'/'.$alert_id.'/'.$arr_alert[1].'<br>xxx';
                                                 if ($mensahe != '') {
                                                     /* $key: patient_id, $arr_alert[0]: program_id, $arr_alert[1]: base date, $alert_id: id for alert, 'queue': sms_status, $mensahe: alert message
                                                      */
                                                     $alert->queue_sms($key6, $arr_alert[0], $arr_alert[1], $alert_id, 'queue', $mensahe);
                                                 }
                                             }
                                         }
                                     }
                                     //$insert_sms_alert = mysql_query("INSERT INTO m_lib_sms_alert SET alert_date=NOW()") or die("Cannot query 735: ".mysql_error());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     } else {
         $arr_config = $alert->get_sms_config();
         if (count($arr_config) != 0) {
             if ($arr_config['sms_time_sched'] <= date('H:i')) {
                 $date_today = date('Y-m-d');
                 $q_alert = mysql_query("SELECT sms_id,alert_date,sms_message,sms_number FROM m_lib_sms_alert WHERE alert_date='{$date_today}' AND sms_status!='sent'") or die("Cannot query 1644: " . mysql_error());
                 if (mysql_num_rows($q_alert) != 0) {
                     while ($r_alert = mysql_fetch_array($q_alert)) {
                         if ($alert->send_sms($arr_config['sms_url'], $arr_config['sms_port'], $r_alert['sms_number'], $r_alert['sms_message'])) {
                             $alert->update_sms_status($r_alert['sms_id'], 'sent');
                         } else {
                             $alert->update_sms_status($r_alert['sms_id'], 'not_sent');
                         }
                     }
                 }
             }
         } else {
             echo "<font>There is no SMS configuration!</font>";
         }
     }
 }
Example #6
0
    public function index()
    {
        $settings = ORM::factory('settings')->find(1);
        $site_name = $settings->site_name;
        $alerts_email = $settings->alerts_email;
        $unsubscribe_message = Kohana::lang('alerts.unsubscribe') . url::site() . 'alerts/unsubscribe/';
        $sms_from = NULL;
        $clickatell = NULL;
        $miles = FALSE;
        // Change to True to calculate distances in Miles
        $max_recipients = 20;
        // Limit each script execution to 50 recipients
        if ($settings->email_smtp == 1) {
            Kohana::config_set('email.driver', 'smtp');
            Kohana::config_set('email.options', array('hostname' => $settings->alerts_host, 'port' => $settings->alerts_port, 'username' => $settings->alerts_username, 'password' => $settings->alerts_password));
        }
        $db = new Database();
        /* Find All Alerts with the following parameters
        		- incident_active = 1 -- An approved incident
        		- incident_alert_status = 1 -- Incident has been tagged for sending
        		
        		Incident Alert Statuses
        		  - 0, Incident has not been tagged for sending. Ensures old incidents are not sent out as alerts
        		  - 1, Incident has been tagged for sending by updating it with 'approved' or 'verified'
        		  - 2, Incident has been tagged as sent. No need to resend again
        		*/
        // 1 - Retrieve All the Incidents that haven't been sent (Process only 1 per script execution)
        $incidents = $db->query("\n\t\t\t\t\t\t\t\t SELECT incident.id, incident_title, \n\t\t\t\t\t\t\t\t incident_description, incident_verified, \n\t\t\t\t\t\t\t\t location.latitude, location.longitude\n\t\t\t\t\t\t\t\t FROM incident\n\t\t\t\t\t\t\t\t INNER JOIN location on location.id = incident.location_id\n\t\t\t\t\t\t\t\t WHERE incident.incident_active=1 AND incident.incident_alert_status = 1 LIMIT 1\n\t\t\t\t\t\t\t\t");
        foreach ($incidents as $incident) {
            $latitude = (double) $incident->latitude;
            $longitude = (double) $incident->longitude;
            // 2 - Retrieve All Qualifying Alertees Based on Distance and Make sure they haven't received this alert,
            // 	   Return Alertees if they haven't requested a Category OR Return Alertees if they specifically asked
            // 	   for this incident region and specific category.
            $distance_type = $miles ? "" : " * 1.609344";
            $alertees = $db->query('
									SELECT DISTINCT alert.*, ((ACOS(SIN(' . $latitude . ' * PI() / 180) * 
									SIN(`alert`.`alert_lat` * PI() / 180) + COS(' . $latitude . ' * PI() / 180) * 
									COS(`alert`.`alert_lat` * PI() / 180) * COS((' . $longitude . ' - `alert`.`alert_lon`)
									 * PI() / 180)) * 180 / PI()) * 60 * 1.1515 ' . $distance_type . ') AS distance
									FROM alert 
									WHERE  alert.alert_confirmed = 1
									HAVING distance <= alert_radius
									');
            $i = 0;
            foreach ($alertees as $alertee) {
                // 3 - Has this incident alert been sent to this alertee?
                $alert_sent = ORM::factory('alert_sent')->where('alert_id', $alertee->id)->where('incident_id', $incident->id)->find();
                $requested_category = true;
                $alert_categories = ORM::factory('alert_category')->select("alert_category.category_id")->where('alert_id', $alertee->id)->find_all();
                // The Alertee requested specific categories for the incident.
                // Make sure the categories are part of this incident.
                $requested_category = alert::requested_category($alert_categories, $incident->id);
                // Alert has not been sent and the alertee requested the incident with the category
                if ($alert_sent->loaded == FALSE && $requested_category) {
                    // 4 - Get Alert Type. 1=SMS, 2=EMAIL
                    $alert_type = (int) $alertee->alert_type;
                    if ($alert_type == 1) {
                        // Save this first
                        $alert = ORM::factory('alert_sent');
                        $alert->alert_id = $alertee->id;
                        $alert->incident_id = $incident->id;
                        $alert->alert_date = date("Y-m-d H:i:s");
                        $alert->save();
                        // Get SMS Numbers
                        if (!empty($settings->sms_no3)) {
                            $sms_from = $settings->sms_no3;
                        } elseif (!empty($settings->sms_no2)) {
                            $sms_from = $settings->sms_no2;
                        } elseif (!empty($settings->sms_no1)) {
                            $sms_from = $settings->sms_no1;
                        } else {
                            $sms_from = "000";
                        }
                        // Admin needs to set up an SMS number
                        $clickatell = new Clickatell();
                        $clickatell->api_id = $settings->clickatell_api;
                        $clickatell->user = $settings->clickatell_username;
                        $clickatell->password = $settings->clickatell_password;
                        $clickatell->use_ssl = false;
                        $clickatell->sms();
                        $message = text::limit_chars($incident->incident_description, 150, "...");
                        //++ We won't verify for now if sms was sent
                        // Leaves too much room for duplicates to be sent out
                        $clickatell->send($alertee->alert_recipient, $sms_from, $message);
                    } elseif ($alert_type == 2) {
                        // Save this first
                        $alert = ORM::factory('alert_sent');
                        $alert->alert_id = $alertee->id;
                        $alert->incident_id = $incident->id;
                        $alert->alert_date = date("Y-m-d H:i:s");
                        $alert->save();
                        //for some reason, mail function complains about bad parameters
                        // in the function so i'm disallowing these characters in the
                        // subject field to allow the mail function to work.
                        $disallowed_chars = array("(", ")", "[", "]", "-");
                        $to = $alertee->alert_recipient;
                        $from = $alerts_email;
                        $subject = trim(str_replace($disallowed_chars, "", $site_name) . ": " . str_replace($disallowed_chars, "", $incident->incident_title));
                        $message = $incident->incident_description . "<p>" . url::base() . "reports/view/" . $incident->id . "</p>" . "<p>" . $unsubscribe_message . "?c=" . $alertee->alert_code . "</p>";
                        //++ We won't verify for now if email was sent
                        // Leaves too much room for duplicates to be sent out
                        email::send($to, $from, $subject, $message, TRUE);
                    }
                    sleep(1);
                    $i++;
                }
                if ($i == $max_recipients) {
                    exit;
                }
            }
            // End For Each Loop
            // Update Incident - All Alerts Have Been Sent!
            $update_incident = ORM::factory('incident', $incident->id);
            if ($update_incident->loaded) {
                $update_incident->incident_alert_status = 2;
                $update_incident->save();
            }
        }
    }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      alert $value A alert object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(alert $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
Example #8
0
 public function index()
 {
     // First, are we allowed to subscribe for alerts via web?
     if (!Kohana::config('settings.allow_alerts')) {
         url::redirect(url::site() . 'main');
     }
     $this->template->header->this_page = $this->themes->this_page = 'alerts';
     $this->template->content = new View('alerts/main');
     // Load the alert radius map view
     $alert_radius_view = new View('alerts/radius');
     $alert_radius_view->show_usage_info = TRUE;
     $alert_radius_view->enable_find_location = TRUE;
     $this->template->content->alert_radius_view = $alert_radius_view;
     // Display Mobile Option?
     $this->template->content->show_mobile = TRUE;
     if (!Kohana::config("settings.sms_provider")) {
         // Hide Mobile
         $this->template->content->show_mobile = FALSE;
     }
     // Retrieve default country, latitude, longitude
     $default_country = Kohana::config('settings.default_country');
     // Retrieve Country Cities
     $this->template->content->cities = $this->_get_cities($default_country);
     // Populate this for backwards compat
     $this->template->content->categories = array();
     // Setup and initialize form field names
     $form = array('alert_mobile' => '', 'alert_mobile_yes' => '', 'alert_email' => '', 'alert_email_yes' => '', 'alert_lat' => '', 'alert_lon' => '', 'alert_radius' => '', 'alert_country' => '', 'alert_confirmed' => '');
     if ($this->user) {
         $form['alert_email'] = $this->user->email;
     }
     // Get Countries
     $countries = array();
     foreach (ORM::factory('country')->orderby('country')->find_all() as $country) {
         // Create a list of all countries
         $this_country = $country->country;
         if (strlen($this_country) > 35) {
             $this_country = substr($this_country, 0, 35) . "...";
         }
         $countries[$country->id] = $this_country;
     }
     //Initialize default value for Alert confirmed hidden value
     $this->template->content->countries = $countries;
     // Copy the form as errors, so the errors will be stored with keys
     // corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // If there is a post and $_POST is not empty
     if ($post = $this->input->post()) {
         $alert_orm = new Alert_Model();
         // HT: created new model and post for mobile alert
         $alert_orm1 = new Alert_Model();
         $post1 = $this->input->post();
         if ($alert_orm->validate($post)) {
             // Yes! everything is valid
             // Save alert and send out confirmation code
             if (!empty($post->alert_mobile)) {
                 // HT: setting value of post1 to alert_orm1
                 $alert_orm1->validate($post1);
                 alert::_send_mobile_alert($post1, $alert_orm1);
                 $this->session->set('alert_mobile', $post->alert_mobile);
             }
             if (!empty($post->alert_email)) {
                 alert::_send_email_alert($post, $alert_orm);
                 $this->session->set('alert_email', $post->alert_email);
             }
             url::redirect('alerts/confirm');
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('alerts'));
             if (array_key_exists('alert_recipient', $post->errors('alerts'))) {
                 $errors = array_merge($errors, $post->errors('alerts'));
             }
             $form_error = TRUE;
         }
     } else {
         $form['alert_lat'] = Kohana::config('settings.default_lat');
         $form['alert_lon'] = Kohana::config('settings.default_lon');
         $form['alert_radius'] = 20;
         $form['alert_category'] = array();
     }
     $this->template->content->form_error = $form_error;
     // Initialize Default Value for Hidden Field Country Name, just incase Reverse Geo coding yields no result
     $form['alert_country'] = $countries[$default_country];
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_saved = $form_saved;
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->js = new View('alerts/alerts_js');
     $this->themes->treeview_enabled = TRUE;
     $this->themes->slider_enabled = TRUE;
     $this->themes->js->latitude = $form['alert_lat'];
     $this->themes->js->longitude = $form['alert_lon'];
 }
Example #9
0
 private function _receive()
 {
     $secret = "";
     $success = "false";
     //Sometimes user send blank SMSs or GSM operators will
     //send promotional SMSs with no phone number, so this way
     //these messages will always end up on the backend and not float around
     //on the phones forever.
     $message_description = Kohana::lang("ui_main.empty");
     $message_from = "00000000";
     $non_numeric_source = false;
     if (isset($this->request['secret'])) {
         $secret = $this->request['secret'];
     }
     if (isset($this->request['from']) && strlen($this->request['from']) > 0) {
         $message_from = $this->request['from'];
         $original_from = $message_from;
         $message_from = preg_replace("#[^0-9]#", "", $message_from);
         if (strlen($message_from) == 0) {
             $message_from = "00000000";
             $non_numeric_source = true;
         }
     }
     if (isset($this->request['message']) && strlen($this->request['message']) > 0) {
         $message_description = $this->request['message'];
     }
     if ($non_numeric_source) {
         $message_description = '<div style="color:red;">' . Kohana::lang("ui_main.message_non_numeric_source") . " \"" . $original_from . "\" </div>" . $message_description;
     }
     if (!empty($message_from) and !empty($message_description)) {
         $secret_match = TRUE;
         // Is this a valid Secret?
         $smssync = ORM::factory('smssync_settings')->find(1);
         if ($smssync->loaded) {
             $smssync_secret = $smssync->smssync_secret;
             if ($smssync_secret and $secret != $smssync_secret) {
                 // A Secret has been set and they don't match
                 $secret_match = FALSE;
             }
         } else {
             // No Secret Set
             $secret_match = TRUE;
         }
         if ($secret_match) {
             if (stristr($message_description, "alert")) {
                 alert::mobile_alerts_register($message_from, $message_description);
                 $success = "true";
             } elseif (stristr($message_description, "off")) {
                 alert::mobile_alerts_unsubscribe($message_from, $message_description);
                 $success = "true";
             } else {
                 sms::add($message_from, $message_description);
                 $success = "true";
             }
         }
     }
     echo json_encode(array("payload" => array("success" => $success)));
 }
Example #10
0
defined('IN_DESTOON') or exit('Access Denied');
login();
require DT_ROOT . '/module/' . $module . '/common.inc.php';
$MOD['alertid'] or message($L['feature_close']);
$MG['alert_limit'] > -1 or dalert(lang('message->without_permission_and_upgrade'), 'goback');
$mids = array();
$tmp = explode('|', $MOD['alertid']);
foreach ($tmp as $v) {
    if ($v > 4 && isset($MODULE[$v])) {
        $mids[] = $v;
    }
}
require DT_ROOT . '/include/post.func.php';
require MD_ROOT . '/alert.class.php';
$do = new alert();
switch ($action) {
    case 'add':
        if ($MG['alert_limit']) {
            $r = $db->get_one("SELECT COUNT(*) AS num FROM {$DT_PRE}alert WHERE username='******' AND status>0");
            if ($r['num'] >= $MG['alert_limit']) {
                dalert(lang($L['limit_add'], array($MG['alert_limit'], $r['num'])), 'goback');
            }
        }
        if ($submit) {
            if ($do->pass($post)) {
                $post['username'] = $_username;
                $post['email'] = $_email;
                $need_check = $MOD['alert_check'] == 2 ? $MG['check'] : $MOD['alert_check'];
                $post['status'] = get_status(3, $need_check);
                $post['addtime'] = $DT_TIME;
Example #11
0
<?php

defined('IN_DESTOON') or exit('Access Denied');
require MD_ROOT . '/alert.class.php';
$do = new alert();
$menus = array(array('发送商机', '?moduleid=' . $moduleid . '&file=' . $file . '&action=send'), array('贸易提醒', '?moduleid=' . $moduleid . '&file=' . $file), array('审核提醒', '?moduleid=' . $moduleid . '&file=' . $file . '&action=check'));
$mids = array();
$tmp = explode('|', $MOD['alertid']);
foreach ($tmp as $v) {
    if ($v > 4 && isset($MODULE[$v])) {
        $mids[] = $v;
    }
}
if (in_array($action, array('', 'check'))) {
    $sfields = array('按条件', '关键词', '会员名', 'Email');
    $dfields = array('word', 'word', 'username', 'email');
    $sorder = array('结果排序方式', '添加时间降序', '添加时间升序', '发送时间降序', '发送时间升序', '发送频率降序', '发送频率升序');
    $dorder = array('addtime DESC', 'addtime DESC', 'addtime ASC', 'sendtime DESC', 'sendtime ASC', 'rate DESC', 'rate ASC');
    isset($fields) && isset($dfields[$fields]) or $fields = 0;
    isset($order) && isset($dorder[$order]) or $order = 0;
    $areaid = isset($areaid) ? intval($areaid) : 0;
    $fields_select = dselect($sfields, 'fields', '', $fields);
    $order_select = dselect($sorder, 'order', '', $order);
    $condition = '';
    if ($keyword) {
        $condition .= " AND {$dfields[$fields]} LIKE '%{$keyword}%'";
    }
    if ($areaid) {
        $condition .= $AREA[$areaid]['child'] ? " AND areaid IN (" . $AREA[$areaid]['arrchildid'] . ")" : " AND areaid={$areaid}";
    }
    if ($mid) {
Example #12
0
        $cap_m->identifier = $_FILES["uploadfile"]["name"];
        $cap_m->destination = $conf->cap->output;
        $path = $cap_m->createFile();
        header('Location: ' . $_SERVER['PHP_SELF'] . '#read');
    }
    if (!empty($_FILES["uploadfile"]["name"])) {
        // Get TEST Cap
        if (!empty($_FILES["uploadfile"]["name"])) {
            $location = $_FILES["uploadfile"]["tmp_name"];
        } else {
            $location = $conf->cap->output . '/' . urldecode($_POST['location']);
        }
    } else {
        $location = $conf->cap->output . '/' . urldecode($_POST['location']);
    }
    $alert = new alert($location);
    $cap = $alert->output();
    //die(print_r($cap)); // DEBUG
    if (!empty($cap['msg_format'])) {
        print $cap['msg_format'];
        exit;
    }
    $form = new CAP_Form($cap);
    print $form->Form();
} elseif (empty($_POST['action']) && $_GET['webservice'] != 1 && empty($_GET['web_test'])) {
    // Build Cap Creator form
    if (!empty($_GET['delete'])) {
        unlink($conf->cap->output . '/' . $_GET['delete']);
        header('Location: ' . $_SERVER['PHP_SELF'] . '#read');
    }
    if (file_exists('conf/template.cap')) {
    /**
     * Output input field for CAP 1.1 value's
     *
     * @param   string	$type			Type/Tag of CAP 1.1
     * @param   string	$lang			the language (in RFC 3066)
     * @return	string						HTML edit field
     */
    function InputStandard($type, $status_arr = "")
    {
        global $conf, $langs, $AreaCodesArray, $ParameterArray;
        $st['date'] = date('Y-m-d');
        $st['time'] = date('H:i:s');
        $st['zone'] = substr(date('P'), 1);
        /*
        Requirenes level
        key : theme : desc
        O   : A     : optional
        OD  : B     : optional (Dark)			
        C   : E     : conditional
        R   : C     : required
        */
        if (is_array($status_arr)) {
            $status_theme = $this->GetTypeStatusFromArray($status_arr[$type]);
        }
        switch ($type) {
            case 'CapButton':
                // TODO SELECT FOR TEMPLATE HERE
                $out = '</li></ul></div>';
                // exit li
                $out .= '<div data-theme="a" data-form="ui-body-a" class="ui-body ui-body-a ui-corner-all">';
                $out .= '<div data-role="listview" class="ui-grid-a" style="height: 200px;margin: 0px 0px 0px 0px;">';
                $out .= '<div class="ui-block-a" style="padding-right: 7.5px;">';
                $out .= '<a href="#alert" style="text-decoration: none;"><div class="ui-btn ui-input-btn ui-btn-b ui-corner-all ui-shadow" style="height: 85px;padding-top: 85px;">';
                $out .= $langs->trans("NewCap");
                $out .= '</div></a>';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="padding-left: 7.5px;">';
                $out .= '<a href="index.php?read=1#alert" data-ajax="false" style="text-decoration: none;"><div class="ui-btn ui-input-btn ui-btn-b ui-corner-all ui-shadow" style="height: 85px;padding-top: 85px;">';
                $out .= $langs->trans("ReadCap");
                $out .= '</div></a>';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '<ul data-role="listview" style="margin-top: 7.5px;"><li>';
                // enter li
                $out .= '<a href="#conf" >' . $langs->trans("TitleConfig") . '</a>';
                $out .= '</li><li>';
                break;
            case 'identifier':
                if (!empty($this->identifier[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<div id="Identapend">';
                $out .= '<label>' . $langs->trans("LabelIdentifier") . ': ' . $this->tooltip($type, $langs->trans("LabelIdentifierDesc")) . '</label>';
                if (!is_array($this->identifier)) {
                    $status_theme_wm = $status_theme;
                    $status_theme_is = $status_theme;
                    $status_theme_ti = $status_theme;
                    $status_theme_id = $status_theme;
                    if (!empty($conf->identifier->WMO_OID)) {
                        $status_theme_wm = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                    }
                    if (!empty($conf->identifier->ISO)) {
                        $status_theme_is = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                    }
                    if (!empty($conf->identifier->ID_ID)) {
                        $status_theme_ti = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                    }
                    if ($conf->identifier->time->on == true) {
                        $status_theme_id = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                    }
                    $out .= '<div class="ui-grid-c">';
                    if (!empty($conf->identifier->WMO_OID)) {
                        $out .= '<div class="ui-block-a" style="width: 200px;"><input placeholder="WMO OID" ' . $status_theme_wm . ' type="text" maxlength="22" name="identifier[WMO]"  value="' . $conf->identifier->WMO_OID . '"></div>';
                    }
                    if (!empty($conf->identifier->ISO)) {
                        $out .= '<div class="ui-block-b" style="width: 45px;"><input ' . $status_theme_is . ' placeholder="ISO" type="text" maxlength="4" name="identifier[ISO]"  value="' . $conf->identifier->ISO . '"></div>';
                    }
                    if ($conf->identifier->time->on == true) {
                        $out .= '<div class="ui-block-c" style="width: 160px;"><input ' . $status_theme_ti . ' placeholder="YYMMDDHHMMSS" type="text" maxlength="14" name="identifier[time]" value="' . date('ymdHis') . '"></div>';
                    }
                    // YYMMDDHHMMSS
                    if (!empty($conf->identifier->ID_ID)) {
                        $out .= '<div class="ui-block-d" style="width: 200px;"><input ' . $status_theme_id . ' placeholder="Warning ID" type="text" maxlength="22" name="identifier[ID]" value="' . $conf->identifier->ID_ID . '"></div>';
                    }
                    if (empty($conf->identifier->ID_ID)) {
                        $out .= '<div class="ui-block-d"><input ' . $status_theme . ' placeholder="Warning ID" type="text" name="identifier[ID]"  value="' . $this->identifier[0] . '"></div>';
                    }
                    $out .= '</div>';
                } else {
                    $out .= '<input ' . $status_theme . ' placeholder="" type="text" name="identifier[ID]"  value="' . $this->identifier[0] . '">';
                }
                $out .= '</div>';
                break;
            case 'sender':
                if (!empty($this->sender[0])) {
                    $status_theme = 'data-theme="f"';
                }
                $out = '<legend>' . $langs->trans("Labelsender") . ': ' . $this->tooltip($type, $langs->trans("LabelsenderDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . ' placeholder="sender" type="text" name="sender" value="' . $this->sender[0] . '">';
                break;
            case 'sent':
                if (!empty($this->sent[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($this->sent[0]) {
                    $st = $this->make_cap_time($this->sent[0]);
                }
                $out = '<div id="Sentapend">';
                $out .= '<label>' . $langs->trans("LabelSent") . ': ' . $this->tooltip($type, $langs->trans("LabelSentDesc")) . '</label>';
                $out .= '<div class="ui-grid-b">';
                $out .= '<div class="ui-block-a" style="width: 155px;">';
                $out .= '<input ' . $status_theme . ' type="date" name="sent[date]" value="' . $st['date'] . '">';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="width: 155px;">';
                $out .= '<div class="input-group clockpicker" data-autoclose="true">';
                $out .= '<input ' . $status_theme . '  type="time" name="sent[time]" step="1" value="' . $st['time'] . '">';
                $out .= '<span class="input-group-addon" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size: 14px;">';
                $out .= '<span class="glyphicon glyphicon-time"></span>';
                $out .= '</span>';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '<div class="ui-block-c" style="width: 24px;">';
                $out .= '<input type="text" max-size="1" value="+" name="sent[plus]" style="height: 37px;">';
                $out .= '</div>';
                $out .= '<div class="ui-block-c" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="time" name="sent[UTC]" value="' . $st['zone'] . '">';
                $out .= '</div>';
                // <yyyy>-<MM>-T<HH>:<mm>:<ss>+<hour>:<min>
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'references':
                if (!empty($this->references[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelreferences") . ': ' . $this->tooltip($type, $langs->trans("LabelreferencesDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="references" type="text" name="references" value="' . $this->references[0] . '">';
                // web / identifier / sent
                break;
            case 'status':
                $status_theme_st = $status_theme;
                $status_theme_ms = $this->GetTypeStatusFromArray($status_arr['msgType']);
                $status_theme_sc = $this->GetTypeStatusFromArray($status_arr['scope']);
                if (!empty($this->status[0])) {
                    $status_theme_st = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if (!empty($this->msgType[0])) {
                    $status_theme_ms = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['msgType'], 1);
                }
                if (!empty($this->scope[0])) {
                    $status_theme_sc = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['scope'], 1);
                }
                // Actual / Test / Exercise / System / Test / Draft
                $status = $this->buildSelect("status", array("Actual" => "Actual", "Test" => "Test", "Exercise" => "Exercise", "System" => "System", "Test" => "Test", "Draft" => "Draft"), " " . $status_theme_st . " data-native-menu=\"false\"", "Status", $this->status[0]);
                // Alert / Update / Cancel / Ack / Error
                $msgType = $this->buildSelect("msgType", array("Alert" => "Alert", "Update" => "Update", "Cancel" => "Cancel", "Ack" => "Ack", "Error" => "Error"), " " . $status_theme_ms . " data-native-menu=\"false\" id=\"msgType\"", "MsgType", $this->msgType[0]);
                // Public / Restricted / Private
                $scope = $this->buildSelect("scope", array("Public" => "Public", "Restricted" => "Restricted", "Private" => "Private"), " " . $status_theme_sc . " data-native-menu=\"false\"", "Scope", $this->scope[0]);
                $out = '<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true" id="TypeMessage">';
                $out .= '<legend>' . $langs->trans("LabelSetTheTypesOfTheMessage") . ': ' . $this->tooltip($type, $langs->trans("LabelSetTheTypesOfTheMessageDesc")) . '</legend>';
                $out .= $status;
                $out .= $msgType;
                $out .= $scope;
                $out .= '</fieldset>';
                break;
            case 'category':
                $status_theme_ca = $status_theme;
                $status_theme_re = $this->GetTypeStatusFromArray($status_arr['responseType']);
                if (!empty($this->category[0])) {
                    $status_theme_ca = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['category'], 1);
                }
                if (!empty($this->responseType[0])) {
                    $status_theme_re = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['responseType'], 1);
                }
                // Geo / Met / Safety / Security / Rescue / Fire / Health / Env / Transport / Infra / CBRNE / Other
                $category = $this->buildSelect("category", array("Geo" => $langs->trans("Geo"), "Met" => $langs->trans("Met"), "Safety" => $langs->trans("Safety"), "Security" => $langs->trans("Security"), "Rescue" => $langs->trans("Rescue"), "Fire" => $langs->trans("Fire"), "Health" => $langs->trans("Health"), "Env" => $langs->trans("Env"), "Transport" => $langs->trans("Transport"), "Infra" => $langs->trans("Infra"), "CBRNE" => $langs->trans("CBRNE"), "Other" => $langs->trans("Other")), " " . $status_theme_ca . " data-native-menu=\"false\"", "Category", $this->category[0]);
                // Shelter / Evacuate / Prepare / Execute / Avoid / Monitor / Assess / AllClear / None
                $responseType = $this->buildSelect("responseType", array("Shelter" => $langs->trans("Shelter"), "Evacuate" => $langs->trans("Evacuate"), "Prepare" => $langs->trans("Prepare"), "Execute" => $langs->trans("Execute"), "Avoid" => $langs->trans("Avoid"), "Monitor" => $langs->trans("Monitor"), "Assess" => $langs->trans("Assess"), "AllClear" => $langs->trans("AllClear"), "None" => $langs->trans("None")), " " . $status_theme_re . " data-native-menu=\"false\"", "Response Type", $this->responseType[0][0]);
                $out = '<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">';
                $out .= '<legend>' . $langs->trans("LabelSetTheHazardType") . ': ' . $this->tooltip($type, $langs->trans("LabelSetTheHazardTypeDesc")) . '</legend>';
                $out .= $category;
                $out .= $responseType;
                $out .= '</fieldset>';
                break;
            case 'urgency':
                $status_theme_ur = $status_theme;
                $status_theme_se = $this->GetTypeStatusFromArray($status_arr['severity']);
                $status_theme_ce = $this->GetTypeStatusFromArray($status_arr['certainty']);
                if (!empty($this->urgency[0])) {
                    $status_theme_ur = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if (!empty($this->severity[0])) {
                    $status_theme_se = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['severity'], 1);
                }
                if (!empty($this->certainty[0])) {
                    $status_theme_ce = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['certainty'], 1);
                }
                // Immediate / Expected / Future / Past
                $urgency = $this->buildSelect("urgency", array("Immediate" => "Immediate", "Expected" => "Expected", "Future" => "Future", "Past" => "Past"), " " . $status_theme_ur . " data-native-menu=\"false\"", "Urgency", $this->urgency[0]);
                // Extreme / Severe / Moderate / Minor / Unknown
                $severity = $this->buildSelect("severity", array("Minor" => "Minor", "Moderate" => "Moderate", "Severe" => "Severe", "Extreme" => "Extreme", "Unknown" => "Unknown"), " " . $status_theme_se . " data-native-menu=\"false\"", "Severity", $this->severity[0]);
                // Observed / Likely / Possible/ Unlikely / Unknown
                $certainty = $this->buildSelect("certainty", array("Unlikely" => "Unlikely", "Possible" => "Possible", "Likely" => "Likely", "Observed" => "Observed", "Unknown" => "Unknown"), " " . $status_theme_ce . " data-native-menu=\"false\"", "Certainty", $this->certainty[0]);
                $out = '<fieldset data-role="controlgroup" data-type="horizontal" data-mini="true">';
                $out .= '<legend>' . $langs->trans("LabelSetThePriorityOfTheMessage") . ': ' . $this->tooltip($type, $langs->trans("LabelSetThePriorityOfTheMessageDesc")) . '</legend>';
                $out .= $urgency;
                $out .= $severity;
                $out .= $certainty;
                $out .= '</fieldset>';
                break;
            case 'audience':
                if (!empty($this->audience[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelaudience") . ': ' . $this->tooltip($type, $langs->trans("LabelaudienceDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="audience" type="text" name="audience" value="' . $this->audience[0] . '">';
                break;
            case 'eventCode':
                if (!empty($this->eventCode[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<div id="Eventappend">';
                $out .= '<legend>' . $langs->trans("LabelEventCode") . ': ' . $this->tooltip($type, $langs->trans("LabelEventCodeDesc")) . '</legend>';
                $out .= '<div class="ui-grid-b">';
                if (is_array($this->eventCode[0])) {
                    foreach ($this->eventCode[0] as $key => $eventCode) {
                        $out .= '<div class="ui-grid-b">';
                        $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="eventCode[valueName][]" value="' . $eventCode['valueName'] . '"></div>';
                        $out .= '<div class="ui-block-b"><input ' . $status_theme . '  placeholder="Value Value" type="text" name="eventCode[value][]" value="' . $eventCode['value'] . '"></div>';
                        $out .= '</div>';
                    }
                }
                $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="eventCode[valueName][]"></div>';
                $out .= '<div class="ui-block-b"><input ' . $status_theme . '  placeholder="Value" type="text" name="eventCode[value][]"></div>';
                $out .= '<div class="ui-block-c"><input ' . $status_theme . '  type="button" onclick="plusEventCodeInput()" value="+"></div>';
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'effective-Clock':
                $out .= '<div class="input-group clockpicker" data-autoclose="true">';
                $out .= '<input type="time" class="form-control" value="09:30" step="2">';
                $out .= '<span class="input-group-addon" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size: 14px;">';
                $out .= '<span class="glyphicon glyphicon-time"></span>';
                $out .= '</span>';
                $out .= '</div>';
                break;
            case 'effective':
                if (!empty($this->effective[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($this->effective[0]) {
                    $st = $this->make_cap_time($this->effective[0]);
                }
                $out = '<div id="Effectiveapend">';
                $out .= '<legend>' . $langs->trans("LabelEffective") . ': ' . $this->tooltip($type, $langs->trans("LabelEffectiveDesc")) . '</legend>';
                $out .= '<div class="ui-grid-b">';
                $out .= '<div class="ui-block-a" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="date" name="effective[date]" value="' . $st['date'] . '">';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="width: 155px;">';
                $out .= '<div class="input-group clockpicker" data-autoclose="true">';
                $out .= '<input ' . $status_theme . '  type="time" name="effective[time]" step="1" value="' . $st['time'] . '">';
                $out .= '<span class="input-group-addon" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size: 14px;">';
                $out .= '<span class="glyphicon glyphicon-time"></span>';
                $out .= '</span>';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '<div class="ui-block-c" style="width: 24px;">';
                $out .= '<input type="text" max-size="1" value="+" name="effective[plus]" style="height: 37px;">';
                $out .= '</div>';
                $out .= '<div class="ui-block-d" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="time" name="effective[UTC]" value="' . $st['zone'] . '">';
                $out .= '</div>';
                // <yyyy>-<MM>-T<HH>:<mm>:<ss>+<hour>:<min>
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'onset':
                if (!empty($this->onset[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($this->onset[0]) {
                    $st = $this->make_cap_time($this->onset[0]);
                }
                $out = '<div id="Onsetapend">';
                $out .= '<legend>' . $langs->trans("LabelOnset") . ': ' . $this->tooltip($type, $langs->trans("LabelOnsetDesc")) . '</legend>';
                $out .= '<div class="ui-grid-b">';
                $out .= '<div class="ui-block-a" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="date" name="onset[date]" value="' . $st['date'] . '">';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="width: 155px;">';
                $out .= '<div class="input-group clockpicker" data-autoclose="true">';
                $out .= '<input ' . $status_theme . '  type="time" name="onset[time]" step="1" value="' . $st['time'] . '">';
                $out .= '<span class="input-group-addon" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size: 14px;">';
                $out .= '<span class="glyphicon glyphicon-time"></span>';
                $out .= '</span>';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '<div class="ui-block-c" style="width: 24px;">';
                $out .= '<input type="text" max-size="1" value="+" name="onset[plus]" style="height: 37px;">';
                $out .= '</div>';
                $out .= '<div class="ui-block-d" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="time" name="onset[UTC]" value="' . $st['zone'] . '">';
                $out .= '</div>';
                // <yyyy>-<MM>-T<HH>:<mm>:<ss>+<hour>:<min>
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'expires':
                if (!empty($this->expires[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($this->expires[0]) {
                    $st = $this->make_cap_time($this->expires[0]);
                }
                $out = '<div id="Expieresapend">';
                $out .= '<legend>' . $langs->trans("LabelExpires") . ': ' . $this->tooltip($type, $langs->trans("LabelExpiresDesc")) . '</legend>';
                $out .= '<div class="ui-grid-b">';
                $out .= '<div class="ui-block-a" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="date" name="expires[date]" value="' . $st['date'] . '">';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="width: 155px;">';
                $out .= '<div class="input-group clockpicker" data-autoclose="true">';
                $out .= '<input ' . $status_theme . '  type="time" name="expires[time]" step="1" value="' . $st['time'] . '">';
                $out .= '<span class="input-group-addon" style="font-family: \'Helvetica Neue\', Helvetica, Arial, sans-serif;font-size: 14px;">';
                $out .= '<span class="glyphicon glyphicon-time"></span>';
                $out .= '</span>';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '<div class="ui-block-c" style="width: 24px;">';
                $out .= '<input type="text" max-size="1" value="+" name="expires[plus]" style="height: 37px;">';
                $out .= '</div>';
                $out .= '<div class="ui-block-d" style="width: 155px;">';
                $out .= '<input ' . $status_theme . '  type="time" name="expires[UTC]" value="' . $st['zone'] . '">';
                $out .= '</div>';
                // <yyyy>-<MM>-T<HH>:<mm>:<ss>+<hour>:<min>
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'senderName':
                if (!empty($this->senderName[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("LabelsenderName") . ': ' . $this->tooltip($type, $langs->trans("LabelsenderNameDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="senderName" type="text" name="senderName" value="' . $this->senderName[0] . '">';
                break;
            case 'info':
                $out = 'TEST';
                break;
            case 'lang':
                if (!empty($this->language[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $langs_arr = $this->getlang();
                foreach ($langs_arr as $key_l => $val_l) {
                    if (in_array($key, $this->language)) {
                        unset($langs_arr[$key]);
                    }
                }
                $lang_S = $this->buildSelect("language_select", $langs_arr, "data-native-menu=\"false\" id=\"language\"", $langs->trans("LabelLanguage"));
                $extralang = '<div data-role="controlgroup" data-type="horizontal">';
                $styleD[true] = "";
                $styleD[false] = "display:none;";
                //if(is_array($this->language)) die(print_r($this->language)); // Array ( [0] => en-GB [1] => de-DE ) 1
                foreach ($langs_arr as $key => $langs_val) {
                    if (in_array($key, $this->language)) {
                        $display = true;
                    } else {
                        $display = false;
                    }
                    $extralang .= '<a href="#" class="ui-btn Lang_Button" role="button" id="' . $key . '_Button" style="' . $styleD[$display] . ' border-right: 1px solid #dddddd;">' . $langs_val . ' <span id="' . $key . '_Remove_Button" style="color:red; padding-left: 5px;">X</span><input type="hidden" name="language[]" id="' . $key . '_language_input" value=""></a>';
                    if ($display == true) {
                        $extralang .= '<input ' . $status_theme . '  type="hidden" value="' . $key . '" name="language[]">';
                    }
                }
                $extralang .= '</div>';
                $out = $lang_S;
                $out .= $extralang;
                break;
            case 'event':
                $status_theme_ev = $status_theme;
                $status_theme_he = $this->GetTypeStatusFromArray($status_arr['headline']);
                $status_theme_de = $this->GetTypeStatusFromArray($status_arr['description']);
                $status_theme_in = $this->GetTypeStatusFromArray($status_arr['instruction']);
                if (!empty($this->event[0])) {
                    $status_theme_ev = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if (!empty($this->headline[0])) {
                    $status_theme_he = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['headline'], 1);
                }
                if (!empty($this->description[0])) {
                    $status_theme_de = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['description'], 1);
                }
                if (!empty($this->instruction[0])) {
                    $status_theme_in = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr['instruction'], 1);
                }
                $langs_arr = $this->getlang();
                $extralang = "";
                $styleD[true] = "";
                $styleD[false] = "display:none;";
                $i = 0;
                foreach ($langs_arr as $key => $langs_val) {
                    if (in_array($key, $this->language) && $i < 1) {
                        $display = true;
                    } else {
                        $display = false;
                    }
                    $extralang .= '<div class="lang_input" id="' . $key . '" style="' . $styleD[$display] . '">';
                    $extralang .= '<input ' . $status_theme_ev . '  placeholder="event" type="text" name="event[' . $key . ']" value="' . $this->event[$i] . '">';
                    $extralang .= '<input ' . $status_theme_he . '  placeholder="headline" type="text" name="headline[' . $key . ']" value="' . $this->headline[$i] . '">';
                    $extralang .= '<textarea ' . $status_theme_de . '  placeholder="description" name="description[' . $key . ']">' . $this->description[$i] . '</textarea>';
                    $extralang .= '<input ' . $status_theme_in . '  placeholder="instruction" type="text" name="instruction[' . $key . ']" value="' . $this->instruction[$i] . '">';
                    $extralang .= '</div>';
                    $i++;
                }
                $out = $extralang;
                break;
            case 'web':
                if (!empty($this->web[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelweb") . ': ' . $this->tooltip($type, $langs->trans("LabelwebDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="web" type="text" name="web" value="' . $this->web[0] . '">';
                break;
            case 'contact':
                if (!empty($this->contact[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelcontact") . ': ' . $this->tooltip($type, $langs->trans("LabelcontactDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="contact" type="text" name="contact" value="' . $this->contact[0] . '">';
                break;
            case 'parameter':
                if (!empty($this->parameter[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $l_level = array("Unknown", "Minor", "Moderate", "Severe", "Extreme");
                if (is_array($ParameterArray['AWT'])) {
                    foreach ($ParameterArray['AWT'] as $key => $area_arr) {
                        $S_Param_AWT[$area_arr['id'] . '&#59; ' . $area_arr['hazard_type']] = $area_arr['hazard_type_DESC'];
                        $G_Param_AWT[$area_arr['id'] . '&#59; ' . $area_arr['hazard_type']] = 'awareness_type';
                        //awareness_type awareness_level
                    }
                }
                if (is_array($ParameterArray['AWL'])) {
                    foreach ($ParameterArray['AWL'] as $key => $area_arr) {
                        $S_Param_AWL[$area_arr['id'] . '&#59; ' . $area_arr['hazard_level'] . '&#59; ' . $l_level[$area_arr['id']]] = $area_arr['hazard_level'];
                        $G_Param_AWL[$area_arr['id'] . '&#59; ' . $area_arr['hazard_level'] . '&#59; ' . $l_level[$area_arr['id']]] = 'awareness_level';
                        //awareness_type awareness_level
                        $this->level_color[$area_arr['hazard_level']] = $area_arr['hazard_level_color'];
                    }
                }
                //die(print_r($S_Param_AWL));
                if (is_array($S_Param_AWT) && is_array($S_Param_AWT)) {
                    $out .= '<legend>' . $langs->trans("LabelAwarenessTypeWebservice") . ': ' . $this->tooltip($type, $langs->trans("LabelAwarenessTypeWebserviceDesc")) . '</legend>';
                    $out .= $this->buildSelectValueName('parameter[value][]', 'parameter[valueName][]', 'parameter_awt', $S_Param_AWT, $G_Param_AWT, $this->parameter[0]);
                    $out .= '<legend>' . $langs->trans("LabelAwarenessLevelWebservice") . ': ' . $this->tooltip($type, $langs->trans("LabelAwarenessLevelWebserviceDesc")) . '</legend>';
                    $out .= $this->buildSelectValueName('parameter[value][]', 'parameter[valueName][]', 'parameter_awl', $S_Param_AWL, $G_Param_AWL, $this->parameter[0]);
                } else {
                    $out = '<div id="Parameterappend">';
                    $out .= '<legend>' . $langs->trans("LabelParameter") . ': ' . $this->tooltip($type, $langs->trans("LabelParameterDesc")) . '</legend>';
                    $out .= '<div class="ui-grid-b">';
                    foreach ($this->parameter[0] as $key => $parameter) {
                        $out .= '<div class="ui-grid-b">';
                        $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="parameter[valueName][]" value="' . $parameter['valueName'] . '"></div>';
                        $out .= '<div class="ui-block-b"><input ' . $status_theme . '  placeholder="Value Value" type="text" name="parameter[value][]" value="' . $parameter['value'] . '"></div>';
                        $out .= '</div>';
                    }
                    $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="parameter[valueName][]"></div>';
                    $out .= '<div class="ui-block-b"><input ' . $status_theme . '  placeholder="Value" type="text" name="parameter[value][]"></div>';
                    $out .= '<div class="ui-block-c"><input ' . $status_theme . '  type="button" onclick="plusParameterInput()" value="+"></div>';
                    $out .= '</div>';
                    $out .= '</div>';
                }
                break;
                /*
                 * Area
                 */
            /*
             * Area
             */
            case 'areaDesc':
                if (!empty($this->areaDesc[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("LabelareaDesc") . ': ' . $this->tooltip($type . 'tool', $langs->trans("LabelareaDescDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="areaDesc" type="text" name="areaDesc" id="areaDesc" value="' . $this->areaDesc[0] . '">';
                break;
            case 'polygon':
                if (!empty($this->polygon[0][0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelpolygon") . ': ' . $this->tooltip($type . 'tool', $langs->trans("LabelpolygonDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="polygon" type="text" name="polygon" id="polygon" value="' . $this->polygon[0][0] . '">';
                break;
            case 'circle':
                if (!empty($this->circle[0][0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelcircle") . ': ' . $this->tooltip($type . 'tool', $langs->trans("LabelcircleDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  placeholder="circle" type="text" name="circle" id="circle" value="' . $this->circle[0][0] . '">';
                break;
            case 'map':
                $out = '<div id="map" style="height: 480px;" class="map"></div>';
                $out .= '<div id="mapinfo" class="mapinfo">';
                $out .= '<ul data-role="listview">';
                $out .= '<li>';
                $out .= '<label for="dragCircle">' . $langs->trans("Labelpolygon") . ':</label><select name="drawPolygon" id="drawPolygon" data-role="slider" data-theme="b" data-mini="true"><option value="0">Off</option><option value="1">On</option></select>';
                $out .= '</li>';
                $out .= '<li>';
                $out .= '<label for="dragCircle">' . $langs->trans("Labelcircle") . ':</label><select name="dragCircle" id="dragCircle" data-role="slider" data-theme="b" data-mini="true"><option value="0">Off</option><option value="1">On</option></select>';
                $out .= '</li>';
                $out .= '</ul>';
                $out .= '</div>';
                break;
            case 'geocode':
                if (!empty($this->geocode[0])) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                // $out.= $AreaCodesArray;
                foreach ($AreaCodesArray as $key => $area_arr) {
                    if (!empty($area_arr['geotype'])) {
                        $S_Area[$area_arr['geocode']] = $area_arr['AreaCaption'];
                        $G_Area[$area_arr['geocode']] = $area_arr['geotype'];
                    } else {
                        $S_Area[$area_arr['EMMA_ID']] = $area_arr['AreaCaption'];
                        $G_Area[$area_arr['EMMA_ID']] = "EMMA_ID";
                    }
                }
                if (is_array($S_Area)) {
                    $out = '<legend>' . $langs->trans("LabelGeocodeWebservice") . ': ' . $this->tooltip($type, $langs->trans("LabelGeocodeWebserviceDesc")) . '</legend>';
                    $out .= $this->buildSelectValueName('geocode[value][]', 'geocode[valueName][]', 'geocode', $S_Area, $G_Area, $this->geocode[0]);
                } else {
                    $out = '<div id="Geocodeappend">';
                    $out .= '<legend>' . $langs->trans("LabelGeocode") . ': ' . $this->tooltip($type, $langs->trans("LabelGeocodeDesc")) . '</legend>';
                    foreach ($this->geocode[0] as $key => $geocode) {
                        $out .= '<div class="ui-grid-b">';
                        $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="geocode[valueName][]" value="' . $geocode['valueName'] . '"></div>';
                        $out .= '<div class="ui-block-b"><input ' . $status_theme . '  placeholder="geocode Value" type="text" name="geocode[value][]" value="' . $geocode['value'] . '"></div>';
                        $out .= '</div>';
                    }
                    $out .= '<div class="ui-grid-b">';
                    $out .= '<div class="ui-block-a"><input ' . $status_theme . '  placeholder="Valuename" type="text" name="geocode[valueName][]"></div>';
                    $out .= '<div class="ui-block-b"><input ' . $status_theme . ' placeholder="Value" type="text" name="geocode[value][]"></div>';
                    $out .= '<div class="ui-block-c"><input ' . $status_theme . ' type="button" onclick="plusGeocodeInput()" value="+"></div>';
                    $out .= '</div>';
                    $out .= '</div>';
                }
                break;
                /*
                 * Conf input => [conf]
                 */
            /*
             * Conf input => [conf]
             */
            case 'cap_save':
                if (!empty($conf->cap->save)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($conf->cap->save == 1) {
                    $onoroff = 'checked=""';
                } else {
                    $onoroff = '';
                }
                $out = '<label for="identifier_time">' . $langs->trans("LabelSaveCapsInOutputFolder") . ':</label>';
                $out .= '<input ' . $status_theme . ' type="checkbox" data-role="flipswitch" name="conf[cap][save]" id="cap_save" ' . $onoroff . ' data-theme="b">';
                break;
            case 'cap_output':
                if (!empty($conf->cap->output)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("Labelcap_output") . ': ' . $this->tooltip($type . 'tool', $langs->trans("Labelcap_outputDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . ' type="text" placeholder="Cap Output" name="conf[cap][output]" value="' . $conf->cap->output . '">';
                break;
            case 'ID_ID':
                if (!empty($conf->identifier->ID_ID)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = $langs->trans("LabelIdentifierNumber") . ': <input ' . $status_theme . ' type="number" placeholder="Identifier Number" name="conf[identifier][ID_ID]" value="' . $conf->identifier->ID_ID . '">';
                break;
            case 'WMO_OID':
                if (!empty($conf->identifier->WMO_OID)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<legend>' . $langs->trans("LabelWMO_OID") . ': ' . $this->tooltip($type . 'tool', $langs->trans("LabelWMO_OIDDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . '  type="text" placeholder="WMO OID" name="conf[identifier][WMO_OID]" value="' . $conf->identifier->WMO_OID . '">';
                break;
            case 'ISO':
                if (!empty($conf->identifier->ISO)) {
                    $status_theme = 'data-theme="f"';
                }
                $out = $langs->trans("LabelISO") . ': <input ' . $status_theme . ' type="text" maxsize="2" placeholder="ISO" name="conf[identifier][ISO]" value="' . $conf->identifier->ISO . '">';
                break;
            case 'identifier_time':
                if (!empty($conf->identifier->time->on)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                if ($conf->identifier->time->on == 1) {
                    $onoroff = 'checked=""';
                } else {
                    $onoroff = '';
                }
                $out = '<legend>' . $langs->trans("LabelAutomaticIdentifierTime") . ': ' . $this->tooltip($type . 'tool', $langs->trans("LabelAutomaticIdentifierTimeDesc")) . '</legend>';
                //$out = '<label for="identifier_time">'.$langs->trans("LabelAutomaticIdentifierTime").':</label>';
                $out .= '<input ' . $status_theme . ' type="checkbox" data-role="flipswitch" name="conf[identifier][time][on]" id="identifier_time" ' . $onoroff . ' data-theme="b">';
                break;
            case 'template':
                if (file_exists('conf/template.cap')) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                foreach (scandir($conf->cap->output) as $num => $capfilename) {
                    if ($capfilename != '.' && $capfilename != '..' && $capfilename != '.cap' && $capfilename != '.conv.cap') {
                        $files[$capfilename] = $capfilename;
                    }
                }
                $out = '<label for="Template">' . $langs->trans("Template") . ':</label>';
                if (file_exists('conf/template.cap')) {
                    $onoroff = 'checked=""';
                } else {
                    $onoroff = '';
                }
                $out .= '<input ' . $status_theme . ' type="checkbox" data-role="flipswitch" name="template_on" id="template_on" ' . $onoroff . ' data-theme="b">';
                if (file_exists('conf/template.cap')) {
                    require_once 'lib/cap.read.class.php';
                    $alert = new alert('conf/template.cap');
                    $template = $alert->output();
                    $files[$template['identifier']] = $template['identifier'];
                }
                $out .= $this->buildSelect("Template", $files, "data-native-menu=\"false\"", "Template", $template['identifier']);
                break;
            case 'lang_conf':
                if (!empty($conf->select->lang)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<label for="lang_conf">' . $langs->trans("LabelUsableLanguages") . ':</label>';
                $out .= '<select name="conf[select][lang][]" id="lang_conf" data-native-menu="false" multiple="multiple" data-iconpos="left">';
                foreach ($conf->lang as $key => $lang_name) {
                    if ($conf->select->lang[$key] == false) {
                        $out .= '<option value="' . $key . '">' . $lang_name . '</option>';
                    } else {
                        $out .= '<option value="' . $key . '" selected="selected">' . $lang_name . '</option>';
                    }
                }
                $out .= '</select>';
                break;
            case 'lang_conf_use':
                if (!empty($conf->user->lang)) {
                    $status_theme = 'data-theme="f" ' . $this->GetTypeStatusFromArray($status_arr[$type], 1);
                }
                $out = '<label for="lang_conf_use">' . $langs->trans("Labellang_conf_use") . ':</label>';
                $out .= '<select name="conf[user][lang]" id="lang_conf_use" data-native-menu="false" data-iconpos="left">';
                foreach ($conf->trans as $key => $lang_name) {
                    if ($conf->user->lang != $key) {
                        $out .= '<option value="' . $key . '">' . $lang_name . '</option>';
                    } else {
                        $out .= '<option value="' . $key . '" selected="selected">' . $lang_name . '</option>';
                    }
                }
                $out .= '</select>';
                break;
            case 'lang_conf_plus':
                $out = '<div id="LangAappend">';
                //$out.='<label for="sent[date]">'.$langs->trans("LabelAddLanguage").': </label>';
                $out .= '<legend>' . $langs->trans("Labellang_conf_plus") . ': ' . $this->tooltip($type . 'tool', $langs->trans("Labellang_conf_plusDesc")) . '</legend>';
                $out .= '<div class="ui-grid-b">';
                $out .= '<div class="ui-block-a"><input ' . $status_theme . ' type="text" maxsize="5" placeholder="RFC 3066" name="conf[lang][key]" id="lang_conf_plus_key"></div>';
                $out .= '<div class="ui-block-b"><input ' . $status_theme . ' type="text" name="conf[lang][name]" placeholder="Name" id="lang_conf_plus_name"></div>';
                $out .= '<div class="ui-block-c" style="width: 54px;"><input ' . $status_theme . ' type="button" onclick="plusLangInput()" value="+" data-theme="b"></div>';
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'lang_conf_remove':
                $out = '<div id="LangRappend">';
                //$out.='<label for="sent[date]">'.$langs->trans("LabelRemoveLanguage").': </label>';
                $out .= '<legend>' . $langs->trans("Labellang_conf_remove") . ': ' . $this->tooltip($type . 'tool', $langs->trans("Labellang_conf_removeDesc")) . '</legend>';
                $out .= '<div class="ui-grid-a">';
                $out .= '<div class="ui-block-a">';
                $out .= '<select id="lang_remove" data-native-menu="false" data-iconpos="left">';
                foreach ($conf->lang as $key => $lang_name) {
                    $out .= '<option value="' . $key . '">' . $lang_name . '</option>';
                }
                $out .= '</select>';
                $out .= '</div>';
                $out .= '<div class="ui-block-b" style="width: 54px;">';
                $out .= '<input ' . $status_theme . ' type="button" onclick="minusLangInput()" value="-" id="lang_remove_input_button" data-theme="b">';
                $out .= '<input ' . $status_theme . ' type="hidden" id="lang_remove_input" value="remove">';
                $out .= '</div>';
                $out .= '</div>';
                $out .= '</div>';
                break;
            case 'webservice_on':
                if ($conf->webservice->on == 1) {
                    $onoroff = 'checked=""';
                } else {
                    $onoroff = '';
                }
                $out = '<label for="webservice_switch">' . $langs->trans("Webservice") . ':</label>';
                $out .= '<input ' . $status_theme . ' type="checkbox" data-role="flipswitch" name="conf[webservice][on]" id="webservice_switch" ' . $onoroff . ' data-theme="b">';
                break;
            case 'webservice_password':
                $out = $langs->trans("Labelwebservice_password") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][password]" value="' . $conf->webservice->password . '">';
                break;
            case 'webservice_securitykey':
                $out = $langs->trans("Labelwebservice_securitykey") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][securitykey]" value="' . $conf->webservice->securitykey . '">';
                break;
            case 'webservice_sourceapplication':
                $out = $langs->trans("Labelwebservice_sourceapplication") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][sourceapplication]" value="' . $conf->webservice->sourceapplication . '">';
                break;
            case 'webservice_login':
                $out = $langs->trans("Labelwebservice_login") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][login]" value="' . $conf->webservice->login . '">';
                break;
            case 'webservice_entity':
                $out = $langs->trans("Labelwebservice_entity") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][entity]" value="' . $conf->webservice->entity . '">';
                break;
                //case 'webservice_destination':
                //		$out.= '<legend>'.$langs->trans("Labelwebservice_destination").': '.$this->tooltip($type.'tool', $langs->trans("Labelwebservice_destinationDesc")).'</legend>';
                //		$out.= '<input type="text" name="conf[webservice][destination]" value="'.$conf->webservice->destination.'">';
                //	break;
            //case 'webservice_destination':
            //		$out.= '<legend>'.$langs->trans("Labelwebservice_destination").': '.$this->tooltip($type.'tool', $langs->trans("Labelwebservice_destinationDesc")).'</legend>';
            //		$out.= '<input type="text" name="conf[webservice][destination]" value="'.$conf->webservice->destination.'">';
            //	break;
            case 'webservice_WS_METHOD':
                $out = $langs->trans("webservice_WS_METHOD") . ':<input ' . $status_theme . ' type="text" name="conf[webservice][WS_METHOD]" value="' . $conf->webservice->WS_METHOD . '">';
                break;
            case 'webservice_ns':
                $out = '<legend>' . $langs->trans("Labelwebservice_ns") . ': ' . $this->tooltip($type . 'tool', $langs->trans("Labelwebservice_nsDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . ' type="text" name="conf[webservice][ns]" value="' . $conf->webservice->ns . '">';
                break;
            case 'webservice_WS_DOL_URL':
                $out = '<legend>' . $langs->trans("Labelwebservice_WS_DOL_URL") . ': ' . $this->tooltip($type . 'tool', $langs->trans("Labelwebservice_WS_DOL_URLDesc")) . '</legend>';
                $out .= '<input ' . $status_theme . ' type="text" name="conf[webservice][WS_DOL_URL]" value="' . $conf->webservice->WS_DOL_URL . '">';
                break;
            case 'capview':
                $out = '<textarea id="capviewtextarea"></textarea>';
                break;
            case 'caplist':
                $out = '</form><form method="POST" id="capform2" name="capform2" action="index.php?read=1" enctype="multipart/form-data" data-ajax="false">';
                $out .= '<input type="file" name="uploadfile" id="uploadfile"><input type="submit" value="' . $langs->trans('LabelUpload') . '" name="upload" data-ajax="false">';
                $out .= '<fieldset data-role="controlgroup">';
                foreach (scandir($conf->cap->output) as $num => $capfilename) {
                    if ($num > 1) {
                        $out .= '<div class="ui-grid-a">';
                        $out .= '<div class="ui-block-a" style="width:90%">';
                        $out .= '<input type="radio" name="location" id="cap_file_' . $num . '" value="' . urlencode($capfilename) . '">';
                        $out .= '<label for="cap_file_' . $num . '">' . $capfilename . ' <span style="font-size: 12px;color: #5A5A5A;">(' . filesize($conf->cap->output . '/' . $capfilename) . 'b | ' . date('d.m.Y H:i:s', filectime($conf->cap->output . '/' . $capfilename)) . ')</span> </label>';
                        $out .= '</div>';
                        $out .= '<div class="ui-block-b" style="width:10%">';
                        $out .= '<a href="#cap_file_' . $num . '_delete" data-rel="popup" data-position-to="window" data-transition="pop" class="ui-shadow ui-btn ui-corner-all ui-btn-inline ui-mini"><span style="color:#ff0000">X</span></a>';
                        $out .= '</div>';
                        $out .= '</div>';
                        $out .= '<div data-role="popup" id="cap_file_' . $num . '_delete" data-theme="a" data-overlay-theme="b" class="ui-content" style="max-width:340px; padding-bottom:2em;">';
                        $out .= '<h3>Delete File?</h3>';
                        $out .= '<a href="index.php?delete=' . urlencode($capfilename) . '" data-ajax="false" class="ui-shadow ui-btn ui-corner-all ui-btn-b ui-icon-check ui-btn-icon-left ui-btn-inline ui-mini">Delete</a>';
                        $out .= '<a href="#" data-rel="back" class="ui-shadow ui-btn ui-corner-all ui-btn-inline ui-mini">Cancel</a>';
                        $out .= '</div>';
                    }
                }
                $out .= '</fieldset>';
                $out .= '<input type="submit" value="<h1>' . $langs->trans("Read") . '</h1>" data-ajax="false">';
                $out .= '</form><form method="POST" id="capform" name="capform" action="index.php" enctype="multipart/form-data" data-ajax="false">';
                break;
            case 'login_popup':
                if ($conf->webservice->on == 1) {
                    $this->login_id++;
                    if ($conf->webservice_aktive == 1) {
                        $out .= '<ul data-role="listview" data-divider-theme="b">';
                        $out .= '<li>' . $langs->trans("Service") . ': ' . $_SESSION['ServiceHost'] . '</li>';
                        $out .= '<li>' . $langs->trans("User") . ': ' . $conf->webservice->login . '</li>';
                        $out .= '<li>' . $langs->trans("LoginDate") . ': ' . date('d.m.Y H:i:s', $_SESSION['timestamp']) . '</li>';
                        $out .= '<li><input ' . $status_theme . ' type="submit" name="send-logout[' . $this->login_id . ']" value="' . $langs->trans('Logout') . '" data-theme="b"></li>';
                        $out .= '</ul>';
                    } else {
                        $out = '<h3>' . $langs->trans("LoginToYourWebservice") . '</h3>';
                        $out .= '<label for="un" class="ui-hidden-accessible">' . $langs->trans("Labelwebservice_login") . ':</label>';
                        $out .= '<input ' . $status_theme . ' type="text" name="Session_login_name[' . $this->login_id . ']" value="' . $conf->webservice->login . '">';
                        $out .= '<label for="pw" class="ui-hidden-accessible">' . $langs->trans("Labelwebservice_password") . ':</label>';
                        $out .= '<input ' . $status_theme . ' type="password" name="Session_login_pass[' . $this->login_id . ']" value="' . $conf->webservice->password . '">';
                        $out .= '<label><input ' . $status_theme . ' type="checkbox" name="savepass[]">' . $langs->trans("SaveWebservicePass") . '</label>';
                        $out .= '<input id="submit_login_button" ' . $status_theme . ' type="submit" name="send-login[' . $this->login_id . ']" value="' . $langs->trans('Login') . '" data-theme="b">';
                    }
                    if (empty($conf->webservice_aktive) && $conf->webservice->on == 1 && $this->login_id == 1) {
                        $out .= '
													<script>
														$("#Login-alert").on("keyup",function(event){
															if ( event.which == 13 ) 
															{
																$( "#submit_login_button" ).trigger( "click" );
															}
														});
														
														$(document).on("pageshow", "#alert" ,function ()
														{
						                  $( "#Login-alert" ).popup();
															setTimeout( function(){ $( "#Login-alert" ).popup("open"); }, 100 );
														});
													</script>
														';
                    }
                }
                break;
                /*
                 * Default
                 */
            /*
             * Default
             */
            default:
                $out = '<div>';
                $out .= '<label for="' . $type . '">' . $langs->trans("Label" . $type) . ': ' . $this->tooltip($type, $langs->trans("Info" . $type)) . '</label>';
                $out .= '<input ' . $status_theme . ' type="text" placeholder="' . $type . '" name="' . $type . '">';
                $out .= '</div>';
                break;
        }
        //$out.= $this->InputStandard('sent');
        return $out;
    }
<?php

include_once "../session.php";
include_once "header.php";
class alert
{
    function succession_plan_alert($db_object, $common, $user_id)
    {
        $user_table = $common->prefix_table("user_table");
        $pos_qry = "select position from {$user_table} where user_id='{$user_id}'";
        $pos_res = $db_object->get_a_line($pos_qry);
        $position = $pos_res[position];
        $users_under = $common->get_chain_below($position, $db_object, $twodarr);
        $user_under_id = $common->get_user_id($db_object, $users_under);
        $b = 0;
        for ($a = 0; $a < count($user_under_id); $a++) {
            $ch_id = $user_under_id[$a][user_id];
            $ch_boss = $common->is_boss($db_object, $ch_id);
            if ($ch_boss) {
                $users1[$b][user_id] = $ch_id;
                $users1[$b][username] = $common->name_display($db_object, $ch_id);
                $b++;
            }
        }
    }
}
$obj = new alert();
$obj->succession_plan_alert($db_object, $common, $user_id);
?>