\n"; echo "\n"; /************************************/ /* Title */ /************************************/ print_title($_SESSION[$_PAGE_INFO['id']]['title']); /************************************/ /* New/reply/delete message button */ /************************************/ echo "\n"; echo "\n"; echo "\n"; print_button_padding(); if (!is_valid_action("messages_read","messages_new")) { echo "\n"; } if (is_valid_action("messages_read")) { echo "\n"; echo "\n"; } echo "\n"; echo "\n"; if (is_valid_action("messages_inbox")) { // Clear old session info unset($_SESSION[$_PAGE_INFO['id']]['messages_info']); // Fill arrays $previous_date = ""; $id = ""; $id[0] = ""; $opt = ""; $opt[0] = ""; $value = ""; $value[0] = array("Subject", "From"); // Retrieve all received messages $messages = db_fetch_messages_user($_SESSION[$_PAGE_INFO['id']]['login']['user']['id']); if (is_array($messages)) { foreach($messages as $item) { if ($previous_date != strip_time($item['datum'])) { // Store values array_push($opt, 1); array_push($id, ""); array_push($value, array(strip_time($item['datum']))); $previous_date = strip_time($item['datum']); } array_push($opt, 0); array_push($id, $item['id']); $color = ($item['status'] == "marked") ? "unread" : ""; $bold = ($item['status'] == "marked") ? 1 : 0; $user = db_fetch_user($item['van'], "", 1); // Existing user? if (is_array($user)) { $cust = db_fetch_customer($user['klant'], 1); $from = (is_array($user)) ? getUser($user['id']) : _("Unknown"); $from .= (is_array($cust)) ? " (" . $cust['klantnaam'] . ")" : ""; array_push($value, array((strlen($item['onderwerp'])) ? htmlspecialchars(strip_tags($item['onderwerp'])) : "<" . _("no subject") . ">", $from, color => $color, bold => $bold)); } } } print_table("", "messages", $value, $opt, $id, array(43, 50), array("L","L"), "", "onSubmit('read_message', '', 1);", 15, $_SESSION[$_PAGE_INFO['id']]['messages_info']['messages'], 0, 1); } else if (is_valid_action("messages_new", "messages_read")) { if ((is_valid_action("messages_read")) && (!$_SESSION[$_PAGE_INFO['id']]['recall_counter'])) { // Determine message (and restore message id) $backup = $_SESSION[$_PAGE_INFO['id']]['messages_info']; $_SESSION[$_PAGE_INFO['id']]['messages_info'] = db_fetch_message($_SESSION[$_PAGE_INFO['id']]['messages_info']['messages']); $_SESSION[$_PAGE_INFO['id']]['messages_info']['messages'] = $backup['messages']; } if (is_valid_action("messages_read")) { // Add hidden input => delete message requires id print_hidden_input("messages",$_SESSION[$_PAGE_INFO['id']]['messages_info']['messages']); // Add hidden input => repply message requires id print_hidden_input("van",$_SESSION[$_PAGE_INFO['id']]['messages_info']['van']); /************************************/ /* From */ /************************************/ $user = db_fetch_user($_SESSION[$_PAGE_INFO['id']]['messages_info']['van'], "", 1); $cust = db_fetch_customer($user['klant'], 1); $from = (is_array($user)) ? getUser($user['id']) : _("Unknown"); $from .= (is_array($cust)) ? " (" . $cust['klantnaam'] . ")" : ""; print_input("From", "", $from, array("messages_read")); /************************************/ /* Date */ /************************************/ print_input("Date", "datum", $_SESSION[$_PAGE_INFO['id']]['messages_info']['datum'], array("messages_read")); } if (is_valid_action("messages_new")) { /************************************/ /* To company */ /************************************/ echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; /************************************/ /* To user */ /************************************/ echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } /************************************/ /* Subject */ /************************************/ // Check if subject is available when reading messages if (is_valid_action("messages_read")) { $_SESSION[$_PAGE_INFO['id']]['messages_info']['onderwerp'] = (strlen($_SESSION[$_PAGE_INFO['id']]['messages_info']['onderwerp'])) ? $_SESSION[$_PAGE_INFO['id']]['messages_info']['onderwerp'] : "<" . _("no subject") . ">"; } print_input("Subject", "onderwerp", $_SESSION[$_PAGE_INFO['id']]['messages_info']['onderwerp'], array("messages_read")); /************************************/ /* Message */ /************************************/ print_textarea("Message", "tekst", $_SESSION[$_PAGE_INFO['id']]['messages_info']['tekst'], 15, array("messages_read")); /************************************/ /* Buttons */ /************************************/ if (is_valid_action("messages_new")) { echo "\n"; echo "\n"; echo "\n"; print_button_padding(); echo "\n"; echo "\n"; echo "\n"; echo "\n"; } } echo "

" . _("To") . "

"; // Collect all customers down the pyramid $row_customers = db_search_customers(); // When contact person => Add customer above (when available!) if (is_array(db_fetch_contact_user($_SESSION[$_PAGE_INFO['id']]['login']['user']['id']))) { $cust_ids = array(); if (is_array($row_customers)) { foreach ($row_customers as $item) { array_push($cust_ids, $item['id']); } } // Collect all customers up the pyramid $row_customers_up = db_search_customers("", "up"); if (is_array($row_customers_up)) { foreach ($row_customers_up as $item) { if (!in_array($item['id'], $cust_ids)) { array_push($row_customers, $item); } } } } // Default value $_SESSION[$_PAGE_INFO['id']]['messages_info']['klant'] = (isset($_SESSION[$_PAGE_INFO['id']]['messages_info']['klant'])) ? $_SESSION[$_PAGE_INFO['id']]['messages_info']['klant'] : $_SESSION[$_PAGE_INFO['id']]['login']['customer']['id']; echo "\n"; echo "
\n"; if ((isset($_SESSION[$_PAGE_INFO['id']]['messages_info']['klant'])) && (strlen($_SESSION[$_PAGE_INFO['id']]['messages_info']['klant']))) { $row_users = db_fetch_users($_SESSION[$_PAGE_INFO['id']]['messages_info']['klant']); } else { $row_users = db_search_users(); } echo "\n"; $info = ""; // Required for new/change message if (isset($_SESSION[$_PAGE_INFO['id']]['messages_info'])) { // Check if the correct recall function was set if (is_valid_recall("but_ok")) { if (!strlen($_SESSION[$_PAGE_INFO['id']]['messages_info']['naar'])) { $info = "Required field!"; } else { $info = "*"; } } else if (is_valid_recall()) { // Different recall => restore old value $info = $_SESSION[$_PAGE_INFO['id']]['messages_info']['naar_info']; } else { $info = "*"; } } else { $info = "*"; } // Print info message print_info("naar", $info); echo "
\n"; echo "\n"; ?>