function drawRenewalTables() { global $pro_mysql_product_table; global $pro_mysql_admin_table; global $pro_mysql_ssl_ips_table; global $pro_mysql_product_table; global $pro_mysql_vps_table; global $pro_mysql_dedicated_table; global $pro_mysql_ssl_ips_table; global $pro_mysql_client_table; global $pro_mysql_domain_table; global $pro_mysql_completedorders_table; global $pro_mysql_pay_table; global $pro_mysql_spent_type_table; global $pro_mysql_spent_providers_table; global $pro_mysql_spent_moneyout_table; global $pro_mysql_companies_table; global $pro_mysql_spent_bank_table; global $pro_mysql_client_table; global $pro_mysql_new_admin_table; global $secpayconf_currency_letters; global $rub; global $conf_vps_renewal_shutdown; get_secpay_conf(); if (!isset($_REQUEST["sousrub"]) || $_REQUEST["sousrub"] == "") { $sousrub = "renewalreport"; } else { $sousrub = $_REQUEST["sousrub"]; } $out = '<ul class="box_wnb_content_nb">'; if ($sousrub == "renewalreport") { $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_clientinterface.gif\" align=\"absmiddle\" border=\"0\"> " . _("Renewal report") . "</a></li>"; } else { $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_clientinterface.gif\" align=\"absmiddle\" border=\"0\"> " . _("Renewal repport") . "</a></li>"; } $out .= '<li class="box_wnb_content_nb_item_vsep"></li>'; if ($sousrub == "spent") { $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=spent\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Money spent") . "</a></li>"; } else { $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=spent\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Money spent") . "</a></li>"; } $out .= '<li class="box_wnb_content_nb_item_vsep"></li>'; if ($sousrub == "bank") { $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=bank\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Bank accounts & payments") . "</a></li>"; } else { $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=bank\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/config-icon/box_wnb_nb_picto-payementgateway.gif\" align=\"absmiddle\" border=\"0\">" . _("Bank accounts & payments") . "</a></li>"; } $out .= '<li class="box_wnb_content_nb_item_vsep"></li>'; if ($sousrub == "provideredit") { $out .= "<li class=\"box_wnb_content_nb_item_select\"><a href=\"?rub={$rub}&sousrub=provideredit\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_admineditor.gif\" align=\"absmiddle\" border=\"0\">" . _("Upstream provider editor") . "</a></li>"; } else { $out .= "<li class=\"box_wnb_content_nb_item\"><a href=\"?rub={$rub}&sousrub=provideredit\"><img width=\"16\" height=\"16\" src=\"gfx/skin/bwoup/gfx/tabs/p_admineditor.gif\" align=\"absmiddle\" border=\"0\">" . _("Upstream provider editor") . "</a></li>"; } $out .= "</ul>"; switch ($sousrub) { case "spent": $ret = dateSelector("spent_moneyout", "invoice_date", "date_selector"); $out .= $ret["text"]; $where_condition = $ret["where_condition"]; $q = "SELECT * FROM {$pro_mysql_spent_providers_table} "; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $prov_popup_id = array(); $prov_popup_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $prov_popup_id[] = $a["id"]; $prov_popup_names[] = $a["quick_name"]; } $q = "SELECT * FROM {$pro_mysql_spent_type_table} "; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $spent_type_popup_id = array(); $spent_type_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $spent_type_popup_id[] = $a["id"]; $spent_type_names[] = $a["label"]; } $q = "SELECT * FROM {$pro_mysql_companies_table} "; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $company_paying_popup_id = array(); $company_paying_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $company_paying_popup_id[] = $a["id"]; $company_paying_names[] = $a["name"]; } $q = "SELECT * FROM {$pro_mysql_spent_bank_table} "; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $bank_popup_id = array(); $bank_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $bank_popup_id[] = $a["id"]; $bank_names[] = $a["acct_name"]; } $dsc = array("title" => _("List of payments done by your hosting company"), "table_name" => $pro_mysql_spent_moneyout_table, "action" => "money_out_editor", "forward" => array("rub", "sousrub"), "print_where_condition" => $where_condition, "order_by" => "invoice_date", "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "label" => array("type" => "text", "size" => "10", "legend" => _("Label")), "id_company_spending" => array("legend" => _("Company paying"), "type" => "popup", "values" => $company_paying_popup_id, "display_replace" => $company_paying_names), "id_provider" => array("legend" => _("Company paid"), "type" => "popup", "values" => $prov_popup_id, "display_replace" => $prov_popup_names), "expenditure_type" => array("legend" => _("Expenditure type"), "type" => "popup", "values" => $spent_type_popup_id, "display_replace" => $spent_type_names), "payment_type" => array("legend" => _("Means of payment"), "type" => "popup", "values" => array("none", "credit_card", "wire_transfer", "paypal", "check", "cash"), "display_replace" => array(_("Unknown"), _("Credit card"), _("Wire transfer"), _("Paypal"), _("Check"), _("Cash"))), "payment_total" => array("type" => "text", "size" => 6, "legend" => _("Total cost")), "vat_rate" => array("type" => "text", "size" => 4, "legend" => _("Tax rate")), "vat_total" => array("type" => "text", "size" => 4, "legend" => _("Total tax")), "currency_type" => array("type" => "text", "size" => 4, "legend" => _("Currency")), "bank_acct_id" => array("type" => "popup", "values" => $bank_popup_id, "display_replace" => $bank_names, "legend" => _("Bank account")), "amount" => array("type" => "text", "size" => 6, "legend" => _("Bank amount")), "invoice_date" => array("type" => "text", "size" => 10, "legend" => _("Invoice date")), "paid_date" => array("type" => "text", "size" => 10, "legend" => _("Payment date")))); if (isset($_REQUEST["date_selector"])) { $dsc["forward"][] = "date_selector"; } $out .= dtcDatagrid($dsc); break; case "bank": $q = "SELECT * FROM {$pro_mysql_companies_table} "; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $company_paying_popup_id = array(); $company_paying_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $company_paying_popup_id[] = $a["id"]; $company_paying_names[] = $a["name"]; } $dsc = array("title" => _("Bank accounts edition"), "table_name" => $pro_mysql_spent_bank_table, "action" => "bank_account_editor", "forward" => array("rub", "sousrub"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "acct_name" => array("type" => "text", "legend" => _("Account name")), "id_company" => array("legend" => _("Company"), "type" => "popup", "values" => $company_paying_popup_id, "display_replace" => $company_paying_names), "sort_code" => array("legend" => _("Sort code"), "type" => "text", "size" => "8"), "acct_number" => array("legend" => _("Account number"), "type" => "text"), "swift" => array("legend" => _("SWIFT"), "type" => "text", "size" => "8"), "bank_addr" => array("legend" => _("Bank address"), "type" => "text"), "currency_type" => array("legend" => _("Currency"), "type" => "text", "size" => "4"))); $out .= dtcDatagrid($dsc); // Payment type $dsc = array("title" => _("Payment type edition"), "table_name" => $pro_mysql_spent_type_table, "action" => "payment_type_editor", "forward" => array("rub", "sousrub"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "label" => array("legend" => _("Type of payment"), "type" => "text", "size" => "32"))); $out .= dtcDatagrid($dsc); break; case "provideredit": $dsc = array("title" => _("Upstream provider list edition"), "table_name" => $pro_mysql_spent_providers_table, "action" => "provider_list_editor", "forward" => array("rub", "sousrub"), "id_fld" => "id", "list_fld_show" => "quick_name", "new_item_title" => _("New upstream provider") . ":", "new_item_link" => _("New upsream provider"), "edit_item_title" => _("Edit upstream provider") . ":", "check_unique" => array("quick_name"), "where_list" => array("always_yes" => "yes"), "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "quick_name" => array("type" => "text", "disable_edit" => "yes", "check" => "dtc_login_or_email", "legend" => _("Short name:")), "company_name" => array("legend" => _("Company name:"), "type" => "text"), "is_company" => array("type" => "checkbox", "values" => array("yes", "no"), "default" => "yes", "legend" => _("Is it a company:")), "familyname" => array("legend" => _("First name:"), "type" => "text"), "christname" => array("legend" => _("Familly name:"), "type" => "text"), "addr1" => array("legend" => _("Address:"), "type" => "text"), "addr2" => array("legend" => _("Address (line2):"), "type" => "text"), "addr3" => array("legend" => _("Address (line3):"), "type" => "text"), "city" => array("legend" => _("City:"), "type" => "text"), "zipcode" => array("legend" => _("Zipcode:"), "type" => "text"), "state" => array("legend" => _("State:"), "type" => "text"), "country" => array("legend" => _("Country:"), "type" => "text"), "phone" => array("legend" => _("Phone:"), "type" => "text"), "fax" => array("legend" => _("Fax:"), "type" => "text"), "email" => array("legend" => _("Email:"), "type" => "text"), "special_note" => array("legend" => _("Note:"), "type" => "textarea"))); $out .= dtcListItemsEdit($dsc); break; default: case "renewalreport": // Allow shutdown of expired VPS if (isset($_REQUEST["action"])) { switch ($_REQUEST["action"]) { case "shutdown_expired_vps": // Perform a clean shutdown remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "shutdown_vps"); break; case "kill_vps_and_owner": // Do a brutal kill of the running instance deleteVPS($_REQUEST["vps_id"]); remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "destroy_vps"); remoteVPSAction($_REQUEST["server_hostname"], $_REQUEST["vps_name"], "kill_vps_disk"); // Delete the admin $q = "DELETE FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); // And the client $q = "DELETE FROM {$pro_mysql_client_table} WHERE id='" . $_REQUEST["client_id"] . "';"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); break; default: break; } } // Display of each month payment list if (isset($_REQUEST["date"])) { $ret = dateSelector($pro_mysql_pay_table, "date", "date"); $out .= $ret["text"]; $where_condition = $ret["where_condition"]; $q = "SELECT id,name FROM {$pro_mysql_product_table} "; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $prod_ids = array(); $prod_names = array(); for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $prod_ids[] = $a["id"]; $prod_names[] = $a["name"]; } $out .= "<h3>" . _("Payements for the period: ") . $_REQUEST["date"] . "</h3>"; $dsc = array("title" => _("Payment history"), "table_name" => $pro_mysql_pay_table, "action" => "payment_history_list_editor", "forward" => array("rub", "sousrub", "date"), "order_by" => "date", "skip_deletion" => "yes", "skip_creation" => "yes", "print_where_condition" => $where_condition, "cols" => array("id" => array("type" => "id", "display" => "no", "legend" => "id"), "date" => array("type" => "text", "size" => "8", "legend" => _("Date")), "id_client" => array("type" => "forkey", "forkey_type" => "info", "table" => $pro_mysql_client_table, "other_table_fld" => "CONCAT(company_name,': ',familyname,', ',christname)", "other_table_key" => "id", "this_table_field" => "id_client", "link" => "?rub=crm&id=", "bk_table" => $pro_mysql_new_admin_table, "bk_other_table_fld" => "CONCAT(comp_name,': ',family_name,', ',first_name)", "bk_other_table_key" => "id", "bk_this_table_field" => "id_client", "legend" => _("Customer name")), "product_id" => array("type" => "popup", "values" => $prod_ids, "display_replace" => $prod_names, "legend" => _("Product")), "refund_amount" => array("type" => "text", "size" => "8", "legend" => _("Refund amount")), "paiement_cost" => array("type" => "text", "size" => "4", "legend" => _("Gate cost")), "vat_rate" => array("type" => "text", "size" => "4", "legend" => _("VAT rate")), "vat_total" => array("type" => "text", "size" => "4", "legend" => _("VAT total")), "paiement_total" => array("type" => "text", "size" => "6", "legend" => _("Grand total")), "paiement_type" => array("type" => "text", "size" => "6", "legend" => _("Type")), "secpay_site" => array("type" => "text", "size" => "4", "legend" => _("Gate type")), "new_account" => array("type" => "popup", "values" => array("no", "yes"), "display_replace" => array(_("New account"), _("Renewal")), "legend" => _("Is renewal")), "valid" => array("type" => "popup", "values" => array("no", "pending", "yes"), "display_replace" => array(_("No"), _("Pending"), _("Yes")), "legend" => _("Validated")), "pending_reason" => array("type" => "text", "size" => "6", "legend" => _("Pending reason")))); $out .= dtcDatagrid($dsc); return $out; $ret = dateSelector($pro_mysql_completedorders_table, "date", "date"); // Allow nuke of bad payment (hackers?) to have accounting done correctly if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "nuke_payment") { $q = "DELETE FROM {$pro_mysql_completedorders_table} WHERE id='" . $_REQUEST["completedorders_id"] . "';"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); } $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $out .= _("No past payments for this period") . "<br>"; } else { $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t\t<tr><td>" . _("Product") . "</td><td>" . _("Client ID") . "</td><td>" . _("Client") . "</td><td>" . _("Service country") . "</td>\n\t\t\t\t<td>" . _("Client country") . "</td>\n\t\t\t\t<td>" . _("VAT collected") . "</td><td>" . _("Period") . "</td><td>" . _("Payment date") . "</td><td>" . _("Total") . "</td><td>" . _("Payment method") . "</td>\n\t\t\t\t<td>" . _("Action") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); if ($a["id_client"] == 0) { $client_name = _("No client id"); $client_id_txt = _("No client id"); } else { $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $a["id_client"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $client_name = _("N/A"); $client_id_txt = _("N/A"); $client_country = _("N/A"); } else { $a2 = mysql_fetch_array($r2); $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"]; $client_id_txt = $a["id_client"]; $client_country = $a2["country"]; } } $q2 = "SELECT * FROM {$pro_mysql_product_table} WHERE id='" . $a["product_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $product_txt = _("Product not found"); } else { $a2 = mysql_fetch_array($r2); $product_txt = $a2["name"]; $product_period_size = $a2["period"]; } $q2 = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["payment_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $payment_txt = _("Payment not found"); $payment_type = _("Payment not found"); $vat_collected = _("VAT not found"); } else { $a2 = mysql_fetch_array($r2); $payment_txt = $a2["paiement_total"] . " " . $a2["currency"]; $payment_type = $a2["paiement_type"]; if ($payment_type == "online") { $payment_type .= ": " . $a2["secpay_site"]; } $vat_collected = $a2["paiement_total"] * $a2["vat_rate"] / 100; } if ($a["last_expiry_date"] == "0000-00-00") { $last_expiry_date = $a["date"]; } else { $last_expiry_date = $a["last_expiry_date"]; } if ($payment_type == 'wire') { $pay = _("Wire"); } else { if ($payment_type == 'cheque') { $pay = _("cheque"); } else { if ($payment_type == 'online: none') { $pay = _("online: none"); } else { $pay = $payment_type; } } } $new_expiry_date = calculateExpirationDate($last_expiry_date, $product_period_size); $out .= "<tr><td>{$product_txt}</td><td>{$client_id_txt}</td><td>{$client_name}</td><td>" . $a["country_code"] . "</td>\n\t\t\t\t\t<td>{$client_country}</td>\n\t\t\t\t\t<td>{$vat_collected}</td><td>{$last_expiry_date} -> {$new_expiry_date}</td><td>" . $a["date"] . "</td><td>{$payment_txt}</td>\n\t\t\t\t\t<td>{$pay}</td>\n\t\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&date=" . $_REQUEST["date"] . "&action=nuke_payment&completedorders_id=" . $a["id"] . "\">" . _("Delete") . "</a></tr>"; } $out .= "</table>"; } return $out; } // Calculation of recuring totals $out .= "<h3>" . _("Total recurring incomes per month:") . "</h3>"; // Monthly recurring for shared hosting: $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_admin_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_admin_table}.prod_id\n\t\tAND {$pro_mysql_product_table}.heb_type='shared'\n\t\tAND {$pro_mysql_admin_table}.expire != '0000-00-00'"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $total_shared = 0; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $period = $a["period"]; $price = $a["price_dollar"]; $id = $a["id"]; if ($period == '0001-00-00') { $total_shared += $price / 12; } else { $papoum = explode('-', $period); $months = $papoum[1]; if ($months == 0) { echo "Product {$id} has zero month.<br>"; } else { $total_shared += $price / $months; } } } // Calculate how much SSL IPs have been taken $q = "SELECT count(id) as num_ssl FROM {$pro_mysql_ssl_ips_table} WHERE available='no'"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $total_ssl = 0; if ($n != 0) { $a = mysql_fetch_array($r); $q = "SELECT price_dollar FROM {$pro_mysql_product_table} WHERE heb_type='ssl'"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 0) { $b = mysql_fetch_array($r); $total_ssl = $a["num_ssl"] * $b["price_dollar"] / 12; } } // Monthly recurring for VPS: $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_vps_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_vps_table}.product_id"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $total_vps = 0; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $period = $a["period"]; $price = $a["price_dollar"]; $id = $a["id"]; if ($period == '0001-00-00') { $total_shared += $price / 12; } else { $papoum = explode('-', $period); $months = $papoum[1]; if ($months != 0) { $total_vps += $price / $months; } else { echo "Product {$id} has zero month.<br>"; } } } // Monthly recurring for dedicated servers: $q = "SELECT {$pro_mysql_product_table}.price_dollar,{$pro_mysql_product_table}.period,{$pro_mysql_product_table}.id\n\t\tFROM {$pro_mysql_product_table},{$pro_mysql_dedicated_table}\n\t\tWHERE {$pro_mysql_product_table}.id = {$pro_mysql_dedicated_table}.product_id"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); $total_dedicated = 0; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $period = $a["period"]; $price = $a["price_dollar"]; $id = $a["id"]; if ($period == '0001-00-00') { $total_shared += $price / 12; } else { $papoum = explode('-', $period); $months = $papoum[1]; if ($months == 0) { echo _("Dedicated server product ID {$id} has zero for the number of month to renew") . "<br>"; } else { $total_dedicated += $price / $months; } } } $p_renewal = ""; $p_renewal .= _("Shared hosting: ") . round($total_shared, 2) . " {$secpayconf_currency_letters}<br>"; $p_renewal .= _("SSL IPs renewals: ") . round($total_ssl, 2) . " {$secpayconf_currency_letters}<br>"; $p_renewal .= _("VPS: ") . round($total_vps, 2) . " {$secpayconf_currency_letters}<br>"; $p_renewal .= _("Dedicated servers: ") . round($total_dedicated, 2) . " {$secpayconf_currency_letters}<br>"; $big_total = $total_shared + $total_vps + $total_dedicated + $total_ssl; $p_renewal .= "<b>" . _("Total: ") . round($big_total, 2) . " {$secpayconf_currency_letters}</b>"; // Show a quick history of payments $year = date("Y"); $month = date("m"); $cur_year = $year - 2; $cur_month = $month; $p_history = ""; $p_history .= "<table cellspacing=\"1\" cellpadding=\"1\" border=\"1\">\n\t\t<tr><td>" . _("Period") . "</td><td>" . _("Amount") . "</td><td>" . _("VAT collected") . "</td><td>" . _("Payment gateway cost") . "</td><td>" . _("Profit") . "</td></tr>"; for ($i = 0; $i < 25; $i++) { $q2 = "SELECT {$pro_mysql_pay_table}.paiement_total,{$pro_mysql_pay_table}.vat_rate,{$pro_mysql_pay_table}.paiement_cost\n\t\t\tFROM {$pro_mysql_pay_table},{$pro_mysql_completedorders_table}\n\t\t\tWHERE {$pro_mysql_pay_table}.vat_rate!='0.00'\n\t\t\tAND {$pro_mysql_completedorders_table}.payment_id = {$pro_mysql_pay_table}.id\n\t\t\tAND {$pro_mysql_completedorders_table}.date LIKE '" . $cur_year . "-" . $cur_month . "-%';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); $vat_collected = 0; $month_total = 0; $cost_total = 0; for ($j = 0; $j < $n2; $j++) { $a2 = mysql_fetch_array($r2); $tt = $a2["paiement_total"]; $vat = $a2["vat_rate"]; $vat_collected += $tt * $vat / 100; $month_total += $tt; $cost_total += $a2["paiement_cost"]; } $q2 = "SELECT sum(paiement_total) as paiement_total, sum(paiement_cost) as paiement_cost FROM {$pro_mysql_completedorders_table},{$pro_mysql_pay_table}\n\t\t\tWHERE {$pro_mysql_completedorders_table}.date LIKE '" . $cur_year . "-" . $cur_month . "%'\n\t\t\tAND {$pro_mysql_completedorders_table}.payment_id = {$pro_mysql_pay_table}.id\n\t\t\tAND {$pro_mysql_pay_table}.vat_rate = '0.00';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 > 0) { $a2 = mysql_fetch_array($r2); $cost_total += $a2["paiement_cost"]; $month_total += $a2["paiement_total"]; $profit = $month_total - $cost_total - $vat_collected; $p_history .= "<tr><td style=\"text-align:right;\"><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&date=" . $cur_year . "-" . $cur_month . "\">" . $cur_year . "-" . $cur_month . "</a></td>\n\t\t\t\t<td style=\"text-align:right;\">" . $month_total . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($vat_collected, 2) . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($cost_total, 2) . " {$secpayconf_currency_letters}</td>\n\t\t\t\t<td style=\"text-align:right;\">" . round($profit, 2) . " {$secpayconf_currency_letters}</td></tr>"; } $cur_month++; if ($cur_month > 12) { $cur_month = 1; $cur_year++; } if ($cur_month < 10) { $cur_month = "0" . $cur_month; } } $p_history .= "</table>"; $p_active_prods = "<img src=\"active_prods_graph.php?graph=year\"><br>\n<img src=\"active_prods_graph.php?graph=month\">"; // Layout the recuring stat and the effective payment statistics $out .= "<table cellspacing=\"1\" cellpadding=\"4\" border=\"0\" width=\"100%\">\n\t\t<tr valign=\"top\"><td valign=\"top\" width=\"50%\">{$p_history}</td>\n\t\t<td valign=\"top\">{$p_renewal}</td>\n\t\t<td valign=\"top\">{$p_active_prods}</td></tr></table>"; $out .= "<h3>" . _("Shared hosting renewals:") . "</h3>"; $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE expire < '" . date("Y-m-d") . "' AND id_client!='0' AND expire !='0000-00-00' ORDER BY expire;"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__); $n = mysql_num_rows($r); if ($n < 1) { $out .= _("No shared account expired.") . "<br>"; } else { $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $a["id_client"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $client_name = _("Client name not found!"); } else { $a2 = mysql_fetch_array($r2); $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"]; } $q2 = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='" . $a["adm_login"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__); $n2 = mysql_num_rows($r2); if ($n2 > 0) { $out .= "<tr><td>" . $a["adm_login"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire"] . "</td></tr>"; } } $out .= "</table>"; } // List of expired expired SSL IPs $out .= "<h3>" . _("SSL IPs renewals") . "</h3>"; $q = "SELECT * FROM {$pro_mysql_ssl_ips_table} WHERE expire < '" . date("Y-m-d") . "' AND available='no' ORDER BY expire"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $out .= _("No SSL IP expired") . "<br>"; } else { $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { die("Cannot find admin name " . $a["adm_login"] . " line " . __LINE__ . " file " . __FILE__); } else { $admin = mysql_fetch_array($r2); } $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $client_name = _("Client name not found!"); } else { $a2 = mysql_fetch_array($r2); $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"]; } $out .= "<tr><td>" . $a["adm_login"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire"] . "</td></tr>"; } $out .= "</table>"; } // List if expired VPS $out .= "<h3>" . _("VPS renewals:") . "</h3>"; $q = "SELECT * FROM {$pro_mysql_vps_table} WHERE expire_date < '" . date("Y-m-d") . "' ORDER BY expire_date"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $out .= _("No VPS expired") . "<br>"; } else { $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("VPS") . "</td>\n\t\t\t<td>" . _("Client") . "</td>\n\t\t\t<td>" . _("Email") . "</td>\n\t\t\t<td>" . _("Expiration date") . "</td>\n\t\t\t<td>" . _("Days of expiration") . "</td>\n\t\t\t<td>" . _("Action") . "</td>\n\t\t\t</tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { die("Cannot find admin name " . $a["owner"] . " line " . __LINE__ . " file " . __FILE__); } else { $admin = mysql_fetch_array($r2); } $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $client_name = _("Client name not found!"); } else { $a2 = mysql_fetch_array($r2); $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"]; } $q2 = "SELECT adm_login FROM {$pro_mysql_admin_table} WHERE id_client='" . $admin["id_client"] . "'"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 == 1) { $q2 = "SELECT * FROM {$pro_mysql_vps_table} WHERE owner='" . $admin["adm_login"] . "'"; $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 == 1) { $q2 = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE owner='" . $admin["adm_login"] . "'"; $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 == 0) { $q2 = "SELECT * FROM {$pro_mysql_domain_table} WHERE owner='" . $admin["adm_login"] . "'"; $r2 = mysql_query($q2) or die("Cannot querry " . $q2 . " line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 == 0) { $kill_owner_txt = "<a href=\"" . $_SERVER["PHP_SELF"] . "?action=kill_vps_and_owner&adm_login="******"adm_login"] . "&client_id=" . $admin["id_client"] . "&vps_name=" . $a["vps_xen_name"] . "&server_hostname=" . $a["vps_server_hostname"] . "&vps_id=" . $a["id"] . "\">" . _("Kill VPS and owner") . "</a>"; } else { $kill_owner_txt = _("Has some domains"); } } else { $kill_owner_txt = _("Has a dedicated"); } } else { $kill_owner_txt = _("More than one VPS"); } } else { $kill_owner_txt = _("More than one login"); } if (numOfDays($a["expire_date"]) >= $conf_vps_renewal_shutdown) { $bgcolor = " bgcolor=\"#FF8888\" "; } else { $bgcolor = " "; } $out .= "<tr><td>" . $a["owner"] . "</td>\n\t\t\t\t<td>" . $a["vps_xen_name"] . ":" . $a["vps_server_hostname"] . "</td>\n\t\t\t\t<td>{$client_name}</td>\n\t\t\t\t<td>" . $a2["email"] . "</td>\n\t\t\t\t<td {$bgcolor}>" . $a["expire_date"] . "</td>\n\t\t\t\t<td {$bgcolor}>" . calculateAge($a["expire_date"], "00:00:00") . "</td>\n\t\t\t\t<td><a href=\"" . $_SERVER["PHP_SELF"] . "?rub={$rub}&action=shutdown_expired_vps&server_hostname=" . $a["vps_server_hostname"] . "&vps_name=" . $a["vps_xen_name"] . "\">" . _("Shutdown") . "</a> - {$kill_owner_txt}</td></tr>"; } $out .= "</table>"; } // List expired dedicated servers $out .= "<h3>" . _("Dedicated servers renewals") . "</h3>"; $q = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE expire_date < '" . date("Y-m-d") . "' ORDER BY expire_date"; $r = mysql_query($q) or die("Cannot querry {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $out .= _("No dedicated server expired") . "<br>"; } else { $out .= "<table cellspacing=\"0\" cellpadding=\"2\" border=\"1\">\n\t\t\t<tr><td>" . _("Login") . "</td><td>" . _("Server") . "</td><td>" . _("Client") . "</td><td>" . _("Email") . "</td><td>" . _("Expiration date") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $q2 = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { die("Cannot find admin name " . $a["owner"] . " line " . __LINE__ . " file " . __FILE__); } else { $admin = mysql_fetch_array($r2); } $q2 = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';"; $r2 = mysql_query($q2) or die("Cannot querry {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $client_name = _("Client name not found!"); } else { $a2 = mysql_fetch_array($r2); $client_name = $a2["company_name"] . ":" . $a2["christname"] . ", " . $a2["familyname"]; } $out .= "<tr><td>" . $a["owner"] . "</td><td>" . $a["server_hostname"] . "</td><td>{$client_name}</td><td>" . $a2["email"] . "</td><td>" . $a["expire_date"] . "</td></tr>"; } $out .= "</table>"; } break; } return $out; }
function drawNewAdminForm() { global $conf_site_root_host_path; global $lang; global $pro_mysql_admin_table; global $pro_mysql_client_table; global $pro_mysql_new_admin_table; global $pro_mysql_pending_queries_table; global $pro_mysql_pay_table; global $pro_mysql_pending_renewal_table; global $pro_mysql_product_table; global $pro_mysql_vps_table; global $pro_mysql_tik_admins_table; global $pro_mysql_tik_queries_table; global $pro_mysql_tik_cats_table; global $pro_mysql_dedicated_table; global $secpayconf_currency_letters; global $secpayconf_use_maxmind; get_secpay_conf(); $out = ""; // Resolve support ticket stuff if (isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == "resolv_ticket") { $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='" . $_REQUEST["tik_id"] . "';"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { return _("Cannot find ticket!"); } $a = mysql_fetch_array($r); $out .= _("Subject: ") . htmlspecialchars(stripslashes($a["subject"])) . "<br>"; $q2 = "SELECT * FROM {$pro_mysql_tik_cats_table} WHERE id='" . $a["cat_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $tmp = _("Type not found!"); } else { $a2 = mysql_fetch_array($r2); $tmp = $a2["catdescript"] . "<br>"; } $out .= _("Type:") . $tmp; $out .= _("First query date: ") . $a["date"] . " " . $a["time"] . "<br>"; $out .= _("Server hostname related: ") . $a["server_hostname"] . "<br>"; $out .= _("Admin login: "******"adm_login"] . "<br><br>"; $out .= "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\">"; $next_tikq = $_REQUEST["tik_id"]; $close_request = "no"; while ($next_tikq != 0) { $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE adm_login='******' AND id='{$next_tikq}';"; $r = mysql_query($q) or die("Cannot query {$q} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { $out .= _("Cannot find ticket!"); break; } $a = mysql_fetch_array($r); $last_tik = $next_tikq; $next_tikq = $a["reply_id"]; if ($a["admin_or_user"] == "user") { $bg = " bgcolor=\"#AAAAFF\" "; } else { $bg = " bgcolor=\"#FFFFAA\" "; } if ($a["admin_or_user"] == "admin") { $replied_by = "<br>" . _("Replied by:") . " " . $a["admin_name"]; } else { $replied_by = ""; } $out .= "<tr><td{$bg} valign=\"top\"><i>" . $a["date"] . " " . $a["time"] . "</i>" . $replied_by . "</td><td{$bg}>" . nl2br(htmlspecialchars(stripslashes($a["text"]))) . "</td></tr>"; if ($a["request_close"] == "yes") { $close_request = "yes"; } } $out .= "</table>"; $out .= _("Request to close the ticket: "); if ($close_request == "yes") { $out .= "<font color=\"#00FF00\">" . _("Yes") . "</font><br>"; } else { $out .= "<font color=\"#FF0000\">" . _("No") . "</font><br>"; } $out .= "<form action=\"" . $_SERVER["PHP_SELF"] . "\" method=\"post\">\n\t\t<input type=\"hidden\" name=\"subaction\" value=\"ticket_reply\">\n\t\t<textarea cols=\"100\" rows=\"10\" wrap=\"physical\" name=\"ticketbody\"></textarea><br>\n\t\t<input type=\"hidden\" name=\"tik_id\" value=\"" . $_REQUEST["tik_id"] . "\">\n\t\t<input type=\"hidden\" name=\"server_hostname\" value=\"" . $a["server_hostname"] . "\">\n\t\t<input type=\"hidden\" name=\"last_tik_id\" value=\"{$last_tik}\">\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"answer\" value=\"" . _("Send reply") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"answer_close\" value=\"" . _("Send reply and close ticket") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"close\" value=\"" . _("Close without reply") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t<div class=\"input_btn_container\" onMouseOver=\"this.className='input_btn_container-hover';\" onMouseOut=\"this.className='input_btn_container';\">\n <div class=\"input_btn_left\"></div>\n <div class=\"input_btn_mid\"><input class=\"input_btn\" type=\"submit\" name=\"delete_thread\" value=\"" . _("Delete thread silently") . "\"></div>\n <div class=\"input_btn_right\"></div>\n</div>\n\t\t</form>"; return $out; } // Reply to support ticket stuff if (isset($_REQUEST["subaction"]) && $_REQUEST["subaction"] == "ticket_reply") { $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='" . $_REQUEST["tik_id"] . "';"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { return _("Cannot find ticket!"); } $a = mysql_fetch_array($r); if (isset($_REQUEST["answer"])) { $closed = "no"; } else { $closed = "yes"; } $adm_login = $a["adm_login"]; if (strlen($adm_login) != 0) { $q = "SELECT * FROM {$pro_mysql_admin_table} WHERE adm_login='******';"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { return "Admin {$adm_login} not found line " . __LINE__ . " file " . __FILE__; } $admin = mysql_fetch_array($r); if ($admin["id_client"] == "0") { return _("The virtual administrator for which you are trying to manage a support ticket has no client file. Go in the Customer management screen and create a client file for this administrator."); } $q = "SELECT * FROM {$pro_mysql_client_table} WHERE id='" . $admin["id_client"] . "';"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n != 1) { return "Client id for admin {$adm_login} not found line " . __LINE__ . " file " . __FILE__; } $client = mysql_fetch_array($r); } else { $adm_login = ""; } if (isset($_REQUEST["delete_thread"])) { deleteTicketThread($_REQUEST["tik_id"]); $closed = "no"; } if (isset($_REQUEST["answer"]) || isset($_REQUEST["answer_close"])) { $qps = "SELECT * FROM {$pro_mysql_tik_admins_table} WHERE pseudo='" . $_SERVER["PHP_AUTH_USER"] . "';"; $rps = mysql_query($qps) or die("Cannot query {$qps} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $nps = mysql_num_rows($rps); if ($nps != 1) { die("Ticket admin not found line " . __LINE__ . " file " . __FILE__); } $aps = mysql_fetch_array($rps); $pseudo = $aps["pseudo"]; $q2 = "INSERT INTO {$pro_mysql_tik_queries_table} (id,adm_login,date,time,in_reply_of_id,reply_id,admin_or_user,subject,text,cat_id,initial_ticket,server_hostname,closed,admin_name)\n\t\t\tVALUES ('','" . $a["adm_login"] . "','" . date("Y-m-d") . "','" . date("H:i:s") . "','" . $_REQUEST["last_tik_id"] . "','0','admin','" . mysql_real_escape_string($a["subject"]) . "','" . mysql_real_escape_string($_REQUEST["ticketbody"]) . "','" . $a["cat_id"] . "','no','" . $a["server_hostname"] . "','{$closed}','{$pseudo}');"; $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $ins_id = mysql_insert_id(); $q2 = "UPDATE {$pro_mysql_tik_queries_table} SET reply_id='{$ins_id}' WHERE id='" . $_REQUEST["last_tik_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); $out .= "Ticket reply sent!<br>"; if (strlen($adm_login) != 0) { mailUserTicketReply($client["email"], $a["hash"], $a["subject"], $_REQUEST["ticketbody"], $closed, $adm_login); } if (strlen($a["customer_email"]) != 0) { mailUserTicketReply($a["customer_email"], $a["hash"], $a["subject"], $_REQUEST["ticketbody"], $closed, $adm_login); } } if ($closed == "yes") { $q2 = "UPDATE {$pro_mysql_tik_queries_table} SET closed='yes' WHERE id='" . $_REQUEST["tik_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot query {$q2} line " . __LINE__ . " file " . __FILE__ . " sql said: " . mysql_error()); } if (isset($_REQUEST["close"])) { if (strlen($adm_login) != 0) { mailUserTicketReply($client["email"], $a["hash"], "The ticket has been closed (without text reply)", "The ticket has been closed (without text reply)", $closed, $adm_login); } if (strlen($a["customer_email"]) != 0) { mailUserTicketReply($a["customer_email"], $a["hash"], "The ticket has been closed (without text reply)", "The ticket has been closed (without text reply)", $closed, $adm_login); } } } // Draw the form for making a new admin $add_a_user = "******" . _("Add a new user") . "</h3>\n<form name=\"addnewuser_frm\" action=\"?\" method=\"post\">\n<input type=\"hidden\" name=\"newadminuser\" value=\"Ok\">\n" . dtcFormTableAttrs() . dtcFormLineDraw(_("Login:"******"<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"newadmin_login\" value=\"\">") . dtcFormLineDraw(_("Password:"******"<input class=\"dtcDatagrid_input_alt_color\" type=\"password\" name=\"newadmin_pass\" value=\"\">" . autoGeneratePassButton("addnewuser_frm", "newadmin_pass"), 0) . dtcFormLineDraw(_("Path:"), "<input class=\"dtcDatagrid_input_color\" type=\"text\" name=\"newadmin_path\" value=\"{$conf_site_root_host_path}\">") . dtcFromOkDraw() . "\n</form>\n</table>\n"; if ($secpayconf_use_maxmind == "yes") { $maxmindsays_th = "<td>" . _("MaxMind says") . "</td>"; } else { $maxmindsays_th = ""; } // Draw the list of users awaiting for an account $waiting_new_users = "<h3>" . _("User and domain waiting for addition:") . "</h3>"; $q = "SELECT * FROM {$pro_mysql_new_admin_table} ORDER BY date,time"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $waiting_new_users .= "<b>" . _("No user waiting!") . "</b>"; } else { $waiting_new_users .= "<table width=\"100%\"border=\"1\">\n<tr><td>" . _("Name") . "</td><td>" . _("Login") . "</td><td>" . _("Domain name / VPS server hostname") . "</td><td>" . _("Product") . "</td><td>" . _("Date") . "</td><td>" . _("Bank validated") . "</td>{$maxmindsays_th}<td>" . _("Action") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $waiting_new_users .= "<tr><td style=\"white-space:nowrap\"><u>" . $a["comp_name"] . ":</u><br>"; $waiting_new_users .= $a["family_name"] . ", " . $a["first_name"] . "</td>"; $waiting_new_users .= "<td>" . $a["reqadm_login"] . "</td>"; $prod_id = $a["product_id"]; $q2 = "SELECT * FROM {$pro_mysql_product_table} WHERE id='{$prod_id}';"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $dom_name = _("Cannot find product in db!"); $prod_name = _("Cannot find product in db!"); } else { $a2 = mysql_fetch_array($r2); $prod_name = $a2["name"]; if ($a2["heb_type"] == "vps") { $dom_name = $a["vps_location"]; } else { $dom_name = $a["domain_name"]; } } $waiting_new_users .= "<td>{$dom_name}</td><td>{$prod_name}</td>"; $waiting_new_users .= "<td>" . $a["date"] . " " . $a["time"] . "<br>" . calculateAge($a["date"], $a["time"]) . "</td>"; if ($a["paiement_id"] == 0) { $waiting_new_users .= "<td>" . _("No pay ID!") . "</td>"; } else { $q = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["paiement_id"] . "';"; $r2 = mysql_query($q) or die("Cannot select {$q} line: " . __LINE__ . " file: " . __FILE__ . " sql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { echo "Numrows!=1 in {$q} line: " . __LINE__ . " file: " . __FILE__ . " : problems with sql tables !"; } $a2 = mysql_fetch_array($r2); if ($a2["valid"] == "yes") { $waiting_new_users .= "<td><font color=\"green\">" . _("Yes") . "</font></td>"; } elseif ($a2["valid"] == "pending") { $waiting_new_users .= "<td><font color=\"#FF8800\">" . _("Pending") . ": " . $a2["pending_reason"] . "</font></td>"; } else { $waiting_new_users .= "<td><font color=\"red\">" . _("No") . "</font></td>"; } } if ($secpayconf_use_maxmind == "yes") { $waiting_new_users .= "<td><pre style='width: 200px; height: 100px; overflow: scroll;'>" . htmlspecialchars(print_r(unserialize($a["maxmind_output"]), true)) . "</pre></td>"; } $waiting_new_users .= "<td style=\"white-space:nowrap\"><a target=\"_blank\" href=\"/dtcadmin/view_waitingusers.php?reqadm_id=" . $a["id"] . "\">" . _("Edit") . "</a><br/>\n\t\t\t<a href=\"" . $_SERVER["PHP_SELF"] . "?action=valid_waiting_user&reqadm_id=" . $a["id"] . "\">" . _("Add") . "</a><br/>\n\t\t\t<a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_waiting_user&reqadm_id=" . $a["id"] . "\">" . _("Delete") . "</a></td>"; $waiting_new_users .= "</tr>"; } $waiting_new_users .= "</table>"; } // Draw the list of domains awaiting to be add to users $q = "SELECT * FROM {$pro_mysql_pending_queries_table}"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $waiting_new_users .= "<br><b>" . _("No domain waiting!") . "</b><br>"; } else { $waiting_new_users .= "<table border=\"1\">\n\t<tr><td>" . _("Login") . "</td><td>" . _("Domain name") . "</td><td>" . _("Action") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $waiting_new_users .= "<td>" . $a["adm_login"] . "</td>"; $waiting_new_users .= "<td>" . $a["domain_name"] . "</td>"; $waiting_new_users .= "<td><a href=\"" . $_SERVER["PHP_SELF"] . "?action=valid_waiting_domain_to_user&reqid=" . $a["id"] . "\">" . _("Add") . "</a>\n- <a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_waiting_domain_to_user&reqid=" . $a["id"] . "\">" . _("Delete") . "</a></td></tr>"; } $waiting_new_users .= "</table>"; } // Draw the list of pending renewals $q = "SELECT * FROM {$pro_mysql_pending_renewal_table} ORDER BY renew_date,renew_time"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $waiting_new_users .= "<b>" . _("No pending renewals!") . "</b><br>"; } else { $waiting_new_users .= "<table border=\"1\">\n<tr><td>" . _("Login") . "</td><td>" . _("Product") . "</td><td>" . _("Payment date") . "</td><td>" . _("Bank validated") . "</td><td>" . _("Type") . "</td><td>" . _("Action") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); $waiting_new_users .= "<tr><td>" . $a["adm_login"] . "</td>"; $q2 = "SELECT name,price_dollar,period FROM {$pro_mysql_product_table} WHERE id='" . $a["product_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $prod_name = _("Cannot find product!"); } else { $a2 = mysql_fetch_array($r2); $prod_name = $a2["name"] . " (" . $a2["price_dollar"] . " {$secpayconf_currency_letters}: " . $a2["period"] . ")"; } $waiting_new_users .= "<td>{$prod_name}</td>"; $waiting_new_users .= "<td>" . $a["renew_date"] . " " . $a["renew_time"] . "</td>"; $q2 = "SELECT * FROM {$pro_mysql_pay_table} WHERE id='" . $a["pay_id"] . "';"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $bank = _("Cannot find payment!"); } else { $a2 = mysql_fetch_array($r2); switch ($a2["valid"]) { case "yes": $bank = "<font color=\"green\">" . _("Yes") . "</font>"; break; default: case "no": $bank = "<font color=\"red\">" . _("No") . "</font>"; break; case "pending": $bank = "<font color=\"#FF8800\">" . _("Pending") . ": " . $a2["pending_reason"] . "</font>"; break; } } $waiting_new_users .= "<td>{$bank}</td>"; switch ($a["heb_type"]) { case "vps": $q2 = "SELECT * FROM {$pro_mysql_vps_table} WHERE id='" . $a["renew_id"] . "'"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); if ($n2 != 1) { $heb_type = _("VPS: Cannot find VPS in db!"); } else { $a2 = mysql_fetch_array($r2); $heb_type = "VPS: " . $a2["vps_xen_name"] . "@" . $a2["vps_server_hostname"]; } break; case "shared": case "ssl": $heb_type = _("Shared"); break; case "shared-upgrade": $heb_type = _("Shared Upgrade"); break; case "ssl": $heb_type = _("SSL Token purchase"); break; case "ssl_renew": $heb_type = _("SSL Token renewal"); break; case "server": $q2 = "SELECT * FROM {$pro_mysql_dedicated_table} WHERE id='" . $a["renew_id"] . "'"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); if ($n2 != 1) { $tmp = _("Cannot find server in db!"); } else { $a2 = mysql_fetch_array($r2); $tmp = $a2["server_hostname"]; } $heb_type = _("Server:") . $tmp; break; default: echo "Renew type " . $a["heb_type"] . " not implemented line " . __LINE__ . " file " . __FILE__; break; } $waiting_new_users .= "<td>{$heb_type}</td>"; $waiting_new_users .= "<td style=\"white-space:nowrap\"><a href=\"" . $_SERVER["PHP_SELF"] . "?action=validate_renewal&id=" . $a["id"] . "\">" . _("Validate") . "</a> <a href=\"" . $_SERVER["PHP_SELF"] . "?action=delete_renewal&id=" . $a["id"] . "\">" . _("Del") . "</a></td>"; $waiting_new_users .= "</tr>"; } $waiting_new_users .= "</table>"; } // Ticket manager: draw all open tickets $q = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE closed='no' AND initial_ticket='yes' ORDER BY `date`,`time`;"; $r = mysql_query($q) or die("Cannot query \"{$q}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n = mysql_num_rows($r); if ($n < 1) { $waiting_new_users .= "<b>" . _("No pending support tickets!") . "</b><br>"; } else { $waiting_new_users .= "<table border=\"1\">\n<tr><td>" . _("Login") . "</td><td>" . _("Age") . "</td><td>" . _("Type") . "</td><td>" . _("Subject") . "</td><td>" . _("Last message from") . "</td><td>" . _("Last message age") . "</td></tr>"; for ($i = 0; $i < $n; $i++) { $a = mysql_fetch_array($r); if (strlen($a["customer_email"]) != 0) { $who = $a["customer_email"]; if (strlen($a["adm_login"]) != 0) { $who .= " / " . $a["adm_login"]; } } else { $who = $a["adm_login"]; } $waiting_new_users .= "<tr><td>{$who}</td>"; $q2 = "SELECT * FROM {$pro_mysql_tik_cats_table} WHERE id='" . $a["cat_id"] . "'"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { $cat = _("Type not found!"); } else { $a2 = mysql_fetch_array($r2); $cat = $a2["catname"]; } $age = calculateAge($a["date"], $a["time"]); $waiting_new_users .= "<td style=\"white-space:nowrap;\">{$age}</td><td>{$cat}</td><td style=\"white-space:nowrap;\"><a href=\"" . $_SERVER["PHP_SELF"] . "?subaction=resolv_ticket&tik_id=" . $a["id"] . "\">" . htmlspecialchars(stripslashes($a["subject"])) . "</a></td>"; $next_reply_id = $a["reply_id"]; $last_reply_text = "<font color=\"green\">" . _("Admin") . "</font>"; $last_message_date = $a["date"]; $last_message_time = $a["time"]; $loop_num = 0; $last_guy_replied = "user"; while ($next_reply_id != 0 && $loop_num < 49) { $loop_num++; $q2 = "SELECT * FROM {$pro_mysql_tik_queries_table} WHERE id='{$next_reply_id}';"; $r2 = mysql_query($q2) or die("Cannot query \"{$q2}\" ! Line: " . __LINE__ . " in file: " . __FILE__ . " mysql said: " . mysql_error()); $n2 = mysql_num_rows($r2); if ($n2 != 1) { echo "Warning: couldn't find tik query {$next_reply_id} in last reply detection!"; break; } $a3 = mysql_fetch_array($r2); $last_message_date = $a3["date"]; $last_message_time = $a3["time"]; if ($a3["admin_or_user"] == "user") { $last_guy_replied = "user"; } else { $last_guy_replied = "admin"; } $next_reply_id = $a3["reply_id"]; if ($loop_num >= 49) { echo "Warning: loop_num exeeded 50, not displaying last ticket reply from line" . __LINE__ . " file " . __FILE__; } } if ($last_guy_replied == "user") { $last_reply_text = "<font color=\"red\">" . _("User") . "</font>"; } $waiting_new_users .= "<td>{$last_reply_text}</td>"; $age2 = calculateAge($last_message_date, $last_message_time); $waiting_new_users .= "<td>" . $age2 . "</td>"; $waiting_new_users .= "</tr>"; } $waiting_new_users .= "</table>"; } return "<table>\n<tr>\n\t<td valign=\"top\">" . $waiting_new_users . "</td>\n\t</tr><tr>\n\t<td valign=\"top\">" . $add_a_user . "</td>\n</tr></table>"; }
expects(withKeys('first_name', 'last_name'), $data); return $data['first_name'] . ' ' . $data['last_name']; } try { getUserFullName(array('hello' => 'world')); } catch (\InvalidArgumentException $e) { echo $e->getMessage() . "\n"; } // 7. Specify object with methods function pet($duck) { expects(withMethod('quack'), $duck); } try { pet(new Integer()); } catch (\InvalidArgumentException $e) { echo $e->getMessage() . "\n"; } // 8. Specify with custom checking function function calculateAge($yearOfBirth) { expectsToBe($yearOfBirth, 'to be an integer > 1900 and <= current year', function ($arg) { return is_int($arg) && $arg > 1900 && $arg <= (int) date('Y'); }); return (int) date('Y') - $yearOfBirth; } try { $age = calculateAge(1800); } catch (\InvalidArgumentException $e) { echo $e->getMessage() . "\n"; }
?> </td> <td><?php echo $user['email']; ?> </td> <td><?php echo $user['gender'] == 'm' ? 'Masculino' : 'Feminino'; ?> </td> <td><?php echo dateConvert($user['birthdate']); ?> </td> <td><?php echo calculateAge($user['birthdate']); ?> anos</td> <td> <a href="form-edit.php?id=<?php echo $user['id']; ?> ">Editar</a> <a href="delete.php?id=<?php echo $user['id']; ?> " onclick="return confirm('Tem certeza de que deseja remover?');">Remover</a> </td> </tr> <?php }
/** * gets userage of current user * * @param Array $userData Current userdata * @param View $view Current view * @return Int $userAge Current userage */ function getUserAge($userData, $view) { $userBirthday = explode("-", $userData["billingaddress"]["birthday"]); $userAge = calculateAge($userBirthday[2], $userBirthday[1], $userBirthday[0]); if ($userAge && $userAge < 18) { $view->piRatepayInvoiceWarning = 'toyoung'; $view->piRatepayRateWarning = 'toyoung'; $view->piRatepayDebitWarning = 'toyoung'; $view->pi_ratepay_toyoung = true; } return $userAge; }
function sn_scoutnet_api_members_html_page() { $options = get_option('sn_scoutnet_api'); //$_SESSION = array(); // Finally, destroy the session. //session_destroy(); //print_r($_SESSION); ?> <script type="text/javascript"> var templateDir = "<?php echo SN_API_PLUGIN_URL; ?> "; </script> <div class="wrap"> <h2>Contacten beheer</h2> <?php $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'per-persoon'; ?> <h2 class="nav-tab-wrapper"> <a href="?page=scoutnet-api-members&tab=per-persoon" class="nav-tab <?php echo $active_tab == 'per-persoon' ? 'nav-tab-active' : ''; ?> ">Per persoon</a> <a href="?page=scoutnet-api-members&tab=per-adres" class="nav-tab <?php echo $active_tab == 'per-adres' ? 'nav-tab-active' : ''; ?> ">Per adres</a> </h2> <?php // HARDCODED //Array ( [21] => Array ( [natid] => 21 [natcode] => BE [nation] => België [nat] => Belg ) [56] => Array ( [natid] => 56 [natcode] => DE [nation] => Duitsland [nat] => Duitser ) [69] => Array ( [natid] => 69 [natcode] => FR [nation] => Frankrijk [nat] => Fransman ) [152] => Array ( [natid] => 152 [natcode] => NL [nation] => Nederland [nat] => Nederlander ) ) $nations = array('21' => array('natid' => 21, 'natcode' => 'BE', 'nation' => 'België', 'nat' => 'Belg'), '56' => array('natid' => 56, 'natcode' => 'DE', 'nation' => 'Duitsland', 'nat' => 'Duitser'), '69' => array('natid' => 69, 'natcode' => 'FR', 'nation' => 'Frankrijk', 'nat' => 'Fransman'), '152' => array('natid' => 152, 'natcode' => 'NL', 'nation' => 'Nederland', 'nat' => 'Nederlander')); $auth_user = get_bloginfo('admin_email'); if ($active_tab == 'per-persoon') { /* // TODO waarschijnlijk nodig voor dep if (isset($_GET['accountid'])){ $accountid = intval($_GET['accountid']); }else{ $accountid=$account; } */ //unset($_SESSION['sections'][$options['accountid']]); if (!isset($_SESSION['sections'][$options['accountid']])) { $call = sn_getAllSections($options['accountid']); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $all_sections = $call['decoded']['body']['data']; } else { $all_sections = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Sections failure</strong></p></div>"; } $_SESSION['sections'][$options['accountid']] = $all_sections; } else { $all_sections = $_SESSION['sections'][$options['accountid']]; } if (!isset($_SESSION['types'][$options['accountid']])) { $call = sn_getAllTypes($options['accountid']); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $all_types = $call['decoded']['body']['data']; } else { $all_types = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Types failure</strong></p></div>"; } $_SESSION['types'][$options['accountid']] = $all_types; } else { $all_types = $_SESSION['types'][$options['accountid']]; } if (isset($_POST['filters']) && !isset($_POST['sections'])) { unset($_SESSION['sections']['filter']); } if (!isset($_SESSION['sections']['filter'])) { $_SESSION['sections']['filter']['id'] = ""; $_SESSION['sections']['filter']['name'] = ""; $_SESSION['sections']['filter']['arr'] = array(); } if (isset($_POST['sections'])) { unset($_SESSION['sections']['filter']); $_SESSION['sections']['filter']['id'] = implode(":", $_POST['sections']); $_SESSION['sections']['filter']['arr'] = $_POST['sections']; foreach ($all_sections as $k => $v) { if (in_array($k, $_POST['sections'])) { $_SESSION['sections']['filter']['name'] .= "{$v['name']}, "; } } $_SESSION['sections']['filter']['name'] = substr($_SESSION['sections']['filter']['name'], 0, -2); } if (isset($_POST['filters']) && !isset($_POST['types'])) { unset($_SESSION['types']['filter']); } if (!isset($_SESSION['types']['filter'])) { $_SESSION['types']['filter']['id'] = ""; $_SESSION['types']['filter']['name'] = ""; $_SESSION['types']['filter']['arr'] = array(); } if (isset($_POST['types'])) { unset($_SESSION['types']['filter']); $_SESSION['types']['filter']['id'] = implode(":", $_POST['types']); $_SESSION['types']['filter']['arr'] = $_POST['types']; foreach ($all_types as $k => $v) { if (in_array($k, $_POST['types'])) { $_SESSION['types']['filter']['name'] .= "{$v['name']}, "; } } $_SESSION['types']['filter']['name'] = substr($_SESSION['types']['filter']['name'], 0, -2); } if (isset($_POST['btnVerzenden'])) { $args = array(); $personid = intval($_POST['personid']); $accountid = intval($_POST['accountid']); if (!isset($_POST['section'])) { $_POST['section'] = array(); } if (!isset($_POST['type'])) { $_POST['type'] = array(); } $args['personid'] = $personid; $string_fields = array('fname' => 40, 'lname' => 40, 'birthday' => 10, 'tel' => 15, 'mobile' => 20, 'email' => 50, 'street' => 50, 'bus' => 5, 'nlcode' => 2, 'gem' => 70, 'natid' => 3, 'orgnum' => 20, 'gender' => 1, 'countrycode' => 3, 'http_host' => 40, 'auth_user' => 40); foreach ($string_fields as $key => $value) { if (isset($_POST[$key])) { $args[$key] = substr(trim($_POST[$key]), 0, $value); } } if (isset($_POST['section'])) { $args['sections'] = implode(':', $_POST['section']); } // optional string 1:2:3:6 if (isset($_POST['type'])) { $args['types'] = implode(':', $_POST['type']); } // optional string 1:2:3:6 $args['alert'] = "mailto:jorisp@scoutnet.be"; try { $call = sn_updateMember($personid, $accountid, $args); $warnings = $call['decoded']['head']['warning']; if (count($warnings) > 0) { echo "<div class=\"update-nag settings-error\">"; foreach ($warnings as $key => $value) { echo "<p>{$value} [{$key}]</p>"; } echo "</div>"; } if ($call['decoded']['head']['status'] == 1) { echo "<div class=\"updated settings-error\"><p><strong>Persoongegevens zijn aangepast.</strong></p></div>"; // update-nag } else { echo "<div class=\"error settings-error\"><p><strong>Aanpassing mislukt</strong></p></div>"; } } catch (Exception $ex) { printf('<br /><span class="error">%s</span><br />', $ex->getMessage()); } if (isset($_POST['sn_password']) && $_POST['sn_password'] != '') { $args = array(); $args['personid'] = intval($_POST['personid']); $args['username'] = substr(trim($_POST['sn_username']), 0, 50); $args['password'] = substr(trim($_POST['sn_password']), 0, 50); try { $call = sn_updateMemberPassword($personid, $accountid, $args); $warnings = $call['decoded']['head']['warning']; if (count($warnings) > 0) { echo "<div class=\"update-nag settings-error\">"; foreach ($warnings as $key => $value) { echo "<p>{$value} [{$key}]</p>"; } echo "</div>"; } if ($call['decoded']['head']['status'] == 1) { echo "<div class=\"updated settings-error\"><p><strong>Password updated.</strong></p></div>"; // update-nag } else { echo "<div class=\"error settings-error\"><p><strong>Aanpassing mislukt</strong></p></div>"; } } catch (Exception $ex) { printf('<br /><span class="error">%s</span><br />', $ex->getMessage()); } } } if (isset($_POST['del'])) { if ($_POST['del'] == 'y') { try { $args = array(); $personid = intval($_POST['personid']); $call = sn_delMember($personid); $warnings = $call['decoded']['head']['warning']; if (count($warnings) > 0) { echo "<div class=\"update-nag settings-error\">"; foreach ($warnings as $key => $value) { echo "<p>{$value} [{$key}]</p>"; } echo "</div>"; } if ($call['decoded']['head']['status'] == 1) { echo "<div class=\"updated settings-error\"><p><strong>Person deleted.</strong></p></div>"; // update-nag } else { echo "<div class=\"error settings-error\"><p><strong>Aanpassing mislukt</strong></p></div>"; } unset($_GET['personid']); //?? } catch (Exception $ex) { printf('<br /><span class="error">%s</span><br />', $ex->getMessage()); } } } if (isset($_GET['personid'])) { $personid = intval($_GET['personid']); $accountid = intval($_GET['accountid']); //$auth_user = get_bloginfo('admin_email'); try { if ($personid > 0) { $call = sn_getMember($personid, $accountid); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $person = $call['decoded']['body']['data']; } else { $person = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Types failure</strong></p></div>"; } } else { $person['id'] = 0; $person['accountid'] = $options['accountid']; $person['natid'] = 21; $person['countrycode'] = "BE"; $person['birthday'] = '0000-00-00'; } //var_dump($person); if ($person) { if ($person['gender'] == 'F') { $person['gender'] = 'V'; } // Geslacht (wordt in de database webgeschreven als 'F') // Onbekend en een nieuw persoon -> Belg if ($person['natid'] == 247 && $personid == 0) { $person['natid'] = 21; } // Nationaliteit // Default Country Belgium //if (($person['countrycode']=='')&&($personid==0)){$person['countrycode']="BE";} // Land default BE if ($person['countrycode'] == '') { $person['countrycode'] = "BE"; } // Land default BE // Birthday required if (is_null($person['birthday'])) { $person['birthday'] = '0000-00-00'; } //$person['fname'] = utf8_decode($person['fname']); //$person['lname'] = utf8_decode($person['lname']); //$person['street'] = utf8_decode($person['street']); //$person['city'] = utf8_decode($person['city']); $sections = array(); $types = array(); //var_dump($person['sections']); if (isset($person['sections'])) { $sections = flat_array($person['sections'], 'id'); } if (isset($person['types'])) { $types = flat_array($person['types'], 'id'); } //print_r($person); //var_dump($sections); //var_dump($types); if (isset($_GET['locationid'])) { $locationid = intval($_GET['locationid']); //$location = $mm->getLocation($locationid); $call = sn_getLocation($locationid); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $location = $call['decoded']['body']['data']; } else { $location = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Locations failure</strong></p></div>"; } //$person['street'] = utf8_decode($location['street']); $person['street'] = $location['street']; $person['bus'] = $location['bus']; $person['nlcode'] = $location['nlcode']; $person['postcode'] = $location['postcode']; //$person['city'] = utf8_encode($location['city']); $person['city'] = $location['city']; $person['contrycode'] = $location['countrycode']; } if ($personid > 0) { ?> <form action="?page=scoutnet-api-members&personid=<?php echo $personid; ?> " method="post" name="frmlidwijzigen" id="frmlidwijzigen"> <?php } else { ?> <form action="?page=scoutnet-api-members" method="post" name="frmlidwijzigen" id="frmlidwijzigen"> <?php } ?> <br /><h3>Vul alle gegevens aan en klik op "Verzenden"</h3><br /> <input type="hidden" name="accountid" value="<?php echo $person['accountid']; ?> " /> <input type="hidden" name="del" value="n" /> <input type="hidden" name="http_host" value="<?php echo $_SERVER['HTTP_HOST']; ?> " /> <input type="hidden" name="auth_user" value="<?php echo $auth_user; ?> " /> <label for="orgnum">Koepel ID</label> <input type="text" name="orgnum" id="orgnum" value="<?php echo $person['orgnum']; ?> " size="10" maxlength="20" title="lidnummer bij koepel" /><span class="notatie"><?php echo $options['orgname']; ?> lidnummer</span><br /> <label for="personid"><?php echo $options['depmark']; ?> ID</label> <input type="text" name="personid" id="personid" value="<?php echo $person['id']; ?> " size="10" title="<?php echo $options['depmark']; ?> ID" readonly="readonly" /> <input type="text" name="sn_username" id="sn_username" value="<?php echo $person['username']; ?> " size="30" title="Username" readonly="readonly" /> <img width="9" height="9" title="change password" src="<?php echo SN_API_PLUGIN_URL; ?> img/plus.gif" name="state14" onclick="exp(14)" alt="password" id="state14"> <div id="item14" style="display: none;" class="sourcecode"> <br /> <input type="button" class="button button-primary" value="generate new password" onclick="generate_password()" /><input name="sn_password" id="sn_password" type="text" size="24" maxlength="20" value="" autocomplete="off" class="password1" /> <span class="notatie">Geef enkel het nieuwe paswoord als je dit wilt wijzigen</span> </div> <br /> <input type="hidden" name="score" id="score" value="" /> <label for="fname">Voornaam</label> <input type="text" name="fname" class="required" id="fname" maxlength="50" size="40" title="geef de voornaam" value="<?php echo $person['fname']; ?> " /><br /> <label for="lname">Familienaam</label> <input type="text" name="lname" class="required" id="lname" maxlength="50" size="40" title="geef de familienaam" value="<?php echo $person['lname']; ?> " /><br /> <label for="birthday">Geboortedatum</label> <input type="text" name="birthday" class="required" id="birthday" maxlength="10" title="geef de geboortedatum" value="<?php echo $person['birthday']; ?> " /><span class="notatie">jjjj-mm-dd</span><br /> <label for="tel">Telefoon</label> <input type="text" name="tel" id="tel" maxlength="15" size="40" title="geef telefoonnnumer" value="<?php echo $person['tel']; ?> " /><span class="notatie">+32.12345678</span><br /> <label for="mobile">GSM</label> <input type="text" name="mobile" id="mobile" maxlength="20" size="40" title="geef mobiel nummer" value="<?php echo $person['mobile']; ?> " /><br /> <label for="email">Email</label> <input type="text" name="email" class="email" id="email" maxlength="50" size="40" title="geef emailadres" value="<?php echo $person['email']; ?> " /><br /> <label for="gender">Geslacht</label> <input type="text" name="gender" class="required" id="gender" size="1" maxlength="1" title="geef het geslacht M|V" value="<?php echo $person['gender']; ?> " /><span class="notatie">M/V</span><br /> <label for="natid">Nationaliteit</label> <select name="natid" id="natid" title="kies de nationaliteit"> <?php foreach ($nations as $l_landen) { if ($person['natid'] != $l_landen['natid']) { echo "<option value='{$l_landen['natid']}'>{$l_landen['nat']}</option>"; } else { echo "<option value='{$l_landen['natid']}' selected='selected'>{$l_landen['nat']}</option>"; } } ?> </select><br /><br /> <label for="street">Straat + nummer</label> <input type="text" name="street" id="street" value="<?php echo $person['street']; ?> " title="geef de straatnaam" size="30" maxlength="50" /> bus <input type="text" name="bus" id="bus" value="<?php echo $person['bus']; ?> " title="geef het busnummer indien van toepassing" size="4" maxlength="5" /> <span class="notatie">Kerkwegel 11 + 1</span><br /> <label for="gem">Gemeente</label> <input type="text" name="gem" id="gem" value="<?php echo "{$person['postcode']} {$person['city']}"; ?> " size="40" maxlength="150" autocomplete="off" title="geef de postcode en gemeente" /> <input type="text" name="nlcode" id="nlcode" value="<?php echo "{$person['nlcode']}"; ?> " size="2" maxlength="2" title="Geef de 2 letter code (enkel voor Nederland)" style="<?php if ($person['countrycode'] == "BE") { echo "display:none;visibility:hidden;"; } else { echo "display:inline;visibility:visible;"; } ?> " /> <select name="countrycode" id="countrycode" onchange="toonNLcode(this.value);" title="geef de 2 letterige landcode (BE|NL)"> <?php foreach ($nations as $l_landen) { if ($person['countrycode'] != $l_landen["natcode"]) { echo "<option value='{$l_landen["natcode"]}'>{$l_landen["natcode"]}</option>"; } else { echo "<option value='{$l_landen["natcode"]}' selected='selected'>{$l_landen["natcode"]}</option>"; } } ?> </select> <?php //if($person->getLocationID()>1){ if ($personid > 0 && $person['locationid'] > 0) { echo "<a href=\"?page=scoutnet-api-members&tab=per-adres&locationid={$person['locationid']}\">Wil je meteen het <b>adres</b> van ALLE gezinsleden wijzigen? klik dan op deze link</a>"; } //} echo "<br />"; echo "<div id=\"container_st\">\n"; echo "<div>\n"; echo "<fieldset>\n"; echo "<legend title=\"Select one or more sections\">Sections:</legend>\n"; if (count($all_sections) > 0) { foreach ($all_sections as $k => $v) { if (!in_array($k, $sections)) { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"section[]\" /> {$v['name']}<br />\n"; } else { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"section[]\" checked=\"checked\" /> <b>{$v['name']}</b><br />\n"; } } } else { echo "Aanmaak van sections doe je momenteel nog via https://my.scoutnet.be"; } echo "</fieldset>\n</div>\n<div>\n<fieldset>\n"; echo "<legend title=\"Select one or more types\">Types:</legend>\n"; if (count($all_types) > 0) { foreach ($all_types as $k => $v) { if (!in_array($k, $types)) { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"type[]\" /> {$v['name']}<br />\n"; } else { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"type[]\" checked=\"checked\" /> <b>{$v['name']}</b><br />\n"; } } } else { echo "Aanmaak van types doe je momenteel nog via https://my.scoutnet.be"; } echo "</fieldset>\n"; echo "</div>\n"; echo "</div>\n"; echo "<div class=\"snspacer\"></div>"; ?> <br /> <br /> <input name="btnVerzenden" id="btnVerzenden" class="button button-primary" type="submit" value="Verzenden" /> <?php if ($personid > 0) { ?> <img src="<?php echo SN_API_PLUGIN_URL; ?> img/delete.gif" style="cursor:pointer" onclick="dele('<?php echo $personid; ?> ');" width="20" height="16" alt="delete" title="delete person" /> <?php } ?> </form> <?php } else { echo "<br /><span class=\"warning\">Person error</span><br />"; } } catch (Exception $ex) { echo "<br /><br /><span class=\"error\">" . $ex->getMessage() . "</span><br />"; } } //$members = $mm->getAllMembers($_SESSION['sections']['filter']['id'],$_SESSION['types']['filter']['id']); $call = sn_getAllMembers($options['accountid'], $_SESSION['sections']['filter']['id'], $_SESSION['types']['filter']['id']); // section en type filter if ($call['decoded']['head']['status'] == 1) { $members = $call['decoded']['body']['data']; //var_dump($members); if (count($members) >= 0) { $all = array('orgnum' => 'Koepel ID', 'id' => 'Scoutnet ID', 'groupname' => 'Groepsnaam', 'username' => 'Username', 'fname' => 'Voornaam', 'lname' => 'Familienaam', 'since' => 'Aansluitdatum (todo)', 'svd' => 'Aantal jaren lid (todo)', 'birthday' => 'Geboortedatum', 'age' => 'Leeftijd', 'gender' => 'Geslacht', 'nat' => 'Nationaliteit', 'tel' => 'Telefoon', 'mobile' => 'GSM', 'email' => 'Email', 'adres' => 'Adres', 'street' => 'Straat', 'bus' => 'Bus', 'nlcode' => 'NLcode', 'postcode' => 'Postcode', 'city' => 'Plaats', 'pcode' => 'Postcode Plaats', 'gem' => 'Gemeente', 'regio' => 'Regio', 'prov' => 'Provincie', 'country' => 'Land'); if (isset($_POST['kolom'])) { $_SESSION[$active_tab]['kolom'] = $_POST['kolom']; } if (!isset($_SESSION[$active_tab]['kolom'])) { $kolom = array('id', 'fname', 'lname', 'birthday', 'email'); } else { $kolom = $_SESSION[$active_tab]['kolom']; } if (isset($_POST['filter'])) { $_SESSION[$active_tab]['filter'] = array_filter($_POST['filter']); } if (!isset($_SESSION[$active_tab]['filter'])) { $_POST['filter'] = array(); } else { $_POST['filter'] = $_SESSION[$active_tab]['filter']; } if (!isset($_POST['andor'])) { $_POST['andor'] = 'and'; } if (!isset($_POST['check'])) { $check = array(); } else { $check = $_POST['check']; } ?> <br />Filter op inhoud: <img height="9" width="9" alt="expand" title="column filter" onclick="exp(901)" name="state901" src="<?php echo SN_API_PLUGIN_URL; ?> /img/plus.gif" id="state901" border="0" /><?php if (count($_POST['filter']) > 0) { echo " <img src=\"" . SN_API_PLUGIN_URL . "img/filter.png\" width=\"24\" height=\"23\" />"; } ?> <br /> <div id="item901" style="font-size: 12px; margin-left: 20px; display: none;"> <form action="" method="post"> <table> <tr><td><input type="radio" name="andor" value="and" <?php if ($_POST['andor'] == 'and') { echo " checked=\"checked\""; } ?> /> EN <input type="radio" name="andor" value="or" <?php if ($_POST['andor'] == 'or') { echo " checked=\"checked\""; } ?> />OF </td><td> </td><td> </td></tr> <?php foreach ($all as $key => $value) { ?> <tr><td><input type="text" id="f<?php echo $key; ?> " name="filter[<?php echo $key; ?> ]" size="10" value="<?php echo @$_POST['filter'][$key]; ?> "<?php if (!in_array($key, $kolom)) { echo " disabled=\"disabled\""; } ?> /></td><td><input type="checkbox" value="<?php echo $key; ?> " name="kolom[]"<?php if (in_array($key, $kolom)) { echo " checked=\"checked\""; } ?> onclick="setCheck(this,'f<?php echo $key; ?> ');" /></td><td><?php echo $value; ?> </td></tr> <?php } ?> <tr><td colspan="2"><input type="submit" name="" value="Filter on content" class="button button-primary" title="Selecteer de kolomkoppen" /></td></tr> </table> <br /> </form> </div> <br /> <?php // TODO filter op soort ook in een session variabele bewaren ?> Filter op soort: <img height="9" width="9" alt="expand" title="column filter" onclick="exp(902)" name="state902" src="<?php echo SN_API_PLUGIN_URL; ?> /img/plus.gif" id="state902" border="0" /><?php if (count($_SESSION['sections']['filter']['arr']) > 0 || count($_SESSION['types']['filter']['arr']) > 0) { echo " <img src=\"" . SN_API_PLUGIN_URL . "img/filter.png\" width=\"24\" height=\"23\" />"; } ?> <?php echo "<span title=\"sections\"><b>" . $_SESSION['sections']['filter']['name'] . "</b></span> <span title=\"types\"><b>" . $_SESSION['types']['filter']['name'] . "</b></span>"; ?> <br /> <div id="item902" style="font-size: 12px; margin-left: 20px; display: none;"> <br /> <form action="" method="post"> <input type="submit" value="Filter sections/types" name="filters" class="button button-primary" title="Maak selectie" /> <small>[beheer (toevoegen/verwijderen) voorlopig enkel mogelijk via my-site]</small><br /><br /> <div id="container_st"> <div> <fieldset> <legend>Sections:</legend> <?php foreach ($all_sections as $k => $v) { if (!in_array($k, $_SESSION['sections']['filter']['arr'])) { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"sections[]\" /> {$v['name']}<br />\n"; } else { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"sections[]\" checked=\"checked\" /> {$v['name']}<br />\n"; } } ?> <br /> </fieldset> </div> <div> <fieldset> <legend>Types:</legend> <?php foreach ($all_types as $k => $v) { if (!in_array($k, $_SESSION['types']['filter']['arr'])) { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"types[]\" /> {$v['name']}<br />\n"; } else { echo "<input type=\"checkbox\" value=\"{$k}\" name=\"types[]\" checked=\"checked\" /> {$v['name']}<br />\n"; } } ?> <br /> </fieldset> </div> </div> </form> </div> <div class="snspacer"></div> <?php echo "<table id=\"persons\" style=\"clear:both;\" class=\"tablesorter\">"; echo "<thead>"; echo "<tr>"; foreach ($all as $key => $value) { if (in_array($key, $kolom)) { echo "<th>{$value}</th>"; } } echo "</tr>"; echo "</thead>"; echo "<tbody>"; //var_dump($members); $filter_num = count($_POST['filter']); foreach ($members as $member) { if ($filter_num > 0) { $show_line = false; $elem_num = 0; foreach ($kolom as $f) { if (@$_POST['filter'][$f] != '') { $match = "1"; $pos = false; // aantal jaren lid if ($_POST['filter'][$f][0] == '>' && ($f == "svd" || $f == "age")) { $match = ">"; } if ($_POST['filter'][$f][0] == '<' && ($f == "svd" || $f == "age")) { $match = "<"; } /* if (($_POST['filter'][$f]{0}=='>')&&($f=="afstand")){ $pieces = explode("-", $member['afstand']); $pieces = array_map("inte", $pieces); $fafstand = intval(substr($_POST['filter'][$f],1,9)); foreach ($pieces as $piece){ if ($piece>$fafstand){$show_line=true;} } } */ if ($_POST['filter'][$f][0] == '%') { $match = "0"; } switch ($_POST['andor']) { case 'or': switch ($match) { case "1": if (strtolower($member[$f]) == strtolower($_POST['filter'][$f])) { $show_line = true; } break; case "0": $pos = stripos($member[$f], substr($_POST['filter'][$f], 1)); if ($pos !== false) { $show_line = true; } break; case ">": $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); switch ($f) { case "svd": $my_num = calculateAge($member['since']); break; case "age": $my_num = calculateAge($member['birthday']); break; default: } if ($my_num > $fafstand) { $show_line = true; } break; case "<": $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); switch ($f) { case "svd": $my_num = calculateAge($member['since']); break; case "age": $my_num = calculateAge($member['birthday']); break; default: } if ($my_num < $fafstand) { $show_line = true; } break; } break; case 'and': switch ($match) { case "1": if (strtolower($member[$f]) == strtolower($_POST['filter'][$f])) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; case "0": $pos = stripos($member[$f], substr($_POST['filter'][$f], 1)); if ($pos !== false) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; case ">": $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); $aantal_afstanden_groter_dan_gevraagd = 0; switch ($f) { case "svd": $my_num = calculateAge($member['since']); break; case "age": $my_num = calculateAge($member['birthday']); break; default: } if ($my_num > $fafstand) { $aantal_afstanden_groter_dan_gevraagd += 1; } if ($aantal_afstanden_groter_dan_gevraagd > 0) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; case "<": $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); $aantal_afstanden_groter_dan_gevraagd = 0; switch ($f) { case "svd": $my_num = calculateAge($member['since']); break; case "age": $my_num = calculateAge($member['birthday']); break; default: } if ($my_num < $fafstand) { $aantal_afstanden_groter_dan_gevraagd += 1; } if ($aantal_afstanden_groter_dan_gevraagd > 0) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; } break; } } } } else { $show_line = true; } foreach ($all as $key => $value) { if (in_array($key, $kolom)) { $member['class'][$key] = 'normal'; } } if ($show_line) { $span = array(); if (in_array('id', $kolom)) { $member['id'] = "<a href=\"?page=scoutnet-api-members&personid={$member['id']}&accountid={$member['accountid']}\" class=\"{$member['class']['id']}\">{$member['id']}</a>"; array_push($span, "id"); } if (in_array('adres', $kolom)) { if ($member['bus'] == '') { $member['adres'] = "{$member['street']} {$member['pcode']}"; } else { $member['adres'] = "{$member['street']} bus {$member['bus']} {$member['pcode']}"; } } if (in_array('age', $kolom)) { $member['age'] = calculateAge($member['birthday']) . " jaar"; } echo "<tr>"; foreach ($all as $key => $value) { if (in_array($key, $kolom)) { if (!in_array($key, $span)) { $member[$key] = "<span class=\"{$member['class'][$key]}\">{$member[$key]}</span>"; } echo "<td>{$member[$key]}</td>"; } } echo "</tr>\n"; } } echo "</tbody>"; echo "</table>"; } else { echo "<span class=\"info\">Er zijn nog geen leden.</span>"; } echo "<br /><img src=\"" . SN_API_PLUGIN_URL . "img/add_contact.gif\" alt=\"nieuw persoon toevoegen\" title=\"nieuw persoon toevoegen\" width=\"25\" height=\"21\" /> <a href=\"?page=scoutnet-api-members&personid=0\">Persoon toevoegen.</a><br />"; } else { echo "<div class=\"error\">{$call['decoded']['head']['error_message']}<br /><br />Is de secret key correct? Contacteer info@scoutnet.be</div>"; } } else { // per-adres if (isset($_POST['btnVerzenden'])) { $args = array(); $locationid = intval($_POST['locationid']); $args['locationid'] = $locationid; $string_fields = array('name' => 50, 'street' => 50, 'bus' => 5, 'nlcode' => 2, 'gem' => 70, 'countrycode' => 2, 'http_host' => 40, 'auth_user' => 40); foreach ($string_fields as $key => $value) { if (isset($_POST[$key])) { $args[$key] = substr(trim($_POST[$key]), 0, $value); } } try { $call = sn_updateLocation($locationid, $args); $warnings = $call['decoded']['head']['warning']; if (count($warnings) > 0) { echo "<div class=\"update-nag settings-error\">"; foreach ($warnings as $key => $value) { echo "<p>{$value} [{$key}]</p>"; } echo "</div>"; } if ($call['decoded']['head']['status'] == 1) { echo "<div class=\"updated settings-error\"><p><strong>Adresgegevens zijn aangepast.</strong></p></div>"; // update-nag } else { echo "<div class=\"error settings-error\"><p><strong>Aanpassing mislukt</strong></p></div>"; } } catch (Exception $ex) { printf('<br /><span class="error">%s</span><br />', $ex->getMessage()); } } if (isset($_GET['locationid'])) { $locationid = intval($_GET['locationid']); try { //$location = $mm->getLocation($locationid); $call = sn_getLocation($locationid); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $location = $call['decoded']['body']['data']; } else { $location = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Locations failure</strong></p></div>"; } //var_dump($location); if ($location) { // Default Country Belgium if ($location['countrycode'] == '' && $locationid == 0) { $location['countrycode'] = "BE"; } // Land default BE $location['name'] = $location['name']; // TODO check utf8_decode ??? $location['street'] = $location['street']; $location['city'] = $location['city']; ?> <form action="" method="post" name="frmlidwijzigen" id="frmlidwijzigen"> <br /><h3>Vul alle gegevens aan en klik op "Verzenden"</h3><br /> <input type="hidden" name="accountid" value="<?php echo $options['accountid']; ?> " /> <input type="hidden" name="locationid" id="locationid" value="<?php echo $location['id']; ?> " /> <input type="hidden" name="http_host" value="<?php echo $_SERVER['HTTP_HOST']; ?> " /> <input type="hidden" name="auth_user" value="<?php echo $auth_user; ?> " /> <label for="name">Aanspreking</label> <input type="text" name="name" id="name" value="<?php echo $location['name']; ?> " title="geef de aanspreektitel" size="40" maxlength="100" /> <span class="notatie">De familie ..., De Heer en Mevrouw Peeters - Vandamme ...</span><br /> <label for="street">Straat + nummer</label> <input type="text" name="street" id="street" value="<?php echo $location['street']; ?> " title="geef de straatnaam en huisnummer" size="30" maxlength="50" /> bus <input type="text" name="bus" id="bus" value="<?php echo $location['bus']; ?> " title="geef het busnummer indien van toepassing" size="4" maxlength="10" /> <span class="notatie">Kerkwegel 25 [+ busnummer]</span><br /> <label for="gem">Gemeente</label> <input type="text" name="gem" id="gem" value="<?php echo "{$location['postcode']} {$location['city']}"; ?> " size="40" maxlength="150" autocomplete="off" title="geef de postcode en gemeente" /> <input type="text" name="nlcode" id="nlcode" value="<?php echo "{$location['nlcode']}"; ?> " size="2" maxlength="2" title="Geef de letter code (enkel voor Nederland)" style="<?php if ($location['countrycode'] != "NL") { echo "display:none;visibility:hidden;"; } else { echo "display:inline;visibility:visible;"; } ?> " /> <select name="countrycode" id="countrycode" title="geef de 2 letterige landcode" onchange="toonNLcode(this.value);"> <?php foreach ($nations as $l_landen) { if ($location['countrycode'] != $l_landen["natcode"]) { echo "<option value='{$l_landen["natcode"]}'>{$l_landen["natcode"]}</option>"; } else { echo "<option value='{$l_landen["natcode"]}' selected='selected'>{$l_landen["natcode"]}</option>"; } } ?> </select><br /> <?php foreach ($location['persons'] as $key => $row) { $birthday[$key] = $row['birthday']; $gender[$key] = $row['gender']; } //array_multisort($birthday, SORT_ASC, $l_members); array_multisort($gender, SORT_ASC, $birthday, SORT_ASC, $location['persons']); if (count($location['persons'] > 0)) { echo "<table cellspacing=\"10\">"; foreach ($location['persons'] as $member) { $member['fname'] = $member['fname']; $member['lname'] = $member['lname']; echo "<tr><td>"; $l_memberprofilepath = "https://my.scoutnet.be/members/profile/{$member['personid']}.jpg"; //if (file_exists($_SERVER['DOCUMENT_ROOT'].$l_memberprofilepath)){ if (file_exists($l_memberprofilepath)) { echo "<br /><a href=\"?page=scoutnet-api-members&personid={$member['personid']}\"><img src='{$l_memberprofilepath}' alt='{$member['fname']}' title='{$member['fname']}' /></a>"; } else { echo "<br /><a href=\"?page=scoutnet-api-members&personid={$member['personid']}\"><img src='https://my.scoutnet.be/members/profile/0.jpg' alt='{$member['fname']}' title='{$member['fname']}' /></a>"; } echo "</td>"; echo "<td>"; if ($member['email']) { echo "<a href=\"mailto:{$member['email']}\">{$member['fname']} {$member['lname']}</a><br />"; } else { echo "{$member['fname']} {$member['lname']}<br />"; } if ($member['mobile']) { echo "{$member['mobile']}<br />"; } echo "{$member['gender']} {$member['birthday']}<br />"; /* if ($member['paid']=='1'){$paidchecked=" checked=\"checked\" disabled=\"disabled\"";$paidstr="betaald";}else{$paidchecked="";$paidstr="";} echo "Lidgeld 2012 ? <input type=\"checkbox\" value=\"{$member['personid']}\"$paidchecked onclick=\"setPaid('{$member['personid']}',this.checked,'{$l_sessie->getSessionUIDencrypted()}');\" /><span id=\"gs{$member['personid']}\">{$paidstr}</span>"; */ echo "</td>"; echo "</tr>"; } echo "<tr><td><a href=\"?page=scoutnet-api-members&personid=0&locationid={$location['id']}\"><img src='https://my.scoutnet.be/members/profile/0.jpg' alt='nieuw contact' title='nieuw contact' /></a></td><td>Nieuw contact toevoegen <b>op dit adres</b>.</td></tr>"; echo "</table>"; } ?> <br /> <input name="btnVerzenden" id="btnVerzenden" class="button button-primary" type="submit" value="Verzenden" /> </form> <?php } else { //echo "<span class=\"warning\">Location error</span>"; } } catch (Exception $ex) { echo "<span class=\"error\">" . $ex->getMessage() . "</span>"; } } $call = sn_getAllLocations('residence'); if (isset($call['decoded']['head']['status']) && $call['decoded']['head']['status'] === "1") { if ($call['decoded']['body']['num'] != 0) { $locations = $call['decoded']['body']['data']; } else { $locations = array(); } } else { echo "<div class=\"error settings-error\"><p><strong>Locations failure</strong></p></div>"; } //var_dump($locations); //if ($locations===false){var_dump($snapi->showError());} if (count($locations) > 0) { $all = array('locationid' => 'Adres ID', 'name' => 'Aanspreking', 'adres' => 'Adres', 'street' => 'Straat', 'bus' => 'Bus', 'postcode' => 'Postcode', 'pcode' => 'Postcode Plaats', 'nlcode' => 'NL code', 'city' => 'Plaats', 'gem' => 'Gemeente', 'regio' => 'Regio', 'prov' => 'Provincie', 'country' => 'Land'); if (isset($_POST['kolom'])) { $_SESSION[$active_tab]['kolom'] = $_POST['kolom']; } if (!isset($_SESSION[$active_tab]['kolom'])) { $kolom = array('name', 'adres', 'pcode', 'regio'); } else { $kolom = $_SESSION[$active_tab]['kolom']; } if (isset($_POST['filter'])) { $_SESSION[$active_tab]['filter'] = array_filter($_POST['filter']); } if (!isset($_SESSION[$active_tab]['filter'])) { $_POST['filter'] = array(); } else { $_POST['filter'] = $_SESSION[$active_tab]['filter']; } if (!isset($_POST['andor'])) { $_POST['andor'] = 'and'; } if (!isset($_POST['check'])) { $check = array(); } else { $check = $_POST['check']; } ?> <br />Filter op inhoud: <img height="9" width="9" alt="expand" title="filter + selecteer kolommen" onclick="exp(901)" name="state901" src="<?php echo SN_API_PLUGIN_URL; ?> img/plus.gif" id="state901" /><?php if (count($_POST['filter']) > 0) { echo " <img src=\"" . SN_API_PLUGIN_URL . "img/filter.png\" width=\"24\" height=\"23\" />"; } ?> <br /> <div id="item901" class="sourcecode" style="font-size: 12px; margin-left: 20px; display: none;"> <form action="" method="post"> <table> <tr><td><input type="radio" name="andor" value="and" <?php if ($_POST['andor'] == 'and') { echo " checked=\"checked\""; } ?> /> EN <input type="radio" name="andor" value="or" <?php if ($_POST['andor'] == 'or') { echo " checked=\"checked\""; } ?> />OF </td><td> </td><td> </td></tr> <?php foreach ($all as $key => $value) { ?> <tr><td><input type="text" id="f<?php echo $key; ?> " name="filter[<?php echo $key; ?> ]" size="10" value="<?php echo @$_POST['filter'][$key]; ?> "<?php if (!in_array($key, $kolom)) { echo " disabled=\"disabled\""; } ?> /></td><td><input type="checkbox" value="<?php echo $key; ?> " name="kolom[]"<?php if (in_array($key, $kolom)) { echo " checked=\"checked\""; } ?> onclick="setCheck(this,'f<?php echo $key; ?> ');" /></td><td><?php echo $value; ?> </td></tr> <?php } ?> <tr><td colspan="2"><input type="submit" name="" value="Filter on content" class="button button-primary" title="Selecteer de kolomkoppen" /></td></tr> </table> </form> </div> <?php echo "<table id=\"addresses\" class=\"tablesorter\">"; echo "<thead>"; echo "<tr>"; foreach ($all as $key => $value) { if (in_array($key, $kolom)) { echo "<th>{$value}</th>"; } } echo "</tr>"; echo "</thead>"; echo "<tbody>"; //var_dump($members); foreach ($locations as $location) { $l_class = "normal"; // kleurtjes gebruiken $span = array(); $l_locationid = $location['locationid']; if (in_array('name', $kolom)) { //$location['name']=utf8_decode($location['name']); //?? TODO check if ($location['name'] == '') { $location['name'] = "EMPTY"; } if ($location['bad'] == 0) { $location['name'] = "<a href=\"?page=scoutnet-api-members&tab=per-adres&locationid={$location['locationid']}\">{$location['name']}</a>"; } else { $location['name'] = "<a href=\"?page=scoutnet-api-members&tab=per-adres&locationid={$location['locationid']}\" style=\"color:red;\" title=\"Dit adres is vermoedelijk fout.\">{$location['name']}</a>"; } array_push($span, "name"); } /* if ((in_array('street',$kolom))||((in_array('adres',$kolom)))){ $location['street']=utf8_decode($location['street']); } if (in_array('pcode',$kolom)){ $location['pcode']=utf8_decode($location['pcode']); } */ if (in_array('adres', $kolom)) { if ($location['bus'] == '') { $location['adres'] = "{$location['street']} {$location['num']}"; } else { $location['adres'] = "{$location['street']} {$location['num']} bus {$location['bus']}"; } } /* if (in_array('country',$kolom)){ $location['country']=utf8_decode($location['country']); } if (in_array('regio',$kolom)){ $location['regio']=utf8_decode($location['regio']); } if (in_array('gem',$kolom)){ $location['gem']=utf8_decode($location['gem']); } */ if (in_array('locationid', $kolom)) { $location['locationid'] = "<a href=\"?page=scoutnet-api-members&tab=per-adres&locationid={$location['locationid']}\">{$location['locationid']}</a>"; array_push($span, "locationid"); } if ($filter_num > 0) { $show_line = false; $elem_num = 0; foreach ($kolom as $f) { if (@$_POST['filter'][$f] != '') { $match = "1"; $pos = false; // afstanden if ($_POST['filter'][$f][0] == '>' && $f == "afstand") { $match = ">"; } /* if (($_POST['filter'][$f]{0}=='>')&&($f=="afstand")){ $pieces = explode("-", $location['afstand']); $pieces = array_map("inte", $pieces); $fafstand = intval(substr($_POST['filter'][$f],1,9)); foreach ($pieces as $piece){ if ($piece>$fafstand){$show_line=true;} } } */ if ($_POST['filter'][$f][0] == '%') { $match = "0"; } switch ($_POST['andor']) { case 'or': switch ($match) { case "1": if (strtolower($location[$f]) == strtolower($_POST['filter'][$f])) { $show_line = true; } break; case "0": $pos = stripos($location[$f], substr($_POST['filter'][$f], 1)); if ($pos !== false) { $show_line = true; } break; case ">": $pieces = explode("-", $location['afstand']); $pieces = array_map("inte", $pieces); $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); foreach ($pieces as $piece) { if ($piece > $fafstand) { $show_line = true; } } break; } break; case 'and': switch ($match) { case "1": if (strtolower($location[$f]) == strtolower($_POST['filter'][$f])) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; case "0": $pos = stripos($location[$f], substr($_POST['filter'][$f], 1)); if ($pos !== false) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; case ">": $pieces = explode("-", $location['afstand']); $pieces = array_map("inte", $pieces); $fafstand = intval(substr($_POST['filter'][$f], 1, 9)); // geef het aantal afstanden die groter zijn dan de gevraagde afstand. //als dat getal groter is dan 1 dan $elem_num+=1 $aantal_afstanden_groter_dan_gevraagd = 0; foreach ($pieces as $piece) { if ($piece > $fafstand) { $aantal_afstanden_groter_dan_gevraagd += 1; } } if ($aantal_afstanden_groter_dan_gevraagd > 0) { $elem_num += 1; } if ($filter_num == $elem_num) { $show_line = true; } break; } break; } } } } else { $show_line = true; } //$show_line=true; if ($l_locationid == 787) { $show_line = false; } if ($show_line) { $l_teller += 1; echo "<tr>"; /* foreach ($all as $key => $value){ if (in_array($key,$kolom)){echo "<td>{$location[$key]}</td>";} } */ foreach ($all as $key => $value) { if (in_array($key, $kolom)) { if (!in_array($key, $span)) { $location[$key] = "<span>{$location[$key]}</span>"; } //echo "<td><span class=\"{$location['class'][$key]}\">{$location[$key]}</span></td>"; echo "<td>{$location[$key]}</td>"; } } echo "</tr>\n"; } } echo "</tbody>"; echo "</table>"; } else { echo "Er zijn nog geen locations."; } //} echo "<br /><img src=\"" . SN_API_PLUGIN_URL . "img/add_contact.gif\" alt=\"nieuw persoon toevoegen\" title=\"nieuw persoon toevoegen\" width=\"25\" height=\"21\" /> <a href=\"?page=scoutnet-api-members&personid=0\">Persoon toevoegen.</a><br />"; if ($l_teller != 1) { echo "<p>In totaal werden <strong>{$l_teller} adressen</strong> gevonden.</p>"; } else { echo "<p>In totaal werd <strong>1 adres</strong> gevonden.</p>"; } $filter_str = ''; if ($filter_num > 0) { $filter_str = "Filter: "; foreach ($_POST['filter'] as $key => $value) { $filter_str .= "{$key}:<b>{$value}</b> {$_POST['andor']} "; } $filter_str = substr($filter_str, 0, -4); } echo $filter_str; ?> <br /> (*) Het veld "Aanspreking" kan je vrij invullen. Dit in functie van de samenstelling van het gezin.<br /> Dit kan je gebruiken voor het versturen van brieven.<br /> Er verschijnt "EMPTY" indien dit veld leeg is.<br /> Indien de aanspreking in het rood staat, dan is het adres vermoedelijk niet juist.<br /> <?php } ?> </div> <?php }