iTx Technologies offre gratuitement
cet espace pour SugarCRM !

title

Body

[fermer]

/install/ -> populateSeedData.php (source)

   1  <?php
   2  if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
   3  /*********************************************************************************
   4   * SugarCRM is a customer relationship management program developed by
   5   * SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
   6   * 
   7   * This program is free software; you can redistribute it and/or modify it under
   8   * the terms of the GNU General Public License version 3 as published by the
   9   * Free Software Foundation with the addition of the following permission added
  10   * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
  11   * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
  12   * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
  13   * 
  14   * This program is distributed in the hope that it will be useful, but WITHOUT
  15   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  17   * details.
  18   * 
  19   * You should have received a copy of the GNU General Public License along with
  20   * this program; if not, see http://www.gnu.org/licenses or write to the Free
  21   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  22   * 02110-1301 USA.
  23   * 
  24   * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
  25   * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
  26   * 
  27   * The interactive user interfaces in modified source and object code versions
  28   * of this program must display Appropriate Legal Notices, as required under
  29   * Section 5 of the GNU General Public License version 3.
  30   * 
  31   * In accordance with Section 7(b) of the GNU General Public License version 3,
  32   * these Appropriate Legal Notices must retain the display of the "Powered by
  33   * SugarCRM" logo. If the display of the logo is not reasonably feasible for
  34   * technical reasons, the Appropriate Legal Notices must display the words
  35   * "Powered by SugarCRM".
  36   ********************************************************************************/
  37  
  38  
  39  
  40  
  41  
  42  
  43  require_once ('include/language/en_us.lang.php');
  44  
  45  require_once ('install/UserDemoData.php');
  46  require_once ('install/TeamDemoData.php');
  47  require_once ('install/seed_data/basicSeedData.php');
  48  if(isset($sugar_config['i18n_test']) && $sugar_config['i18n_test'] == true)
  49      require_once ('modules/Contacts/contactSeedData_jp.php');
  50  else
  51      require_once ('modules/Contacts/contactSeedData.php');
  52  
  53  
  54  
  55  
  56  
  57  
  58  
  59  
  60      if(file_exists("install/demoData.$_SESSION[demoData].php")){
  61         require_once("install/demoData.$_SESSION[demoData].php");
  62      }else{
  63         require_once ("install/demoData.en_us.php");
  64      }
  65  
  66  
  67  
  68  $last_name_count = count($sugar_demodata['last_name_array']);
  69  $first_name_count = count($sugar_demodata['first_name_array']);
  70  $company_name_count = count($sugar_demodata['company_name_array']);
  71  $street_address_count = count($sugar_demodata['street_address_array']);
  72  $city_array_count = count($sugar_demodata['city_array']);
  73  
  74  
  75  
  76  
  77  global $app_list_strings;
  78  global $sugar_config;
  79  $_REQUEST['useEmailWidget'] = "true";
  80  if(empty($app_list_strings)) {
  81      $app_list_strings = return_app_list_strings_language('en_us');
  82  }
  83  /*
  84   * Seed the random number generator with a fixed constant.  This will make all installs of the same code have the same
  85   * seed data.  This facilitates cross database testing..
  86   */
  87  mt_srand(93285903);
  88  $db = DBManagerFactory::getInstance();
  89  $timedate = new TimeDate();
  90  // Set the max time to ~10 minutes (helps Windows load the seed data)
  91  ini_set("max_execution_time", "601");
  92  // ensure we have enough memory
  93  $memory_needed  = 108;
  94  $memory_limit   = ini_get('memory_limit');
  95  if( $memory_limit != "" && $memory_limit != "-1" ){ // if memory_limit is set
  96      rtrim($memory_limit, 'M');
  97      $memory_limit_int = (int) $memory_limit;
  98      if( $memory_limit_int < $memory_needed ){
  99          ini_set("memory_limit", "$memory_needed" . "M");
 100      }
 101  }
 102  $large_scale_test = empty($sugar_config['large_scale_test']) ?
 103      false : $sugar_config['large_scale_test'];
 104  
 105  $seed_user = new User();
 106  $user_demo_data = new UserDemoData($seed_user, $large_scale_test);
 107  $user_demo_data->create_demo_data();
 108  $number_contacts = 200;
 109  $number_companies = 50;
 110  $number_leads = 200;
 111  $large_scale_test = empty($sugar_config['large_scale_test']) ? false : $sugar_config['large_scale_test'];
 112  // If large scale test is set to true, increase the seed data.
 113  if($large_scale_test) {
 114      // increase the cuttoff time to 1 hour
 115      ini_set("max_execution_time", "3600");
 116      $number_contacts = 100000;
 117      $number_companies = 15000;
 118      $number_leads = 100000;
 119  }
 120  
 121  
 122  
 123  
 124  
 125  
 126  
 127  $possible_duration_hours_arr = array( 0, 1, 2, 3);
 128  $possible_duration_minutes_arr = array('00' => '00','15' => '15', '30' => '30', '45' => '45');
 129  $account_ids = Array();
 130  $accounts = Array();
 131  $opportunity_ids = Array();
 132  
 133  // Determine the assigned user for all demo data.  This is the default user if set, or admin
 134  $assigned_user_name = "admin";
 135  if(!empty($sugar_config['default_user_name']) &&
 136      !empty($sugar_config['create_default_user']) &&
 137      $sugar_config['create_default_user'])
 138  {
 139      $assigned_user_name = $sugar_config['default_user_name'];
 140  }
 141  
 142  // Look up the user id for the assigned user
 143  $seed_user = new User();
 144  $assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
 145  $patterns[] = '/ /';
 146  $patterns[] = '/\./';
 147  $patterns[] = '/&/';
 148  $patterns[] = '/\//';
 149  $replacements[] = '';
 150  $replacements[] = '';
 151  $replacements[] = '';
 152  $replacements[] = '';
 153  
 154  ///////////////////////////////////////////////////////////////////////////////
 155  ////    ACCOUNTS
 156  
 157  for($i = 0; $i < $number_companies; $i++) {
 158      $account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)].' '.mt_rand(1,1000000);
 159      // Create new accounts.
 160      $account = new Account();
 161      $account->name = $account_name;
 162      $account->phone_office = create_phone_number();
 163      $account->assigned_user_id = $assigned_user_id;
 164      $account->emailAddress->addAddress(createEmailAddress(), true);
 165      $account->emailAddress->addAddress(createEmailAddress());
 166      $account->website = createWebAddress();
 167      $account->billing_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_count-1)];
 168      $account->billing_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_count-1)];
 169      if($i % 3 == 1)    {
 170          $account->billing_address_state = "NY";
 171          $assigned_user_id = mt_rand(9,10);
 172          if($assigned_user_id == 9) {
 173              $account->assigned_user_name = "seed_will";
 174              $account->assigned_user_id = $account->assigned_user_name."_id";
 175          } else {
 176              $account->assigned_user_name = "seed_chris";
 177              $account->assigned_user_id = $account->assigned_user_name."_id";
 178          }
 179  
 180          $account->assigned_user_id = $account->assigned_user_name."_id";
 181      } else {
 182          $account->billing_address_state = "CA";
 183          $assigned_user_id = mt_rand(6,8);
 184          if($assigned_user_id == 6) {
 185              $account->assigned_user_name = "seed_sarah";
 186          } elseif($assigned_user_id == 7) {
 187              $account->assigned_user_name = "seed_sally";
 188          } else {
 189              $account->assigned_user_name = "seed_max";
 190          }
 191  
 192          $account->assigned_user_id = $account->assigned_user_name."_id";
 193      }
 194  
 195  
 196  
 197  
 198  
 199  
 200  
 201  
 202  
 203  
 204  
 205  
 206  
 207  
 208  
 209  
 210  
 211  
 212  
 213  
 214  
 215  
 216  
 217  
 218  
 219  
 220      $account->billing_address_postalcode = mt_rand(10000, 99999);
 221      $account->billing_address_country = 'USA';
 222      $account->shipping_address_street = $account->billing_address_street;
 223      $account->shipping_address_city = $account->billing_address_city;
 224      $account->shipping_address_state = $account->billing_address_state;
 225      $account->shipping_address_postalcode = $account->billing_address_postalcode;
 226      $account->shipping_address_country = $account->billing_address_country;
 227      $account->industry = array_rand($app_list_strings['industry_dom']);
 228      $account->account_type = "Customer";
 229      $account->save();
 230      $account_ids[] = $account->id;
 231      $accounts[] = $account;
 232  
 233      // Create a case for the account
 234      $case = new aCase();
 235      $case->account_id = $account->id;
 236      $case->priority = array_rand($app_list_strings['case_priority_dom']);
 237      $case->status = array_rand($app_list_strings['case_status_dom']);
 238      $case->name = $sugar_demodata['case_seed_names'][mt_rand(0,4)];
 239      $case->assigned_user_id = $account->assigned_user_id;
 240      $case->assigned_user_name = $account->assigned_user_name;
 241  
 242  
 243  
 244  
 245      $case->save();
 246  
 247      $note = new Note();
 248      $note->parent_type = 'Accounts';
 249      $note->parent_id = $account->id;
 250      $seed_data_index = mt_rand(0,3);
 251      $note->name = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][0];
 252      $note->description = $sugar_demodata['note_seed_names_and_Descriptions'][$seed_data_index][1];
 253      $note->assigned_user_id = $account->assigned_user_id;
 254      $note->assigned_user_name = $account->assigned_user_name;
 255  
 256  
 257  
 258  
 259      $note->save();
 260  
 261      $call = new Call();
 262      $call->parent_type = 'Accounts';
 263      $call->parent_id = $account->id;
 264      $call->name = $sugar_demodata['call_seed_data_names'][mt_rand(0,3)];
 265      $call->assigned_user_id = $account->assigned_user_id;
 266      $call->assigned_user_name = $account->assigned_user_name;
 267      $call->direction='Outbound';
 268      $call->date_start = create_date(). ' ' . create_time();
 269      $call->duration_hours='0';
 270      $call->duration_minutes='30';
 271      $call->account_id =$account->id;
 272      $call->status='Planned';
 273  
 274  
 275  
 276  
 277      $call->save();
 278  
 279      //Create new opportunities
 280      $opp = new Opportunity();
 281  
 282  
 283  
 284  
 285      $opp->assigned_user_id = $account->assigned_user_id;
 286      $opp->assigned_user_name = $account->assigned_user_name;
 287      $opp->name = substr($account_name." - 1000 units", 0, 50);
 288      $opp->date_closed = create_date();
 289      $opp->lead_source = array_rand($app_list_strings['lead_source_dom']);
 290      $opp->sales_stage = array_rand($app_list_strings['sales_stage_dom']);
 291      // If the deal is already one, make the date closed occur in the past.
 292      if($opp->sales_stage == "Closed Won" || $opp->sales_stage == "Closed Lost")
 293      {
 294          $opp->date_closed = create_past_date();
 295      }
 296      $opp->opportunity_type = array_rand($app_list_strings['opportunity_type_dom']);
 297      $amount = array("10000", "25000", "50000", "75000");
 298      $key = array_rand($amount);
 299      $opp->amount = $amount[$key];
 300      $probability = array("10", "70", "40", "60");
 301      $key = array_rand($probability);
 302      $opp->probability = $probability[$key];
 303      $opp->save();
 304      $opportunity_ids[] = $opp->id;
 305      // Create a linking table entry to assign an account to the opportunity.
 306      $opp->set_relationship('accounts_opportunities', array('opportunity_id'=>$opp->id ,'account_id'=> $account->id), false);
 307  
 308  }
 309  
 310  $titles = $sugar_demodata['titles'];
 311  $account_max = count($account_ids) - 1;
 312  $first_name_max = $first_name_count - 1;
 313  $last_name_max = $last_name_count - 1;
 314  $street_address_max = $street_address_count - 1;
 315  $city_array_max = $city_array_count - 1;
 316  $lead_source_max = count($app_list_strings['lead_source_dom']) - 1;
 317  $lead_status_max = count($app_list_strings['lead_status_dom']) - 1;
 318  $title_max = count($titles) - 1;
 319  ///////////////////////////////////////////////////////////////////////////////
 320  ////    DEMO CONTACTS
 321  for($i=0; $i<$number_contacts; $i++) {
 322      $contact = new Contact();
 323      $contact->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)];
 324      $contact->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)];
 325      $contact->assigned_user_id = $account->assigned_user_id;
 326      $contact->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)];
 327      $contact->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)];
 328      $contact->lead_source = array_rand($app_list_strings['lead_source_dom']);
 329      $contact->title = $titles[mt_rand(0,$title_max)];
 330      $contact->emailAddress->addAddress(createEmailAddress(), true, true);
 331      $contact->emailAddress->addAddress(createEmailAddress(), false, false, false, true);
 332      $assignedUser = new User();
 333      $assignedUser->retrieve($contact->assigned_user_id);
 334  
 335  
 336  
 337  
 338  
 339      $contact->assigned_user_id = $assigned_user_id;
 340      $contact->email1 = createEmailAddress();
 341      $key = array_rand($sugar_demodata['street_address_array']);
 342      $contact->primary_address_street = $sugar_demodata['street_address_array'][$key];
 343      $key = array_rand($sugar_demodata['city_array']);
 344      $contact->primary_address_city = $sugar_demodata['city_array'][$key];
 345      $contact->lead_source = array_rand($app_list_strings['lead_source_dom']);
 346  
 347  
 348  
 349      $contact->phone_work = create_phone_number();
 350      $contact->phone_home = create_phone_number();
 351      $contact->phone_mobile = create_phone_number();
 352      $account_number = mt_rand(0,$account_max);
 353      $account_id = $account_ids[$account_number];
 354      // Fill in a bogus address
 355      $contacts_account = $accounts[$account_number];
 356      $contact->primary_address_state = $contacts_account->billing_address_state;
 357  
 358  
 359  
 360  
 361      $contact->assigned_user_id = $contacts_account->assigned_user_id;
 362      $contact->assigned_user_name = $contacts_account->assigned_user_name;
 363      $contact->primary_address_postalcode = mt_rand(10000,99999);
 364      $contact->primary_address_country = 'USA';
 365      $contact->save();
 366      // Create a linking table entry to assign an account to the contact.
 367      $contact->set_relationship('accounts_contacts', array('contact_id'=>$contact->id ,'account_id'=> $account_id), false);
 368      // This assumes that there will be one opportunity per company in the seed data.
 369      $opportunity_key = array_rand($opportunity_ids);
 370      $contact->set_relationship('opportunities_contacts', array('contact_id'=>$contact->id ,'opportunity_id'=> $opportunity_ids[$opportunity_key], 'contact_role'=>$app_list_strings['opportunity_relationship_type_default_key']), false);
 371  
 372      //Create new tasks
 373      $task = new Task();
 374      $key = array_rand($sugar_demodata['task_seed_data_names']);
 375      $task->name = $sugar_demodata['task_seed_data_names'][$key];
 376      //separate date and time field have been merged into one.
 377      $task->date_due = create_date() . ' ' . create_time();
 378      $task->date_due_flag = 0;
 379  
 380  
 381  
 382  
 383      $task->assigned_user_id = $contacts_account->assigned_user_id;
 384      $task->assigned_user_name = $contacts_account->assigned_user_name;
 385      $task->priority = array_rand($app_list_strings['task_priority_dom']);
 386      $task->status = array_rand($app_list_strings['task_status_dom']);
 387      $task->contact_id = $contact->id;
 388      if ($contact->primary_address_city == "San Mateo") {
 389          $task->parent_id = $account_id;
 390          $task->parent_type = 'Accounts';
 391      }
 392      $task->save();
 393  
 394      //Create new meetings
 395      $meeting = new Meeting();
 396      $key = array_rand($sugar_demodata['meeting_seed_data_names']);
 397      $meeting->name = $sugar_demodata['meeting_seed_data_names'][$key];
 398      $meeting->date_start = create_date(). ' ' . create_time();
 399      //$meeting->time_start = date("H:i",time());
 400      $meeting->duration_hours = array_rand($possible_duration_hours_arr);
 401      $meeting->duration_minutes = array_rand($possible_duration_minutes_arr);
 402      $meeting->assigned_user_id = $assigned_user_id;
 403  
 404  
 405  
 406  
 407      $meeting->assigned_user_id = $contacts_account->assigned_user_id;
 408      $meeting->assigned_user_name = $contacts_account->assigned_user_name;
 409      $meeting->description = $sugar_demodata['meeting_seed_data_descriptions'];
 410      $meeting->status = array_rand($app_list_strings['meeting_status_dom']);
 411      $meeting->contact_id = $contact->id;
 412      $meeting->parent_id = $account_id;
 413      $meeting->parent_type = 'Accounts';
 414      // dont update vcal
 415      $meeting->update_vcal  = false;
 416      $meeting->save();
 417      // leverage the seed user to set the acceptance status on the meeting.
 418      $seed_user->id = $meeting->assigned_user_id;
 419      $meeting->set_accept_status($seed_user,'accept');
 420  
 421      //Create new emails
 422      $email = new Email();
 423      $key = array_rand($sugar_demodata['email_seed_data_subjects']);
 424      $email->name = $sugar_demodata['email_seed_data_subjects'][$key];
 425      $email->date_start = create_date();
 426      $email->time_start = create_time();
 427      $email->duration_hours = array_rand($possible_duration_hours_arr);
 428      $email->duration_minutes = array_rand($possible_duration_minutes_arr);
 429      $email->assigned_user_id = $assigned_user_id;
 430  
 431  
 432  
 433  
 434      $email->assigned_user_id = $contacts_account->assigned_user_id;
 435      $email->assigned_user_name = $contacts_account->assigned_user_name;
 436      $email->description = $sugar_demodata['email_seed_data_descriptions'];
 437      $email->status = 'sent';
 438      $email->parent_id = $account_id;
 439      $email->parent_type = 'Accounts';
 440      $email->to_addrs = $contact->emailAddress->getPrimaryAddress($contact);
 441      $email->from_addr = $assignedUser->emailAddress->getPrimaryAddress($assignedUser);
 442      $email->from_addr_name = $email->from_addr;
 443      $email->to_addrs_names = $email->to_addrs;
 444      $email->type = 'out';
 445      $email->save();
 446      $email->load_relationship('contacts');
 447      $email->contacts->add($contact->id);
 448      $email->load_relationship('accounts');
 449      $email->contacts->add($account_id);
 450  }
 451  
 452  for($i=0; $i<$number_leads; $i++)
 453  {
 454      $lead = new Lead();
 455      $lead->account_name = $sugar_demodata['company_name_array'][mt_rand(0,$company_name_count-1)].' '.mt_rand(1,1000000);
 456      $lead->first_name = $sugar_demodata['first_name_array'][mt_rand(0,$first_name_max)];
 457      $lead->last_name = $sugar_demodata['last_name_array'][mt_rand(0,$last_name_max)];
 458      $lead->primary_address_street = $sugar_demodata['street_address_array'][mt_rand(0,$street_address_max)];
 459      $lead->primary_address_city = $sugar_demodata['city_array'][mt_rand(0,$city_array_max)];
 460      $lead->lead_source = array_rand($app_list_strings['lead_source_dom']);
 461      $lead->title = $sugar_demodata['titles'][mt_rand(0,$title_max)];
 462      $lead->phone_work = create_phone_number();
 463      $lead->phone_home = create_phone_number();
 464      $lead->phone_mobile = create_phone_number();
 465      $lead->emailAddress->addAddress(createEmailAddress(), true);
 466      // Fill in a bogus address
 467      $lead->primary_address_state = $sugar_demodata['primary_address_state'];
 468      $leads_account = $accounts[$account_number];
 469      $lead->primary_address_state = $leads_account->billing_address_state;
 470      $lead->status = array_rand($app_list_strings['lead_status_dom']);
 471      $lead->lead_source = array_rand($app_list_strings['lead_source_dom']);    
 472      if($i % 3 == 1)
 473      {
 474          $lead->billing_address_state = $sugar_demodata['billing_address_state']['east'];
 475              $assigned_user_id = mt_rand(9,10);
 476              if($assigned_user_id == 9)
 477              {
 478                  $lead->assigned_user_name = "seed_will";
 479                  $lead->assigned_user_id = $lead->assigned_user_name."_id";
 480              }
 481              else
 482              {
 483                  $lead->assigned_user_name = "seed_chris";
 484                  $lead->assigned_user_id = $lead->assigned_user_name."_id";
 485              }
 486  
 487              $lead->assigned_user_id = $lead->assigned_user_name."_id";
 488          }
 489          else
 490          {
 491              $lead->billing_address_state = $sugar_demodata['billing_address_state']['west'];
 492              $assigned_user_id = mt_rand(6,8);
 493              if($assigned_user_id == 6)
 494              {
 495                  $lead->assigned_user_name = "seed_sarah";
 496              }
 497              else if($assigned_user_id == 7)
 498              {
 499                  $lead->assigned_user_name = "seed_sally";
 500              }
 501              else
 502              {
 503                  $lead->assigned_user_name = "seed_max";
 504              }
 505  
 506              $lead->assigned_user_id = $lead->assigned_user_name."_id";
 507          }
 508  
 509  
 510      // If this is a large scale test, switch to the bulk teams 90% of the time.
 511      if ($large_scale_test)
 512      {
 513          if(mt_rand(0,100) < 90) {
 514              $assigned_team = $team_demo_data->get_random_team();
 515  
 516  
 517  
 518  
 519              $lead->assigned_user_name = $assigned_team;
 520          } else {
 521  
 522  
 523  
 524  
 525  
 526  
 527          } 
 528      } 
 529  
 530  
 531  
 532  
 533  
 534  
 535  
 536  
 537  
 538  
 539  
 540  
 541  
 542      $lead->primary_address_postalcode = mt_rand(10000,99999);
 543      $lead->primary_address_country = $sugar_demodata['primary_address_country'];
 544      $lead->save();
 545  }
 546  
 547  
 548  
 549  
 550  
 551  
 552  
 553  
 554  
 555  
 556  
 557  
 558  
 559  
 560  
 561  
 562  
 563  
 564  
 565  
 566  
 567  
 568  
 569  
 570  
 571  
 572  
 573  
 574  
 575  
 576  
 577  
 578  
 579  
 580  
 581  
 582  
 583  
 584  
 585  
 586  
 587  
 588  
 589  
 590  
 591  
 592  
 593  
 594  
 595  
 596  
 597  
 598  
 599  
 600  
 601  
 602  
 603  
 604  
 605  
 606  
 607  
 608  
 609  
 610  
 611  
 612  
 613  
 614  
 615  
 616  
 617  
 618  
 619  
 620  
 621  
 622  
 623  
 624  
 625  
 626  
 627  
 628  
 629  
 630  
 631  
 632  
 633  
 634  
 635  
 636  
 637  
 638  
 639  
 640  
 641  
 642  
 643  
 644  
 645  
 646  
 647  
 648  
 649  
 650  
 651  
 652  
 653  
 654  
 655  
 656  
 657  
 658  
 659  
 660  
 661  
 662  
 663  
 664  
 665  
 666  
 667  
 668  
 669  
 670  
 671  
 672  
 673  
 674  
 675  
 676  
 677  
 678  
 679  
 680  
 681  
 682  
 683  
 684  
 685  
 686  
 687  
 688  
 689  
 690  
 691  
 692  
 693  
 694  
 695  
 696  
 697  
 698  
 699  
 700  
 701  
 702  
 703  
 704  
 705  
 706  
 707  
 708  
 709  
 710  
 711  
 712  
 713  
 714  
 715  
 716  
 717  
 718  
 719  
 720  
 721  
 722  
 723  
 724  
 725  
 726  
 727  
 728  
 729  
 730  
 731  
 732  
 733  
 734  
 735  
 736  
 737  
 738  
 739  
 740  
 741  
 742  
 743  
 744  
 745  
 746  
 747  
 748  
 749  
 750  
 751  
 752  
 753  
 754  
 755  
 756  
 757  
 758  
 759  
 760  
 761  
 762  
 763  
 764  
 765  
 766  
 767  
 768  
 769  
 770  
 771  
 772  
 773  
 774  
 775  
 776  
 777  
 778  
 779  
 780  
 781  
 782  
 783  
 784  
 785  
 786  
 787  
 788  
 789  
 790  
 791  
 792  
 793  
 794  
 795  
 796  
 797  
 798  
 799  
 800  
 801  
 802  
 803  
 804  
 805  
 806  
 807  
 808  
 809  
 810  
 811  
 812  
 813  
 814  
 815  
 816  ///
 817  /// SEED DATA FOR PROJECT AND PROJECT TASK
 818  ///
 819  include_once ('modules/Project/Project.php');
 820  include_once ('modules/ProjectTask/ProjectTask.php');
 821  // Project: Audit Plan
 822  $project = new Project();
 823  $project->name = $sugar_demodata['project_seed_data']['audit']['name'];
 824  $project->description = $sugar_demodata['project_seed_data']['audit']['description'];
 825  $project->assigned_user_id = 1;
 826  $project->estimated_start_date = $sugar_demodata['project_seed_data']['audit']['estimated_start_date'];
 827  $project->estimated_end_date = $sugar_demodata['project_seed_data']['audit']['estimated_end_date'];
 828  $project->status = $sugar_demodata['project_seed_data']['audit']['status'];
 829  $project->priority = $sugar_demodata['project_seed_data']['audit']['priority'];
 830  
 831  
 832  
 833  $audit_plan_id = $project->save();
 834  $sugar_demodata['project_seed_data']['audit']['project_tasks'][] = array(
 835      'name' => 'Gather data from meetings',
 836      'date_start' => '2007/11/20',
 837      'date_finish' => '2007/11/20',
 838      'description' => 'Need to organize the data and put it in the right spreadsheet.',
 839      'duration' => '1',
 840      'duration_unit' => 'Days',
 841      'percent_complete' => 0,
 842  );
 843  foreach($sugar_demodata['project_seed_data']['audit']['project_tasks'] as $v){
 844      $project_task = new ProjectTask();
 845      $project_task->assigned_user_id = 1;
 846  
 847  
 848  
 849      $project_task->name = $v['name'];
 850      list($year, $month, $day) = $v['date_start'];
 851      $project_task->date_start = create_date($year, $month, $day);
 852      //$project_task->time_start = create_time(8,0,0);
 853      list($year, $month, $day) = $v['date_start'];
 854      $project_task->date_finish = create_date($year, $month, $day);
 855      //$project_task->time_finish = create_time(8,0,0);
 856      $project_task->project_id = $audit_plan_id;
 857      $project_task->project_task_id = '1';
 858      $project_task->description = $v['description'];
 859      $project_task->duration = $v['duration'];
 860      $project_task->duration_unit = $v['duration_unit'];
 861      $project_task->percent_complete = $v['percent_complete'];
 862      $communicate_stakeholders_id = $project_task->save();    
 863  }
 864  /*
 865  // Project: Move Mountain
 866  
 867  $project = new Project();
 868  $project->name = 'IPO Launch Party';
 869  $project->description = 'Need to organize the IPO party for the upcoming Tuesday.';
 870  $project->assigned_user_id = 1;
 871  
 872  
 873  
 874  $move_mountain_id = $project->save();
 875  
 876  $project_task = new ProjectTask();
 877  $project_task->assigned_user_id = 1;
 878  
 879  
 880  
 881  $project_task->name = 'Book the facility';
 882  $project_task->status = 'Completed';
 883  $project_task->date_due = create_date() . ' '. create_time(8,0,0);
 884  //$project_task->time_due = create_time(8,0,0);
 885  $project_task->date_start = create_past_date() . ' '. create_time(8,0,0);
 886  //$project_task->time_start = create_time(8,0,0);
 887  $project_task->parent_id = $move_mountain_id;
 888  $project_task->priority = 'High';
 889  $project_task->description = "We can either do it at the Promenade or the Galleria.";
 890  $project_task->order_number = 1;
 891  $project_task->task_number = 101;
 892  $project_task->estimated_effort = 40;
 893  $project_task->actual_effort = 36;
 894  $project_task->utilization = 100;
 895  $project_task->percent_complete = 100;
 896  $project_task->save();
 897  
 898  $project_task = new ProjectTask();
 899  $project_task->assigned_user_id = 1;
 900  
 901  
 902  
 903  $project_task->name = 'Get a band';
 904  $project_task->status = 'In Progress';
 905  $project_task->date_due = create_date() . ' '. create_time(8,0,0);
 906  //$project_task->time_due = create_time(8,0,0);
 907  $project_task->date_start = create_past_date() . ' '. create_time(8,0,0);
 908  //$project_task->time_start = create_time(8,0,0);
 909  $project_task->parent_id = $move_mountain_id;
 910  $project_task->priority = 'High';
 911  $project_task->description = "Jim likes something Jazzy.";
 912  $project_task->order_number = 2;
 913  $project_task->task_number = 102;
 914  $project_task->estimated_effort = 40;
 915  $project_task->actual_effort = 20;
 916  $project_task->utilization = 100;
 917  $project_task->percent_complete = 50;
 918  $project_task->save();
 919  
 920  $project_task = new ProjectTask();
 921  $project_task->assigned_user_id = 1;
 922  
 923  
 924  
 925  $project_task->name = 'Get a Caterer';
 926  $project_task->status = 'Not Started';
 927  $project_task->date_due = create_date() . ' '.create_time(8,0,0);
 928  //$project_task->time_due = create_time(8,0,0);
 929  $project_task->date_start = create_past_date(). ' '.create_time(8,0,0);
 930  //$project_task->time_start = create_time(8,0,0);
 931  $project_task->parent_id = $move_mountain_id;
 932  $project_task->priority = 'High';
 933  $project_task->description = "Everyone like French food.";
 934  $project_task->order_number = 3;
 935  $project_task->task_number = 103;
 936  $project_task->estimated_effort = 40;
 937  $project_task->utilization = 100;
 938  $project_task->percent_complete = 0;
 939  $project_task->save();
 940  
 941  // Project: Setup Booth At Tradeshow
 942  /*
 943  $project = new Project();
 944  $project->name = 'Setup Booth At Tradeshow';
 945  $project->description = "The annual Widgets Tradeshow will be held in Springfield this year.  We are going to design a booth so good, it will knock the socks off of our competition.  No more fish heads thrown at us this year!";
 946  $project->assigned_user_id = 1;
 947  
 948  
 949  
 950  $tradeshow_id = $project->save();
 951  
 952  $project_task = new ProjectTask();
 953  $project_task->assigned_user_id = 1;
 954  
 955  
 956  
 957  $project_task->name = 'Build the marketing message theme';
 958  $project_task->status = 'Completed';
 959  $project_task->date_due = create_date() . ' '. create_time(8,0,0);
 960  //$project_task->time_due = create_time(8,0,0);
 961  $project_task->date_start = create_past_date() . ' '. create_time(8,0,0);
 962  ///$project_task->time_start = create_time(8,0,0);
 963  $project_task->parent_id = $tradeshow_id;
 964  $project_task->priority = 'High';
 965  $project_task->description = "Thinking along the lines of a post-apocalyptic world in which the human race is gone.  Where the robots have taken over the world.  Gray color palette, blinking LED lights.";
 966  $project_task->order_number = 1;
 967  $project_task->task_number = 111;
 968  $project_task->estimated_effort = 32;
 969  $project_task->actual_effort = 40;
 970  $project_task->utilization = 100;
 971  $project_task->percent_complete = 100;
 972  $project_task_id = $project_task->save();
 973  
 974  $project_task = new ProjectTask();
 975  $project_task->assigned_user_id = 1;
 976  
 977  
 978  
 979  $project_task->name = 'Order tradeshow booth';
 980  $project_task->status = 'Completed';
 981  $project_task->date_due = create_date() . ' ' .create_time(8,0,0);
 982  //$project_task->time_due = create_time(8,0,0);
 983  $project_task->date_start = create_past_date() . ' ' . create_time(8,0,0);
 984  //$project_task->time_start = create_time(8,0,0);
 985  $project_task->parent_id = $tradeshow_id;
 986  $project_task->priority = 'High';
 987  $project_task->description = "";
 988  $project_task->order_number = 2;
 989  $project_task->task_number = 109;
 990  $project_task->depends_on_id = $project_task_id;
 991  $project_task->estimated_effort = 80;
 992  $project_task->actual_effort = 70;
 993  $project_task->utilization = 100;
 994  $project_task->percent_complete = 100;
 995  $project_task_id = $project_task->save();
 996  
 997  $project_task = new ProjectTask();
 998  $project_task->assigned_user_id = 1;
 999  
1000  
1001  
1002  $project_task->name = 'Order tradeshow graphics';
1003  $project_task->status = 'Completed';
1004  $project_task->date_due = create_date() . ' ' . create_time(8,0,0);
1005  //$project_task->time_due = create_time(8,0,0);
1006  $project_task->date_start = create_past_date() . ' '.create_time(8,0,0);
1007  //$project_task->time_start = create_time(8,0,0);
1008  $project_task->parent_id = $tradeshow_id;
1009  $project_task->priority = 'High';
1010  $project_task->description = "We need a big poster of a fallen Statue of Liberty--a la Planet of the Apes.  And flying cars--we need flying cars.";
1011  $project_task->order_number = 3;
1012  $project_task->task_number = 110;
1013  $project_task->depends_on_id = $project_task_id;
1014  $project_task->estimated_effort = 40;
1015  $project_task->actual_effort = 50;
1016  $project_task->utilization = 100;
1017  $project_task->percent_complete = 100;
1018  $project_task_id = $project_task->save();
1019  
1020  $project_task = new ProjectTask();
1021  $project_task->assigned_user_id = 1;
1022  
1023  
1024  
1025  $project_task->name = 'Confirm booth number with the tradeshow';
1026  $project_task->status = 'Completed';
1027  $project_task->date_due = create_date() . ' ' . create_time(17,0,0);
1028  //$project_task->time_due = create_time(17,0,0);
1029  $project_task->date_start = create_past_date() . ' '. create_time(10,0,0);
1030  //$project_task->time_start = create_time(10,0,0);
1031  $project_task->parent_id = $tradeshow_id;
1032  $project_task->priority = 'High';
1033  $project_task->description = "Make sure we get a good booth location near the center of the show floor.";
1034  $project_task->order_number = 4;
1035  $project_task->task_number = 112;
1036  $project_task->depends_on_id = $project_task_id;
1037  $project_task->estimated_effort = 4;
1038  $project_task->actual_effort = 2;
1039  $project_task->utilization = 50;
1040  $project_task->percent_complete = 100;
1041  $confirm_booth_id = $project_task->save();
1042  
1043  $project_task = new ProjectTask();
1044  $project_task->assigned_user_id = 1;
1045  
1046  
1047  
1048  $project_task->name = 'Organize union help';
1049  $project_task->status = 'Completed';
1050  $project_task->date_due = create_date() . ' ' . create_time(10,0,0);
1051  //$project_task->time_due = create_time(10,0,0);
1052  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1053  //$project_task->time_start = create_time(10,0,0);
1054  $project_task->parent_id = $tradeshow_id;
1055  $project_task->priority = 'Medium';
1056  $project_task->description = "";
1057  $project_task->order_number = 5;
1058  $project_task->task_number = 108;
1059  $project_task->depends_on_id = $confirm_booth_id;
1060  $project_task->estimated_effort = 24;
1061  $project_task->actual_effort = 10;
1062  $project_task->utilization = 100;
1063  $project_task->percent_complete = 100;
1064  $project_task_id = $project_task->save();
1065  
1066  $project_task = new ProjectTask();
1067  $project_task->assigned_user_id = 1;
1068  
1069  
1070  
1071  $project_task->name = 'Order drayage';
1072  $project_task->status = 'Completed';
1073  $project_task->date_due = create_date() . ' ' . create_time(17,0,0);
1074  //$project_task->time_due = create_time(17,0,0);
1075  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1076  //$project_task->time_start = create_time(10,0,0);
1077  $project_task->parent_id = $tradeshow_id;
1078  $project_task->priority = 'High';
1079  $project_task->description = "";
1080  $project_task->order_number = 6;
1081  $project_task->task_number = 107;
1082  $project_task->depends_on_id = $project_task_id;
1083  $project_task->estimated_effort = 40;
1084  $project_task->actual_effort = 40;
1085  $project_task->utilization = 100;
1086  $project_task->percent_complete = 100;
1087  $project_task_id = $project_task->save();
1088  
1089  $project_task = new ProjectTask();
1090  $project_task->assigned_user_id = 1;
1091  
1092  
1093  
1094  $project_task->name = 'Order chotskies';
1095  $project_task->status = 'Completed';
1096  $project_task->date_due = create_date() . ' ' .create_time(17,0,0);
1097  //$project_task->time_due = create_time(17,0,0);
1098  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1099  //$project_task->time_start = create_time(10,0,0);
1100  $project_task->parent_id = $tradeshow_id;
1101  $project_task->priority = 'Medium';
1102  $project_task->description = "The edible pencils we gave our last year did well.";
1103  $project_task->order_number = 7;
1104  $project_task->task_number = 105;
1105  $project_task->depends_on_id = $confirm_booth_id;
1106  $project_task->estimated_effort = 16;
1107  $project_task->actual_effort = 40;
1108  $project_task->utilization = 100;
1109  $project_task->percent_complete = 100;
1110  $project_task_id = $project_task->save();
1111  
1112  $project_task = new ProjectTask();
1113  $project_task->assigned_user_id = 1;
1114  
1115  
1116  
1117  $project_task->name = 'Order lead capture device';
1118  $project_task->status = 'Completed';
1119  $project_task->date_due = create_date() . ' ' .create_time(17,0,0);
1120  //$project_task->time_due = create_time(17,0,0);
1121  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1122  //$project_task->time_start = create_time(10,0,0);
1123  $project_task->parent_id = $tradeshow_id;
1124  $project_task->priority = 'Medium';
1125  $project_task->description = "Leads will be piped straight into SugarCRM from a swipe of the admission badge this year.";
1126  $project_task->order_number = 8;
1127  $project_task->task_number = 106;
1128  $project_task->depends_on_id = $confirm_booth_id;
1129  $project_task->estimated_effort = 4;
1130  $project_task->actual_effort = 16;
1131  $project_task->utilization = 100;
1132  $project_task->percent_complete = 100;
1133  $project_task_id = $project_task->save();
1134  
1135  $project_task = new ProjectTask();
1136  $project_task->assigned_user_id = 1;
1137  
1138  
1139  
1140  $project_task->name = 'Assign booth duty';
1141  $project_task->status = 'Completed';
1142  $project_task->date_due = create_date() . ' ' .create_time(17,0,0);
1143  //$project_task->time_due = create_time(17,0,0);
1144  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1145  //$project_task->time_start = create_time(10,0,0);
1146  $project_task->parent_id = $tradeshow_id;
1147  $project_task->priority = 'Medium';
1148  $project_task->description = "No more than 3 hour shifts.  Let the employees have a look around the tradeshow floor.";
1149  $project_task->order_number = 9;
1150  $project_task->task_number = 103;
1151  $project_task->depends_on_id = $confirm_booth_id;
1152  $project_task->estimated_effort = 4;
1153  $project_task->actual_effort = 3;
1154  $project_task->utilization = 100;
1155  $project_task->percent_complete = 100;
1156  $project_task_id = $project_task->save();
1157  
1158  $project_task = new ProjectTask();
1159  $project_task->assigned_user_id = 1;
1160  
1161  
1162  
1163  $project_task->name = 'Remind booth workers to wear their uniforms';
1164  $project_task->status = 'Not Started';
1165  $project_task->date_due = create_date() . ' ' . create_time(17,0,0);
1166  //$project_task->time_due = create_time(17,0,0);
1167  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1168  //$project_task->time_start = create_time(10,0,0);
1169  $project_task->parent_id = $tradeshow_id;
1170  $project_task->priority = 'Low';
1171  $project_task->description = "Be sure to suggest to dress up as a famous suppressive robot (e.g. HAL2000).";
1172  $project_task->order_number = 10;
1173  $project_task->task_number = 104;
1174  $project_task->depends_on_id = $project_task_id;
1175  $project_task->estimated_effort = 1;
1176  $project_task->utilization = 100;
1177  $project_task->percent_complete = 0;
1178  $project_task_id = $project_task->save();
1179  
1180  $project_task = new ProjectTask();
1181  $project_task->assigned_user_id = 1;
1182  
1183  
1184  
1185  $project_task->name = 'Build press kits';
1186  $project_task->status = 'In Progress';
1187  $project_task->date_due = create_date() . ' ' . create_time(17,0,0);
1188  //$project_task->time_due = create_time(17,0,0);
1189  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1190  //$project_task->time_start = create_time(10,0,0);
1191  $project_task->parent_id = $tradeshow_id;
1192  $project_task->priority = 'High';
1193  $project_task->description = "";
1194  $project_task->order_number = 11;
1195  $project_task->task_number = 101;
1196  $project_task->depends_on_id = $confirm_booth_id;
1197  $project_task->estimated_effort = 16;
1198  $project_task->actual_effort = 3;
1199  $project_task->utilization = 100;
1200  $project_task->percent_complete = 25;
1201  $project_task_id = $project_task->save();
1202  
1203  $project_task = new ProjectTask();
1204  $project_task->assigned_user_id = 1;
1205  
1206  
1207  
1208  $project_task->name = 'Arrange partner meetings';
1209  $project_task->status = 'In Progress';
1210  $project_task->date_due = create_date() . ' ' . create_time(17,0,0);
1211  //$project_task->time_due = create_time(17,0,0);
1212  $project_task->date_start = create_past_date() . ' ' . create_time(10,0,0);
1213  //$project_task->time_start = create_time(10,0,0);
1214  $project_task->parent_id = $tradeshow_id;
1215  $project_task->priority = 'Medium';
1216  $project_task->description = "Get the usual bunch.";
1217  $project_task->order_number = 12;
1218  $project_task->task_number = 102;
1219  $project_task->depends_on_id = $project_task_id;
1220  $project_task->estimated_effort = 40;
1221  $project_task->actual_effort = 10;
1222  $project_task->utilization = 100;
1223  $project_task->percent_complete = 25;
1224  $project_task_id = $project_task->save();
1225  */
1226  
1227  
1228  
1229  
1230  
1231  
1232  
1233  
1234  
1235  
1236  
1237  
1238  ?>


Generé en: Thu Mar 4 09:44:50 2010 | Cross-referenced par PHPXref 0.7