1) &&(db_check_system_device_capabilities($type['id'], array("kortsluiting schakelen")))) { // Find all equipment $equipment_type = db_fetch_all_lances($type['id']); if (is_array($equipment_type)) { // Merge arrays $equipment += $equipment_type; } } } } // Check switch status (batteries and sections) and main battery if (!empty($equipment)) { foreach ($equipment as $item) { // Active item? if ($item['lans_status'] == "actief") { // Initial values $batt_status = ""; // Fetch last log_realtime entry $status = db_fetch_lance_logrt($item['id']); // Valid log entry? if (is_array($status)) { // Main battery almost empty or empty? => message switch(($status[0]['mcu_state'] & 0xF000) >> 12) { case 3: $batt_status = "leeg"; break; case 1: $batt_status = "alarm"; break; default: break; } } // Error detected? if (!strlen($batt_status)) { if (in_array($item['id'], $error)) { // Remove from zkl_logerror table db_delete("zkl_logerror", "zkl='" . $item['id'] . "' AND task_id='" . $task['id'] . "'"); } } else { if (!in_array($item['id'], $error)) { // Store in zkl_logerror table db_store("zkl_logerror", array("zkl","tijd","task_id"), array($item['id'], $now, $task['id'])); array_push($battery_check, array(id => $item['id'], status => $batt_status)); } } } } } if (!empty($battery_check)) { foreach($battery_check as $item) { // Initial values $service_email = array(); // Fetch equipment info $item_info = db_fetch_lance($item['id'], "", 1); // Fetch owner info $cust_info = db_fetch_customer($item_info['eigenaar'], 1); // Set owner language (When service email has been selected => else default) if (strlen($cust_info['service_email'])) { array_push($service_email, array(i18n => $cust_info['i18n'], email => $cust_info['service_email'], cust_name => $cust_info['bedrijfsnaam'])); } // Rented? if ((!is_null($item_info['gebruiker'])) && ($item_info['eigenaar'] != $item_info['gebruiker'])) { // Fetch customer who is renting $rent_cust_info = db_fetch_customer($item_info['gebruiker'], 1); if (strlen($rent_cust_info['service_email'])) { array_push($service_email, array(i18n => $rent_cust_info['i18n'], email => $rent_cust_info['service_email'], cust_name => $rent_cust_info['bedrijfsnaam'])); } } if ((is_array($service_email)) && (!empty($service_email))) { foreach($service_email as $mail) { i18n_settext_language($mail['i18n'], $_PAGE_INFO['base_path'] . "locale/"); // Display rt status remark? $item_value = $item_info['idcode']; if (strlen($item_info['rtstatus'])) { $item_value .= " / " . $item_info['rtstatus']; } // Define subject $subject = "MTinfo" . " " . strtolower(_("Warning")) . ": " . $item_value . " (" . $mail['cust_name'] . ")"; // Define content $content = "

"; $content .= _("Dear MTinfo user") . ",

"; $content .= _("The main battery of the following equipment has an distressed status") . " (" . _($item['status']) . ")"; $content .= ": " . $item_value . "
"; $content .= _("It is necessairy to replace this battery") . "!

"; $content .= _("Best regards") . ",

"; $content .= "MTinfo"; $content .= "

"; // Send mail (high priority) send_mail($mail['email'], "", $_PAGE_INFO['ini']['comm']['batt_warning'], $_PAGE_INFO['ini']['report']['no-reply'], $subject, $content, "", "", 1); } } } } // Set handled flag $handled = 1; ?>