function make_rand_wo() { global $WOProjects; global $WOIPTeams; global $WOPriorities; $lines = file("docs/randomtext.txt", FILE_USE_INCLUDE_PATH); $titles = file("docs/randomnames.txt", FILE_USE_INCLUDE_PATH); $accounts = get_all_accounts(); $revs = array(0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); $pris = array(0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3); $app = array(false, false, false, true, true, true, true, true, true, true); $nsuccess = 0; $na = 0; $nas = 0; $nf = 0; $nc = 0; $nact = 0; $nacap = 0; $nwo = count($titles); foreach ($titles as $t) { $data = array(); $data["Title"] = trim($t); $data["Description"] = trim($lines[rand(0, count($lines) - 1)]); $data["Priority"] = $WOPriorities[$pris[rand(0, count($pris) - 1)]]; $data["Project"] = $WOProjects[rand(1, count($WOProjects) - 1)]; $data["Revision"] = $revs[rand(0, count($revs) - 1)]; $data["Requestor"] = $WOIPTeams[rand(1, count($WOIPTeams) - 1)]; $data["Receiver"] = $WOIPTeams[rand(1, count($WOIPTeams) - 1)]; $data["AuthorID"] = $accounts[rand(0, count($accounts) - 1)]; $data["DateCreated"] = date('Y-m-d', time() - rand(0, 30) * 24 * 3600); $data["DateNeedBy"] = date('Y-m-d', time() + rand(0, 30) * 24 * 3600); $data["Approved"] = false; $data["ApprovedByCap"] = false; $data["Assigned"] = false; $data["Finished"] = false; $data["Closed"] = false; $data["Active"] = true; if ($data["Revision"] > 0) { $data["Approved"] = rand(0, 100) > 20; $data["ApprovedByCap"] = rand(0, 100) > 85; } if ($data["Approved"] || $data["ApprovedByCap"]) { $data["Assigned"] = rand(0, 100) > 30; $data["Finished"] = rand(0, 100) > 60; } if ($data["Finished"]) { $data["Closed"] = rand(0, 100) > 20; } if (!$data["Closed"]) { $data["Closed"] = rand(0, 100) > 95; } $data["Active"] = !(rand(0, 100) > 98); $result = CreateNewWorkOrder($data); if ($result[1] === true) { $nsuccess++; if ($data["Approved"]) { $na++; } if ($data["ApprovedByCap"]) { $nacap++; } if ($data["Assigned"]) { $nas++; } if ($data["Finished"]) { $nf++; } if ($data["Closed"]) { $nc++; } if (!$data["Active"]) { $nact++; } } else { echo '<br>' . $result[1] . $data["Title"]; } } $msg = "WOs added=" . $nsuccess . "\n"; $msg .= "App, CapApp= " . $na . ', ' . $nacap . ' ' . "\n"; $msg .= "Asgnd= " . $nas . ', Fin=' . $nf . ' Csd=' . $nc . ", NotAct=" . $nact; return $msg; }
function get_first_account($binding) { $accounts = get_all_accounts($binding); return $accounts[0]; }
break; case '--max-accounts': $max_accounts = $argv[++$i]; break; default: echo "Usage: {$prog} [--no-lists] [--no-fields] [--no-contacts] [--no-contact-fields] [--no-messages] [--no-deliveries] [--max-accounts num]\n"; exit(1); } } echo "<bronto-data>\n"; $login_result = bronto_agency_login(); if (!$login_result) { die("Unable to log in to agency account"); } $binding = $login_result['binding']; $accounts = get_all_accounts($binding); if ($accounts == null) { die("Unable to get accounts"); } echo "<accounts count=\"" . count($accounts) . "\">\n"; $acct_num = 0; foreach ($accounts as $acct) { echo "<account id=\"" . $acct->id . "\" name=\"" . $acct->name . "\" currContactCount=\"" . $acct->currContactCount . "\" " . "maxContactCount=\"" . $acct->maxContactCount . "\" monthEmailCount=\"" . $acct->monthEmailCount . "\" " . "currHostingSize=\"" . $acct->currHostingSize . "\" maxHostingSize=\"" . $acct->maxHostingSize . "\">\n"; // Now login to the subaccount using the agency account, but specifying the subaccount ID in the login. $login_result = bronto_agency_login($acct->id); if (!$login_result) { echo "<error text=\"INVALID ACCOUNT\"/>\n"; } else { $binding = $login_result['binding']; if ($disp_lists) { display_lists($binding);
display_errorbox("Must specify a username, password, and sitename."); print_request_login_form($fm_username, $fm_password, $fm_sitename); } else { $login_info = bronto_user_login($fm_username, $fm_password, $fm_sitename, $fm_siteid); process_login($login_info, $fm_username, $fm_password, $fm_sitename); } } else { if ($fm_stage == "suauth") { if (empty($fm_sessionid) || empty($fm_username) || empty($fm_sitename)) { display_errorbox("Must have a valid user session."); print_request_login_form($fm_username, $fm_password, $fm_sitename); } else { if (empty($fm_password) || empty($fm_siteid)) { display_errorbox("Must select the target sub-account."); $bapi = connect_bronto_session($fm_sessionid); $accounts = get_all_accounts($bapi); sort_accounts_by_name($accounts); print_agency_login_form($fm_username, $fm_password, $fm_sitename, $fm_siteid, $fm_sessionid, $accounts); } else { $login_info = bronto_user_login($fm_username, $fm_password, $fm_sitename, $fm_siteid); process_login($login_info, $fm_username, $fm_password, $fm_sitename); } } } else { if ($fm_stage == "userinfo") { $dbh = open_db(); // we could obtain the username from the userinfo form itself, but this could allow a malicious user to // change the user information for a user other than him/herself; a DB lookup is used instead $username = db_get_session_user($dbh, $fm_sessionid); if ($username) { $got_error = false;