X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=sql%2FGenerateReportData.php;h=2f0d19394742a54745758718466380f412dec412;hb=3840dee98c3e3d05127efe8277f31a036b6ccf67;hp=730de38167d549b12b5c175db949ee0befe29774;hpb=c219b4c822b7539da67f5eb9fdcde48b562720ed;p=civicrm-core.git diff --git a/sql/GenerateReportData.php b/sql/GenerateReportData.php index 730de38167..2f0d193947 100644 --- a/sql/GenerateReportData.php +++ b/sql/GenerateReportData.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.7 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2015 | + | Copyright CiviCRM LLC (c) 2004-2016 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -23,12 +23,12 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2015 + * @copyright CiviCRM LLC (c) 2004-2016 * $Id$ * */ @@ -212,21 +212,21 @@ class CRM_GCD { private $numStrictIndividual = 0; private $CSC = array( - // united states + // united states 1228 => array( // california 1004 => array('San Francisco', 'Los Angeles', 'Palo Alto'), // new york 1031 => array('New York', 'Albany'), ), - // india + // india 1101 => array( // maharashtra 1113 => array('Mumbai', 'Pune', 'Nasik'), // karnataka 1114 => array('Bangalore', 'Mangalore', 'Udipi'), ), - // poland + // poland 1172 => array( // mazowieckie 1115 => array('Warszawa', 'Płock'), @@ -245,7 +245,11 @@ class CRM_GCD { * @return string */ - // get a randomly generated string + /** + * Get a randomly generated string. + * + * @param int $size + */ private function _getRandomString($size = 32) { $string = ""; @@ -348,7 +352,7 @@ class CRM_GCD { // number of seconds for 2 year $numSecond = 63072000; - $dateFormat = "Ymdhis"; + $dateFormat = "YmdHis"; $today = time(); // both are defined @@ -406,11 +410,9 @@ class CRM_GCD { * Helper function which randomly populates "note" and * "date_modified" and inserts it. * - * @param CRM_DAO_Note DAO object for Note + * @param $note * @access private * - * @return none - * */ private function _insertNote($note) { $note->note = $this->_getRandomElement($this->note); @@ -418,14 +420,12 @@ class CRM_GCD { $this->_insert($note); } - /******************************************************* + /** * * Start of public functions * - *******************************************************/ - // constructor - function __construct() { - + */ + public function __construct() { // initialize all the vars $this->numIndividual = self::INDIVIDUAL_PERCENT * self::NUM_CONTACT / 100; $this->numHousehold = self::HOUSEHOLD_PERCENT * self::NUM_CONTACT / 100; @@ -512,7 +512,6 @@ class CRM_GCD { $this->activity_type[] = trim($activity_type); } - // module foreach ($sampleData->modules->module as $module) { $this->module[] = trim($module); @@ -577,7 +576,7 @@ class CRM_GCD { $config = CRM_Core_Config::singleton(); } - /******************************************************* + /** * * this function creates arrays for the following * @@ -592,7 +591,7 @@ class CRM_GCD { * contact_task uuid * contact_note uuid * - *******************************************************/ + */ public function initID() { // may use this function in future if needed to get @@ -621,14 +620,14 @@ class CRM_GCD { $this->householdIndividual = array_combine($this->household, $this->householdIndividual); } - /******************************************************* + /** * * addDomain() * * This method adds NUM_DOMAIN domains and then adds NUM_REVISION * revisions for each domain with the latest revision being the last one.. * - *******************************************************/ + */ public function addDomain() { /* Add a location for domain 1 */ @@ -663,7 +662,7 @@ class CRM_GCD { return $this->prefix[$prefix] . " $first_name $middle_name $last_name " . $this->suffix[$suffix]; } - /******************************************************* + /** * * addContact() * @@ -673,7 +672,7 @@ class CRM_GCD { * contact_type 'Individual' 'Household' 'Organization' * preferred_communication (random 1 to 3) * - *******************************************************/ + */ public function addContact() { // add contacts @@ -690,7 +689,7 @@ class CRM_GCD { } } - /******************************************************* + /** * * addIndividual() * @@ -707,7 +706,7 @@ class CRM_GCD { * greeting_type - randomly select from the enum values * custom_greeting - "custom greeting $contact_uuid' * - *******************************************************/ + */ public function addIndividual() { $contact = new CRM_Contact_DAO_Contact(); @@ -733,7 +732,7 @@ class CRM_GCD { } } - /******************************************************* + /** * * addHousehold() * @@ -747,7 +746,7 @@ class CRM_GCD { * nick_name 'nick $contact_uuid' * primary_contact_uuid = $household_individual[$contact_uuid][0]; * - *******************************************************/ + */ public function addHousehold() { $contact = new CRM_Contact_DAO_Contact(); @@ -774,7 +773,7 @@ class CRM_GCD { } } - /******************************************************* + /** * * addOrganization() * @@ -790,7 +789,7 @@ class CRM_GCD { * sic_code 'sic $contact_uuid' * primary_contact_id - random individual contact uuid * - *******************************************************/ + */ public function addOrganization() { $contact = new CRM_Contact_DAO_Contact(); @@ -808,7 +807,7 @@ class CRM_GCD { } } - /******************************************************* + /** * * addRelationship() * @@ -816,7 +815,7 @@ class CRM_GCD { * * it adds the following fields * - *******************************************************/ + */ public function addRelationship() { $relationship = new CRM_Contact_DAO_Relationship(); @@ -870,13 +869,13 @@ class CRM_GCD { } } - /******************************************************* + /** * * addLocation() * * This method adds data to the location table * - *******************************************************/ + */ public function addLocation() { // strict individuals foreach ($this->strictIndividual as $contactId) { @@ -895,7 +894,7 @@ class CRM_GCD { // some individuals. $someIndividual = array_diff($this->individual, $this->strictIndividual); - $someIndividual = array_slice($someIndividual, 0, (int)(75 * ($this->numIndividual - $this->numStrictIndividual) / 100)); + $someIndividual = array_slice($someIndividual, 0, (int) (75 * ($this->numIndividual - $this->numStrictIndividual) / 100)); foreach ($someIndividual as $contactId) { $this->_addLocation(self::HOME, $contactId, FALSE, TRUE); } @@ -1016,13 +1015,13 @@ class CRM_GCD { } } - /******************************************************* + /** * * addTagEntity() * * This method populates the crm_entity_tag table * - *******************************************************/ + */ public function addEntityTag() { $entity_tag = new CRM_Core_DAO_EntityTag(); @@ -1053,13 +1052,13 @@ class CRM_GCD { } } - /******************************************************* + /** * * addGroup() * * This method populates the crm_entity_tag table * - *******************************************************/ + */ public function addGroup() { // add the 3 groups first $numGroup = count($this->group); @@ -1085,7 +1084,6 @@ class CRM_GCD { // membership status $groupContact->status = $this->_getRandomElement($this->groupMembershipStatus); - $subscriptionHistory = new CRM_Contact_DAO_SubscriptionHistory(); $subscriptionHistory->contact_id = $groupContact->contact_id; @@ -1153,13 +1151,13 @@ class CRM_GCD { CRM_Core_BAO_Cache::deleteGroup('contact fields'); } - /******************************************************* + /** * * addNote() * * This method populates the crm_note table * - *******************************************************/ + */ public function addNote() { $note = new CRM_Core_DAO_Note(); @@ -1174,13 +1172,13 @@ class CRM_GCD { } } - /******************************************************* + /** * * addActivity() * * This method populates the crm_activity_history table * - *******************************************************/ + */ public function addActivity() { $contactDAO = new CRM_Contact_DAO_Contact(); $contactDAO->contact_type = 'Individual'; @@ -1237,7 +1235,7 @@ class CRM_GCD { /** * @return array */ - static function getZipCodeInfo() { + public static function getZipCodeInfo() { $stateID = mt_rand(1000, 5132); $offset = mt_rand(1, 4132); @@ -1256,7 +1254,7 @@ class CRM_GCD { * * @return array */ - static function getLatLong($zipCode) { + public static function getLatLong($zipCode) { $query = "http://maps.google.com/maps?q=$zipCode&output=js"; $userAgent = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0"; @@ -1284,7 +1282,7 @@ class CRM_GCD { return array(NULL, NULL); } - function addMembershipType() { + public function addMembershipType() { $organizationDAO = new CRM_Contact_DAO_Contact(); $organizationDAO->id = 5; $organizationDAO->find(TRUE); @@ -1300,7 +1298,7 @@ class CRM_GCD { CRM_Core_DAO::executeQuery($membershipType, CRM_Core_DAO::$_nullArray); } - function addMembership() { + public function addMembership() { $contact = new CRM_Contact_DAO_Contact(); $contact->query("SELECT id FROM civicrm_contact where contact_type = 'Individual'"); while ($contact->fetch()) { @@ -1384,12 +1382,12 @@ VALUES * * @return string */ - static function repairDate($date) { + public static function repairDate($date) { $dropArray = array('-' => '', ':' => '', ' ' => ''); return strtr($date, $dropArray); } - function addMembershipLog() { + public function addMembershipLog() { $membership = new CRM_Member_DAO_Membership(); $membership->query("SELECT id FROM civicrm_membership"); while ($membership->fetch()) { @@ -1413,7 +1411,7 @@ VALUES } } - function createEvent() { + public function createEvent() { $event = "INSERT INTO civicrm_address ( contact_id, location_type_id, is_primary, is_billing, street_address, street_number, street_number_suffix, street_number_predirectional, street_name, street_type, street_number_postdirectional, street_unit, supplemental_address_1, supplemental_address_2, supplemental_address_3, city, county_id, state_province_id, postal_code_suffix, postal_code, usps_adc, country_id, geo_code_1, geo_code_2, timezone) VALUES ( NULL, 1, 1, 1, 'S 14S El Camino Way E', 14, 'S', NULL, 'El Camino', 'Way', NULL, NULL, NULL, NULL, NULL, 'Collinsville', NULL, 1006, NULL, '6022', NULL, 1228, 41.8328, -72.9253, NULL), @@ -1484,7 +1482,6 @@ VALUES "; CRM_Core_DAO::executeQuery($optionGroup, CRM_Core_DAO::$_nullArray); - $sql = "SELECT max(id) from civicrm_option_group where name = 'civicrm_event.amount.1'"; $page1 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray); @@ -1494,7 +1491,6 @@ VALUES $sql = "SELECT max(id) from civicrm_option_group where name = 'civicrm_event.amount.3'"; $page3 = CRM_Core_DAO::singleValueQuery($sql, CRM_Core_DAO::$_nullArray); - $optionValue = "INSERT INTO civicrm_option_value (option_group_id, label, value, is_default, weight, is_optgroup, is_reserved, is_active) VALUES ($page1, 'Single', '50', 0, 1, 0, 0, 1), @@ -1528,7 +1524,7 @@ VALUES CRM_Core_DAO::executeQuery($event, CRM_Core_DAO::$_nullArray); } - function addParticipant() { + public function addParticipant() { // add participant $participant = new CRM_Event_DAO_Participant(); @@ -1560,23 +1556,23 @@ VALUES } } - function addPCP() { + public function addPCP() { $query = " INSERT INTO `civicrm_pcp` (contact_id, status_id, title, intro_text, page_text, donate_link_text, contribution_page_id, is_thermometer, is_honor_roll, goal_amount, referer, is_active) VALUES ({$this->individual[3]}, 2, 'My Personal Civi Fundraiser', 'I''m on a mission to get all my friends and family to help support my favorite open-source civic sector CRM.', '

Friends and family - please help build much needed infrastructure for the civic sector by supporting my personal campaign!

\r\n

You can learn more about CiviCRM here.

\r\n

Then click the Contribute Now button to go to our easy-to-use online contribution form.

', 'Contribute Now', 1, 1, 1, 5000.00, NULL, 1); "; - CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray); + CRM_Core_DAO::executeQuery($query); } - function addContribution() { + public function addContribution() { // add contributions $contribution = new CRM_Contribute_DAO_Contribution(); for ($id = 1; $id <= self::NUM_CONTRIBUTION; $id++) { $contribution->contact_id = mt_rand(1, self::NUM_CONTACT); - $contribution->financial_type_id = mt_rand(1, 4); + $contribution->financial_type_id = mt_rand(1, 4); $contribution->contribution_page_id = mt_rand(1, 3); $contribution->payment_instrument_id = mt_rand(1, 5); $contribution->receive_date = $this->_getRandomDate(); @@ -1587,7 +1583,7 @@ VALUES } } - function addSoftContribution() { + public function addSoftContribution() { $pcpRollNickNAme = array('Jones Family', 'Annie and the kids', 'Anonymous', 'Adam Family'); $pcpPersonalNote = array('Helping Hands', 'Annie Helps', 'Anonymous', 'Adam Helps'); @@ -1615,7 +1611,7 @@ VALUES } } - function addPledge() { + public function addPledge() { $pledge = "INSERT INTO civicrm_pledge (contact_id, financial_type_id, contribution_page_id, amount, frequency_unit, frequency_interval, frequency_day, installments, start_date, create_date, acknowledge_date, modified_date, cancel_date, end_date, honor_contact_id, honor_type_id, status_id, is_test) VALUES @@ -1626,7 +1622,7 @@ VALUES CRM_Core_DAO::executeQuery($pledge, CRM_Core_DAO::$_nullArray); } - function addPledgePayment() { + public function addPledgePayment() { $pledgePayment = "INSERT INTO civicrm_pledge_payment ( pledge_id, contribution_id, scheduled_amount, scheduled_date, reminder_date, reminder_count, status_id) VALUES @@ -1642,13 +1638,13 @@ VALUES CRM_Core_DAO::executeQuery($pledgePayment, CRM_Core_DAO::$_nullArray); } - function addMembershipPayment() { + public function addMembershipPayment() { $amount = array('50', '100', '1200'); $contribution = new CRM_Contribute_DAO_Contribution(); for ($id = 1; $id <= 200; $id++) { $contribution->contact_id = mt_rand(1, self::NUM_CONTACT); - $contribution->financial_type_id = mt_rand(1, 4); + $contribution->financial_type_id = mt_rand(1, 4); $contribution->payment_instrument_id = mt_rand(1, 5); $contribution->receive_date = $this->_getRandomDate(); $contribution->total_amount = $this->_getRandomElement($amount); @@ -1688,6 +1684,7 @@ VALUES } } } + } /** @@ -1734,4 +1731,3 @@ $obj1->addPledge(); $obj1->addPledgePayment(); $obj1->addMembershipPayment(); echo ("Ending data generation on " . date("F dS h:i:s A") . "\n"); -