[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/install/ -> populateSeedData.php (source)

   1  <?php
   2  /*********************************************************************************
   3   * The contents of this file are subject to the SugarCRM Public License Version 1.1.2
   4   * ("License"); You may not use this file except in compliance with the 
   5   * License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
   6   * Software distributed under the License is distributed on an  "AS IS"  basis,
   7   * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
   8   * the specific language governing rights and limitations under the License.
   9   * The Original Code is:  SugarCRM Open Source
  10   * The Initial Developer of the Original Code is SugarCRM, Inc.
  11   * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.;
  12   * All Rights Reserved.
  13   * Contributor(s): ______________________________________.
  14   ********************************************************************************/
  15  /*********************************************************************************
  16   * $Header: /advent/projects/wesat/vtiger_crm/sugarcrm/install/populateSeedData.php,v 1.17 2005/03/25 20:13:52 simian Exp $
  17   * Description:  Executes a step in the installation process.
  18   ********************************************************************************/
  19  
  20  require_once ('config.php');
  21  
  22  require_once ('modules/Leads/Leads.php');
  23  require_once ('modules/Contacts/contactSeedData.php');
  24  require_once ('modules/Contacts/Contacts.php');
  25  require_once ('modules/Accounts/Accounts.php');
  26  require_once ('modules/Campaigns/Campaigns.php');
  27  require_once ('modules/Potentials/Potentials.php');
  28  require_once ('modules/Calendar/Activity.php');
  29  require_once ('include/database/PearDatabase.php');
  30  require_once ('include/utils/utils.php');
  31  require_once ('include/language/en_us.lang.php');
  32  require_once ('include/ComboStrings.php');
  33  require_once ('include/ComboUtil.php');
  34  require_once ('modules/Products/Products.php');
  35  require_once ('modules/PriceBooks/PriceBooks.php');
  36  require_once ('modules/Vendors/Vendors.php');
  37  require_once ('modules/Faq/Faq.php');
  38  require_once ('modules/HelpDesk/HelpDesk.php');
  39  require_once ('modules/Notes/Notes.php');
  40  require_once ('modules/Quotes/Quotes.php');
  41  require_once ('modules/SalesOrder/SalesOrder.php');
  42  require_once ('modules/PurchaseOrder/PurchaseOrder.php');
  43  require_once ('modules/Invoice/Invoice.php');
  44  require_once ('modules/Emails/Emails.php');
  45  require_once ('include/utils/InventoryUtils.php'); //Included to save inventory related products in demo data
  46  
  47  global $first_name_array;
  48  global $first_name_count;
  49  global $last_name_array;
  50  global $last_name_count;
  51  global $company_name_array;
  52  global $company_name_count;
  53  global $street_address_array;
  54  global $street_address_count;
  55  global $city_array;
  56  global $city_array_count;
  57  global $campaign_name_array,$campaign_type_array,$campaign_status_array;
  58  global $adb;
  59   $db = new PearDatabase();
  60  
  61  function add_digits($quantity, &$string, $min = 0, $max = 9)
  62  {
  63      for($i=0; $i < $quantity; $i++)
  64      {
  65          $string .= rand($min,$max);
  66      }
  67  }
  68  
  69  function create_phone_number()
  70  {
  71      $phone = "(";
  72  $phone = $phone; // This line is useless, but gets around a code analyzer warning.  Bug submitted 4/28/04
  73      add_digits(3, $phone);
  74      $phone .= ") ";
  75      add_digits(3, $phone);
  76      $phone .= "-";
  77      add_digits(4, $phone);
  78      
  79      return $phone;
  80  }
  81  
  82  function create_date()
  83  {
  84      $date = "";
  85      $date .= "2006";
  86      $date .= "-";
  87      $date .= rand(1,9);
  88      $date .= "-";
  89      $date .= rand(1,28);
  90      
  91      return $date;
  92  }
  93  
  94  //$adb->println("PSD dumping started");
  95  
  96  $account_ids = Array();
  97  $opportunity_ids = Array();
  98  $vendor_ids = Array();
  99  $contact_ids = Array();
 100  $product_ids = Array();
 101  $pricebook_ids = Array();
 102  $quote_ids = Array();
 103  $salesorder_ids = Array();
 104  $purchaseorder_ids = Array();
 105  $invoice_ids = Array();
 106  $email_ids = Array();
 107  
 108  // Determine the assigned user for all demo data.  This is the default user if set, or admin
 109  $assigned_user_name = "admin";
 110  if(isset($default_user_name) && $default_user_name != '' && isset($create_default_user) && $create_default_user)
 111  {
 112      $assigned_user_name = $default_user_name;
 113  }
 114  
 115  // Look up the user id for the assigned user
 116  $seed_user = new Users();
 117  
 118  //$adb->println("PSD assignname=".$assigned_user_name);
 119  
 120  $assigned_user_id = $seed_user->retrieve_user_id($assigned_user_name);
 121  
 122  global $current_user;
 123  
 124  $current_user = new Users();
 125  $result = $current_user->retrieve_entity_info($assigned_user_id,'Users');
 126  
 127  $tagkey = 1;
 128  
 129  // Get _dom arrays
 130  $comboFieldNames = Array('leadsource'=>'leadsource_dom'
 131                ,'leadstatus'=>'lead_status_dom'
 132                ,'industry'=>'industry_dom'
 133                ,'rating'=>'rating_dom'
 134                        ,'opportunity_type'=>'opportunity_type_dom'
 135                        ,'sales_stage'=>'sales_stage_dom');
 136  $comboFieldArray = getComboArray($comboFieldNames);
 137  
 138  //$adb->println("PSD assignid=".$assigned_user_id);
 139  $adb->println("company_name_array");
 140  $adb->println($company_name_array);
 141  
 142  $cloudtag = Array ('SO_vendtl', 'X-CEED', 'X-CEED', 'vtiger_50usr');
 143  
 144  for($i = 0; $i < $company_name_count; $i++)
 145  {
 146      
 147      $account_name = $company_name_array[$i];
 148  
 149      // Create new accounts.
 150      $account = new Accounts();
 151      $account->column_fields["accountname"] = $account_name;
 152      $account->column_fields["phone"] = create_phone_number();
 153      $account->column_fields["assigned_user_id"] = $assigned_user_id;
 154  
 155      $whitespace = array(" ", ".", "&", "\/");
 156      $website = str_replace($whitespace, "", strtolower($account->column_fields["accountname"]));
 157      $account->column_fields["website"] = "www.".$website.".com";
 158      
 159      $account->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
 160      $account->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
 161      $account->column_fields["bill_state"] = "CA";
 162      $account->column_fields["bill_code"] = rand(10000, 99999);
 163      $account->column_fields["bill_country"] = 'USA';    
 164  
 165      $account->column_fields["ship_street"] = $account->column_fields["bill_street"];
 166      $account->column_fields["ship_city"] = $account->column_fields["bill_city"];
 167      $account->column_fields["ship_state"] = $account->column_fields["bill_state"];
 168      $account->column_fields["ship_code"] = $account->column_fields["bill_code"];
 169      $account->column_fields["ship_country"] = $account->column_fields["bill_country"];    
 170  
 171  //      $key = array_rand($app_list_strings['industry_dom']);
 172  //      $account->industry = $app_list_strings['industry_dom'][$key];
 173      $key = array_rand($comboFieldArray['industry_dom']);
 174      $account->column_fields["industry"] = $comboFieldArray['industry_dom'][$key];
 175  
 176      $account->column_fields["account_type"] = "Customer";
 177  
 178      //$account->saveentity("Accounts");
 179      $account->save("Accounts");
 180      
 181      $account_ids[] = $account->id;
 182      
 183      if ($i > 3)
 184      {
 185          $freetag = $adb->getUniqueId('vtiger_freetags');
 186          $query = "insert into vtiger_freetags values ($freetag, '$cloudtag[1]', '$cloudtag[1]')";
 187          $res = $adb->query($query);
 188  
 189          $date = $adb->formatDate(date('YmdHis')); 
 190          $query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$account->id.", $date, 'Accounts')";
 191          $result = $adb->query($query_tag);
 192      }
 193  
 194  
 195  //    $adb->println("PSD Account [".$account->id."] - ".$account_name);
 196  
 197          
 198  //Create new opportunities
 199      $opp = new Potentials();
 200  
 201      $opp->column_fields["assigned_user_id"] = $assigned_user_id;
 202      $opp->column_fields["potentialname"] = $account_name." - 1000 units";
 203      $opp->column_fields["closingdate"] = & create_date();
 204  
 205  //      $key = array_rand($app_list_strings['lead_source_dom']);
 206  //      $opp->lead_source = $app_list_strings['lead_source_dom'][$key];
 207      $key = array_rand($comboFieldArray['leadsource_dom']);
 208      $opp->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
 209  
 210  //      $key = array_rand($app_list_strings['sales_stage_dom']);
 211  //      $opp->sales_stage = $app_list_strings['sales_stage_dom'][$key];
 212      $comboSalesStageArray = Array ("Closed Won");
 213      $key = array_rand($comboSalesStageArray);
 214      $opp->column_fields["sales_stage"] = $comboSalesStageArray[$key];
 215      
 216  //      $key = array_rand($app_list_strings['opportunity_type_dom']);
 217  //      $opp->opportunity_type = $app_list_strings['opportunity_type_dom'][$key];
 218      $key = array_rand($comboFieldArray['opportunity_type_dom']);
 219      $opp->column_fields["opportunity_type"] = $comboFieldArray['opportunity_type_dom'][$key];
 220  
 221      $amount = array("10000", "25000", "50000", "75000"); 
 222      $key = array_rand($amount);
 223      $opp->column_fields["amount"] = $amount[$key];
 224      $opp->column_fields["account_id"] = $account->id;
 225  
 226      //$opp->saveentity("Potentials");
 227      $opp->save("Potentials");
 228      
 229      $opportunity_ids[] = $opp->id;
 230  
 231  //    $adb->println("PSD Potential [".$opp->id."] - account[".$account->id."]");
 232      
 233  }
 234  
 235  
 236  for($i=0; $i<10; $i++)
 237  {
 238      $contact = new Contacts();
 239      $contact->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
 240      $contact->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
 241      $contact->column_fields["assigned_user_id"] = $assigned_user_id;
 242      
 243      $contact->column_fields["email"] = strtolower($contact->column_fields["firstname"])."_".strtolower($contact->column_fields["lastname"])."@company.com";
 244  
 245      $contact->column_fields["phone"] = create_phone_number();
 246      $contact->column_fields["homephone"] = create_phone_number();
 247      $contact->column_fields["mobile"] = create_phone_number();
 248      
 249      // Fill in a bogus address
 250      $key = array_rand($street_address_array);
 251      $contact->column_fields["mailingstreet"] = $street_address_array[$key];
 252      $key = array_rand($city_array);
 253      $contact->column_fields["mailingcity"] = $city_array[$key];
 254      $contact->column_fields["mailingstate"] = "CA";
 255      $contact->column_fields["mailingzip"] = '99999';
 256      $contact->column_fields["mailingcountry"] = 'USA';    
 257      if ($contact->column_fields["mailingcity"] == "San Mateo") 
 258          $contact->column_fields["yahooid"] = "clint_oram";
 259      elseif ($contact->column_fields["mailingcity"] == "San Francisco") 
 260          $contact->column_fields["yahooid"] = "not_a_real_id";
 261  
 262  //      $key = array_rand($app_list_strings['lead_source_dom']);
 263  //      $contact->lead_source = $app_list_strings['lead_source_dom'][$key];
 264      $key = array_rand($comboFieldArray['leadsource_dom']);
 265      $contact->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
 266  
 267      $titles = array("President", 
 268                      "VP Operations", 
 269                      "VP Sales", 
 270                      "Director Operations", 
 271                      "Director Sales", 
 272                      "Mgr Operations", 
 273                      "IT Developer", 
 274                      "");
 275      $key = array_rand($titles);
 276      $contact->column_fields["title"] = $titles[$key];
 277      
 278      $account_key = array_rand($account_ids);
 279      $contact->column_fields["account_id"] = $account_ids[$account_key];
 280  
 281      //$contact->saveentity("Contacts");
 282      $contact->save("Contacts");
 283      $contact_ids[] = $contact->id;
 284  
 285      
 286      if ($i > 8)
 287      {
 288          $freetag = $adb->getUniqueId('vtiger_freetags');
 289          $query = "insert into vtiger_freetags values ($freetag, '$cloudtag[2]', '$cloudtag[2]')";
 290          $res1 = $adb->query($query);
 291  
 292          $date = $adb->formatDate(date('YmdHis')); 
 293          $query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$contact->id.", $date, 'Contacts')";
 294          $result1 = $adb->query($query_tag);
 295      }
 296      // This assumes that there will be one opportunity per company in the seed data.
 297      $opportunity_key = array_rand($opportunity_ids);
 298      //$query = "insert into opportunities_contacts set id='".create_guid()."', contact_id='$contact->id', contact_role='".$app_list_strings['opportunity_relationship_type_default_key']."', opportunity_id='".$opportunity_ids[$opportunity_key]."'";
 299      //$db->query($query, true, "unable to create seed links between opportunities and contacts");
 300  
 301      $query = "insert into vtiger_contpotentialrel ( contactid, potentialid ) values (".$contact->id.",".$opportunity_ids[$opportunity_key].")";
 302      $db->query($query);
 303  
 304  //    $adb->println("PSD Contact [".$contact->id."] - account[".$account_ids[$account_key]."] - potential[".$opportunity_ids[$opportunity_key]."]");
 305  
 306      //Create new tasks
 307      /*$task = new Task();
 308  
 309      $key = array_rand($task->default_task_name_values);
 310      $task->name = $task->default_task_name_values[$key];
 311      $task->date_due = & create_date();
 312      $task->time_due = date("H:i:s",time());
 313      $task->date_due_flag = 'off';
 314      $task->assigned_user_id = $assigned_user_id;
 315      
 316      $key = array_rand($app_list_strings['task_status_dom']);
 317      $task->status = $app_list_strings['task_status_dom'][$key];
 318      $task->contact_id = $contact->id;
 319      if ($contact->primary_address_city == "San Mateo") {
 320          $task->parent_id = $account_ids[$account_key];
 321          $task->parent_type = 'Accounts';
 322          $task->save();
 323      }*/
 324  
 325  }
 326  
 327      $company_count=0;
 328  for($i=0; $i<10; $i++)
 329  {
 330      $lead = new Leads();
 331      $lead->column_fields["firstname"] = ucfirst(strtolower($first_name_array[$i]));
 332      $lead->column_fields["lastname"] = ucfirst(strtolower($last_name_array[$i]));
 333  
 334      if($i<5)
 335             {
 336              $lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$i]));
 337             }
 338             else
 339             {
 340                     $lead->column_fields["company"] = ucfirst(strtolower($company_name_array[$company_count]));
 341                     $company_count++;
 342             }
 343  
 344      $lead->column_fields["assigned_user_id"] = $assigned_user_id;
 345      
 346      $lead->column_fields["email"] = strtolower($lead->column_fields["firstname"])."_".strtolower($lead->column_fields["lastname"])."@company.com";
 347      
 348      $website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
 349          $lead->column_fields["website"] = "www.".$website.".com";
 350      
 351      $lead->column_fields["phone"] = create_phone_number();
 352      $lead->column_fields["mobile"] = create_phone_number();
 353      
 354      // Fill in a bogus address
 355      $key = array_rand($street_address_array);
 356      //$lead->address_street = $street_address_array[$key];
 357      $lead->column_fields["lane"] = $street_address_array[$key];
 358      $key = array_rand($city_array);
 359      $lead->column_fields["city"] = $city_array[$key];
 360      $lead->column_fields["state"] = "CA";
 361      $lead->column_fields["code"] = '99999';
 362      $lead->column_fields["country"] = 'USA';    
 363      if ($lead->column_fields["city"] == "San Mateo") 
 364          $lead->column_fields["yahooid"] = "clint_oram";
 365      elseif ($lead->column_fields["city"] == "San Francisco") 
 366          $lead->column_fields["yahooid"] = "not_a_real_id";
 367  
 368  //      $key = array_rand($app_list_strings['lead_source_dom']);
 369  //      $lead->lead_source = $app_list_strings['lead_source_dom'][$key];
 370      $key = array_rand($comboFieldArray['leadsource_dom']);
 371      $lead->column_fields["leadsource"] = $comboFieldArray['leadsource_dom'][$key];
 372  
 373  //      $key = array_rand($app_list_strings['lead_status_dom']);
 374  //      $lead->lead_status = $app_list_strings['lead_status_dom'][$key];
 375      $key = array_rand($comboFieldArray['lead_status_dom']);
 376      $lead->column_fields["leadstatus"] = $comboFieldArray['lead_status_dom'][$key];
 377  
 378  //      $key = array_rand($app_list_strings['rating_dom']);
 379  //      $lead->rating = $app_list_strings['rating_dom'][$key];
 380      $key = array_rand($comboFieldArray['rating_dom']);
 381      $lead->column_fields["rating"] = $comboFieldArray['rating_dom'][$key];    
 382  
 383      $titles = array("President", 
 384                      "VP Operations", 
 385                      "VP Sales", 
 386                      "Director Operations", 
 387                      "Director Sales", 
 388                      "Mgr Operations", 
 389                      "IT Developer", 
 390                      "");
 391      $key = array_rand($titles);
 392      $lead->column_fields["designation"] = $titles[$key];
 393  
 394      //$lead->saveentity("Leads");
 395      $lead->save("Leads");
 396  
 397  //    $adb->println("PSD Lead [".$lead->id."] - name=".$lead->column_fields["lastname"]);
 398  
 399  }
 400  
 401  // Temp fix since user is not logged in while populating data updating creatorid in crmentity - GS
 402  
 403  
 404  //Populating Vendor Data
 405  for($i=0; $i<10; $i++)
 406  {
 407      $vendor = new Vendors();
 408      $vendor->column_fields["vendorname"] = ucfirst(strtolower($first_name_array[$i]));
 409      $vendor->column_fields["phone"] = create_phone_number();
 410      $vendor->column_fields["email"] = strtolower($vendor->column_fields["vendorname"])."@company.com";
 411      $website = str_replace($whitespace, "", strtolower(ucfirst(strtolower($company_name_array[$i]))));
 412          $vendor->column_fields["website"] = "www.".$website.".com";
 413  
 414      $vendor->column_fields["assigned_user_id"] = $assigned_user_id;
 415      
 416  
 417      
 418      // Fill in a bogus address
 419      $vendor->column_fields["street"] = $street_address_array[rand(0,$street_address_count-1)]; 
 420      $key = array_rand($city_array);
 421      $vendor->column_fields["city"] = $city_array[$key];
 422      $vendor->column_fields["state"] = "CA";
 423      $vendor->column_fields["postalcode"] = '99999';
 424      $vendor->column_fields["country"] = 'USA';    
 425  
 426      $vendor->save("Vendors");
 427      $vendor_ids[] = $vendor->id;
 428  
 429  
 430  }
 431  
 432  
 433  //Populating Product Data
 434  
 435  $product_name_array= array( "Vtiger Single User Pack", "Vtiger 5 Users Pack", "Vtiger 10 Users Pack",
 436          "Vtiger 25 Users Pack", "Vtiger 50 Users Pack", "Double Panel See-thru Clipboard",
 437          "abcd1234", "Cd-R CD Recordable", "Sharp - Plain Paper Fax" , "Brother Ink Jet Cartridge"); 
 438  $product_code_array= array("001","002","003","023","005","sg-106","1324356","sg-108","sg-119","sg-125");
 439  $subscription_rate=array("149","699","1299","2999","4995");
 440  //added by jeri to populate product images
 441  $product_image_array = array("product1.jpeg###","product2.jpeg###product3.jpeg###","product4.jpeg###product5.jpeg###product6
 442  .jpeg###","product7.jpeg###product8.jpeg###product9.jpeg###product10.jpeg###");
 443  for($i=0; $i<10; $i++)
 444  {
 445          $product = new Products();
 446      if($i>4)
 447      {
 448          $parent_key = array_rand($opportunity_ids);
 449          $product->column_fields["parent_id"]=$opportunity_ids[$parent_key];
 450  
 451          $usageunit    =    "Each";
 452          $qty_per_unit    =    1;
 453          $qty_in_stock    =    rand(10000, 99999);
 454          $category     =     "Hardware";        
 455          $website     =    "";
 456          $manufacturer    =     "";
 457          $commission_rate=    rand(10,20);
 458          $unit_price    =    rand(100,999);
 459          $product_image_name = '';
 460      }
 461      else
 462      {
 463          $account_key = array_rand($account_ids);
 464          $product->column_fields["parent_id"]=$account_ids[$account_key];
 465  
 466          $usageunit    =    "Each";
 467          $qty_per_unit    =    1;
 468          $qty_in_stock    =    rand(10000, 99999);
 469          $category     =     "Software";    
 470          $website     =    "www.vtiger.com";
 471          $manufacturer    =     "vtiger";
 472          $commission_rate=    rand(1,10);
 473          $unit_price    =    $subscription_rate[$i];
 474          $product_image_name = $product_image_array[$i];
 475      }
 476  
 477          $product->column_fields["productname"]     =     $product_name_array[$i];
 478          $product->column_fields["productcode"]     =     $product_code_array[$i];
 479          $product->column_fields["manufacturer"]    =     $manufacturer;
 480  
 481      $product->column_fields["productcategory"] =     $category;
 482          $product->column_fields["website"]     =    $website;
 483          $product->column_fields["productsheet"] =    "";
 484  
 485      $vendor_key = array_rand($vendor_ids);
 486          $product->column_fields["vendor_id"]     =     $vendor_ids[$vendor_key];
 487      $contact_key = array_rand($contact_ids);
 488          $product->column_fields["contact_id"]     =     $contact_ids[$contact_key];
 489  
 490          $product->column_fields["start_date"]     =     & create_date();
 491          $product->column_fields["sales_start_date"]     = & create_date();
 492  
 493          $product->column_fields["unit_price"]     =     $unit_price;
 494          $product->column_fields["commissionrate"] =     $commission_rate;
 495          $product->column_fields["taxclass"]     =     'SalesTax';
 496          $product->column_fields["usageunit"]    =     $usageunit;
 497           $product->column_fields["qty_per_unit"] =     $qty_per_unit;
 498          $product->column_fields["qtyinstock"]     =     $qty_in_stock;
 499      $product->column_fields["imagename"] =  $product_image_name;
 500  
 501      $product->save("Products");
 502      $product_ids[] = $product ->id;
 503  }
 504  
 505  
 506  //Populating HelpDesk- FAQ Data
 507  
 508      $status_array=array ("Draft","Reviewed","Published","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft","Reviewed","Draft");
 509      $question_array=array (
 510      "How to migrate data from previous versions to the latest version?",
 511      "Error message: The file is damaged and could not be repaired.",
 512      "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
 513      "When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
 514      " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
 515      "How to migrate data from previous versions to the latest version?",
 516      "A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No when trying to add Email to vitger CRM ",
 517      " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
 518      "Error message: The file is damaged and could not be repaired.",
 519      "When trying to merge a template with a contact, First I was asked allow installation of ActiveX control. I accepted. After it appears a message that it will not be installed because it can't verify the publisher. Do you have a workarround for this issue ?",
 520      " Error message - please close all instances of word before using the vtiger word plugin. Do I need to close all Word and Outlook instances first before I can reopen Word and sign in?",
 521      "How to migrate data from previous versions to the latest version?",
 522      
 523      );
 524  
 525  
 526      $answer_array=array (
 527      "Database migration scripts are available to migrate from the following versions:
 528  
 529      1.0 to 2.0
 530  
 531      2.0 to 2.1
 532  
 533      2.1 to 3.0
 534  
 535      3.0 to 3.2
 536  
 537      3.2 to 4.0
 538  
 539      4.0 to 4.0.1
 540  
 541      4.0.1 to 4.2",
 542      
 543      "The above error message is due to version incompatibility between FPDF and PHP5. Use PHP 4.3.X version","Published",
 544      "The above error message is displayed if you have installed the Microsoft(R) Outlook(R) E-mail Security Update. Please refer to the following URL for complete details:
 545  
 546  http://support.microsoft.com/default.aspx?scid=kb%3BEN-US%3B263074
 547  
 548  If you want to continue working with vtiger Outlook Plug-in, select the Allow access for check box and select the time from drop-down box.",
 549      " Since, vtigerCRM & all plugins are open source, it is not signed up with third party vendors and IE will ask to download even though the plugin are not signed.
 550  
 551  This message if produced by Microsoft Windows XP. I English Windows XP with the SP2 and the last updates. I told IE to accept installation of the ActiveX, but after it, this message has appeared. Provably there is a place where to tall to WinXP to not validate if the code is signed... but I don\'t know where.
 552  
 553  In IE from Tools->Internet Options->Security->Custom Level, there you can see various options for downloading plugins which are not signed and you can adjust according to your need, so relax your security settings for a while and give a try to vtiger Office Plugin.",
 554      "Before modifying any templates, please ensure that you don\'t have any documents open and only one instance of word is available in your memory."
 555      );
 556  
 557  $num_array=array(0,1,2,3,4,6,7,8,9,10,11,12);
 558  for($i=0;$i<12;$i++)
 559  {
 560  
 561      $faq = new Faq();
 562      
 563      $rand=array_rand($num_array);
 564      $faq->column_fields["product_id"]    = $product_ids[$i];
 565      $faq->column_fields["faqcategories"]    = "General";
 566      $faq->column_fields["faqstatus"]     = $status_array[$i];
 567      $faq->column_fields["question"]        = $question_array[$i];
 568      $faq->column_fields["faq_answer"]    = $answer_array[$i];
 569  
 570      $faq->save("Faq");
 571      $faq_ids[] = $faq ->id;
 572  }
 573  
 574  //Populate Quote Data
 575  
 576  $sub_array = array ("Prod_Quote", "Cont_Quote", "SO_Quote", "PO_Quote", "Vendor_Quote");
 577  $stage_array = array ("Created", "Reviewed", "Delivered", "Accepted" , "Rejected");
 578  $carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
 579  $validtill_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
 580  for($i=0;$i<5;$i++)
 581  {
 582      $quote = new Quotes();
 583      
 584      $quote->column_fields["assigned_user_id"] = $assigned_user_id;
 585      $account_key = array_rand($account_ids);
 586      $quote->column_fields["account_id"] = $account_ids[$account_key];
 587      $op_key = array_rand($opportunity_ids);
 588      $quote->column_fields["potential_id"] = $opportunity_ids[$op_key];
 589      $contact_key = array_rand($contact_ids);
 590          $quote->column_fields["contact_id"] = $contact_ids[$contact_key];
 591      $rand = array_rand($num_array);
 592      $quote->column_fields["subject"] = $sub_array[$i];
 593      $quote->column_fields["quotestage"] = $stage_array[$i];    
 594      $quote->column_fields["carrier"] = $carrier_array[$i];
 595      $quote->column_fields["validtill"] = $validtill_array[$i];
 596  
 597      $quote->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
 598      $quote->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
 599      $quote->column_fields["bill_state"] = "CA";
 600      $quote->column_fields["bill_code"] = rand(10000, 99999);
 601      $quote->column_fields["bill_country"] = 'USA';    
 602  
 603      $quote->column_fields["ship_street"] = $account->column_fields["bill_street"];
 604      $quote->column_fields["ship_city"] = $account->column_fields["bill_city"];
 605      $quote->column_fields["ship_state"] = $account->column_fields["bill_state"];
 606      $quote->column_fields["ship_code"] = $account->column_fields["bill_code"];
 607      $quote->column_fields["ship_country"] = $account->column_fields["bill_country"];    
 608  
 609      
 610      $quote->save("Quotes");
 611  
 612      $quote_ids[] = $quote->id;
 613  
 614      $product_key = array_rand($product_ids); 
 615      $productid = $product_ids[$product_key];
 616  
 617      //set the inventory product details in request then just call the saveInventoryProductDetails function 
 618      $_REQUEST['totalProductCount']     = 1;
 619  
 620      $_REQUEST['hdnProductId1'] = $productid;
 621      $_REQUEST['qty1'] = $qty = 1;
 622      $_REQUEST['listPrice1'] = $listprice = 130;
 623      $_REQUEST['comment1'] = "This is test comment for product of Quotes";
 624      
 625      $_REQUEST['deleted1'] = 0;
 626      $_REQUEST['discount_type1'] = 'amount';
 627      $_REQUEST['discount_amount1'] = $discount_amount = '20';
 628  
 629      $_REQUEST['taxtype'] = $taxtype = 'individual';
 630      $_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
 631      $_REQUEST['discount_type_final'] = 'amount';
 632      $_REQUEST['discount_amount_final'] = $discount_amount_final = '10';
 633      
 634      $_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
 635      $_REQUEST['adjustmenttype'] = '+';
 636      $_REQUEST['adjustment'] = $adjustment = '10';
 637  
 638      $_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
 639  
 640      //Upto this added to set the request values which will be used to save the inventory product details
 641  
 642      //Now call the saveInventoryProductDetails function
 643      saveInventoryProductDetails(&$quote, 'Quotes');
 644  }
 645  
 646  //Populate SalesOrder Data
 647  
 648  $subj_array = array ("SO_vtiger", "SO_zoho", "SO_vtiger5usrp", "SO_vt100usrpk", "SO_vendtl");
 649  $status_array = array ("Created",  "Delivered", "Approved" , "Cancelled" , "Created");
 650  $carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
 651  $duedate_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
 652  
 653  for($i=0;$i<5;$i++)
 654  {
 655      $so = new SalesOrder();
 656      
 657      $so->column_fields["assigned_user_id"] = $assigned_user_id;
 658      $account_key = array_rand($account_ids);
 659      $so->column_fields["account_id"] = $account_ids[$account_key];
 660      $quote_key = array_rand($quote_ids);
 661      $so->column_fields["quote_id"] = $quote_ids[$quote_key];
 662      $contact_key = array_rand($contact_ids);
 663          $so->column_fields["contact_id"] = $contact_ids[$contact_key];
 664      $rand = array_rand($num_array);
 665      $so->column_fields["subject"] = $subj_array[$i];
 666      $so->column_fields["sostatus"] = $status_array[$i];    
 667      $so->column_fields["hdnGrandTotal"] = $sototal_array[$i];
 668      $so->column_fields["carrier"] = $carrier_array[$i];
 669      $so->column_fields["duedate"] = $duedate_array[$i];
 670  
 671      $so->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
 672      $so->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
 673      $so->column_fields["bill_state"] = "CA";
 674      $so->column_fields["bill_code"] = rand(10000, 99999);
 675      $so->column_fields["bill_country"] = 'USA';    
 676  
 677      $so->column_fields["ship_street"] = $account->column_fields["bill_street"];
 678      $so->column_fields["ship_city"] = $account->column_fields["bill_city"];
 679      $so->column_fields["ship_state"] = $account->column_fields["bill_state"];
 680      $so->column_fields["ship_code"] = $account->column_fields["bill_code"];
 681      $so->column_fields["ship_country"] = $account->column_fields["bill_country"];    
 682  
 683      
 684      $so->save("SalesOrder");
 685  
 686      $salesorder_ids[] = $so->id;
 687  
 688      $product_key = array_rand($product_ids); 
 689      $productid = $product_ids[$product_key];
 690  
 691      //set the inventory product details in request then just call the saveInventoryProductDetails function 
 692      $_REQUEST['totalProductCount']     = 1;
 693  
 694      $_REQUEST['hdnProductId1'] = $productid;
 695      $_REQUEST['qty1'] = $qty = 1;
 696      $_REQUEST['listPrice1'] = $listprice = 1230;
 697      $_REQUEST['comment1'] = "This is test comment for product of SalesOrder";
 698      
 699      $_REQUEST['deleted1'] = 0;
 700      $_REQUEST['discount_type1'] = 'amount';
 701      $_REQUEST['discount_amount1'] = $discount_amount = '200';
 702  
 703      $_REQUEST['taxtype'] = $taxtype = 'individual';
 704      $_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
 705      $_REQUEST['discount_type_final'] = 'amount';
 706      $_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
 707      
 708      $_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
 709      $_REQUEST['adjustmenttype'] = '+';
 710      $_REQUEST['adjustment'] = $adjustment = '100';
 711  
 712      $_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
 713  
 714      //Upto this added to set the request values which will be used to save the inventory product details
 715  
 716      //Now call the saveInventoryProductDetails function
 717      saveInventoryProductDetails(&$so, 'SalesOrder');
 718  
 719  
 720  }
 721  
 722  
 723  //Populate PurchaseOrder Data
 724  
 725  $psubj_array = array ("PO_vtiger", "PO_zoho", "PO_vtiger5usrp", "PO_vt100usrpk", "PO_vendtl");
 726  $pstatus_array = array ("Created",  "Delivered", "Approved" , "Cancelled", "Recieved Shipment");
 727  $carrier_array = array ("FedEx", "UPS", "USPS", "DHL", "BlueDart");
 728  $trkno_array = array ("po1425", "po2587", "po7974", "po7979", "po6411"); 
 729  $duedate_array = array ("2006-09-21", "2006-10-29", "2006-12-11", "2006-10-09", "2006-11-18");
 730  
 731  for($i=0;$i<5;$i++)
 732  {
 733      $po = new PurchaseOrder();
 734      
 735      $po->column_fields["assigned_user_id"] = $assigned_user_id;
 736      $vendor_key = array_rand($vendor_ids);
 737      $po->column_fields["vendor_id"] = $vendor_ids[$vendor_key];
 738      $contact_key = array_rand($contact_ids);
 739          $po->column_fields["contact_id"] = $contact_ids[$contact_key];
 740      $rand = array_rand($num_array);
 741      $po->column_fields["subject"] = $psubj_array[$i];
 742      $po->column_fields["postatus"] = $pstatus_array[$i];    
 743      $po->column_fields["carrier"] = $carrier_array[$i];
 744      $po->column_fields["tracking_no"] = $trkno_array[$i];
 745      $po->column_fields["duedate"] = $duedate_array[$i];
 746  
 747      $po->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
 748      $po->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
 749      $po->column_fields["bill_state"] = "CA";
 750      $po->column_fields["bill_code"] = rand(10000, 99999);
 751      $po->column_fields["bill_country"] = 'USA';    
 752  
 753      $po->column_fields["ship_street"] = $account->column_fields["bill_street"];
 754      $po->column_fields["ship_city"] = $account->column_fields["bill_city"];
 755      $po->column_fields["ship_state"] = $account->column_fields["bill_state"];
 756      $po->column_fields["ship_code"] = $account->column_fields["bill_code"];
 757      $po->column_fields["ship_country"] = $account->column_fields["bill_country"];    
 758          
 759      
 760      $po->save("PurchaseOrder");
 761  
 762      $purchaseorder_ids[] = $po->id;
 763  
 764      $product_key = array_rand($product_ids); 
 765      $productid = $product_ids[$product_key];
 766  
 767      //set the inventory product details in request then just call the saveInventoryProductDetails function 
 768      $_REQUEST['totalProductCount']     = 1;
 769  
 770      $_REQUEST['hdnProductId1'] = $productid;
 771      $_REQUEST['qty1'] = $qty = 1;
 772      $_REQUEST['listPrice1'] = $listprice = 2200;
 773      $_REQUEST['comment1'] = "This is test comment for product of PurchaseOrder";
 774      
 775      $_REQUEST['deleted1'] = 0;
 776      $_REQUEST['discount_type1'] = 'amount';
 777      $_REQUEST['discount_amount1'] = $discount_amount = '200';
 778  
 779      $_REQUEST['taxtype'] = $taxtype = 'individual';
 780      $_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
 781      $_REQUEST['discount_type_final'] = 'amount';
 782      $_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
 783      
 784      $_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
 785      $_REQUEST['adjustmenttype'] = '+';
 786      $_REQUEST['adjustment'] = $adjustment = '100';
 787  
 788      $_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
 789  
 790      //Upto this added to set the request values which will be used to save the inventory product details
 791  
 792      //Now call the saveInventoryProductDetails function
 793      saveInventoryProductDetails(&$po, 'PurchaseOrder');
 794  
 795  
 796  }
 797  
 798  //Populate Invoice Data
 799  
 800  $isubj_array = array ("vtiger_invoice201", "zoho_inv7841", "vtiger5usrp_invoice71134", "vt100usrpk_inv113", "vendtl_inv214");
 801  $istatus_array = array ("Created",  "Sent", "Approved" , "Credit Invoice", "Paid");
 802  $itotal_array = array ("4842.000", "4842.000", "4842.000", "4842.000", "4842.000");
 803  
 804  for($i=0;$i<5;$i++)
 805  {
 806      $invoice = new Invoice();
 807      
 808      $invoice->column_fields["assigned_user_id"] = $assigned_user_id;
 809      $account_key = array_rand($account_ids);
 810      $invoice->column_fields["account_id"] = $account_ids[$account_key];
 811      $so_key = array_rand($salesorder_ids);
 812      $invoice->column_fields["salesorder_id"] = $salesorder_ids[$so_key];
 813      $contact_key = array_rand($contact_ids);
 814          $invoice->column_fields["contactid"] = $contact_ids[$contact_key];
 815      $rand = array_rand($num_array);
 816      $invoice->column_fields["subject"] = $isubj_array[$i];
 817      $invoice->column_fields["invoicestatus"] = $istatus_array[$i];    
 818      $invoice->column_fields["hdnGrandTotal"] = $itotal_array[$i];
 819  
 820      $invoice->column_fields["bill_street"] = $street_address_array[rand(0,$street_address_count-1)];
 821      $invoice->column_fields["bill_city"] = $city_array[rand(0,$city_array_count-1)];
 822      $invoice->column_fields["bill_state"] = "CA";
 823      $invoice->column_fields["bill_code"] = rand(10000, 99999);
 824      $invoice->column_fields["bill_country"] = 'USA';    
 825  
 826      $invoice->column_fields["ship_street"] = $account->column_fields["bill_street"];
 827      $invoice->column_fields["ship_city"] = $account->column_fields["bill_city"];
 828      $invoice->column_fields["ship_state"] = $account->column_fields["bill_state"];
 829      $invoice->column_fields["ship_code"] = $account->column_fields["bill_code"];
 830      $invoice->column_fields["ship_country"] = $account->column_fields["bill_country"];    
 831      
 832      
 833      $invoice->save("Invoice");
 834  
 835      $invoice_ids[] = $invoice->id;
 836      if ($i > 3)
 837      {
 838          $freetag = $adb->getUniqueId('vtiger_freetags');
 839          $query = "insert into vtiger_freetags values ($freetag, '$cloudtag[0]', '$cloudtag[0]')";
 840          $res_inv = $adb->query($query);
 841  
 842          $date = $adb->formatDate(date('YmdHis')); 
 843          $query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$invoice->id.", $date, 'Invoice')";
 844          $result_inv = $adb->query($query_tag);
 845      }
 846  
 847      $product_key = array_rand($product_ids); 
 848      $productid = $product_ids[$product_key];
 849  
 850      //set the inventory product details in request then just call the saveInventoryProductDetails function 
 851      $_REQUEST['totalProductCount']     = 1;
 852  
 853      $_REQUEST['hdnProductId1'] = $productid;
 854      $_REQUEST['qty1'] = $qty = 1;
 855      $_REQUEST['listPrice1'] = $listprice = 4300;
 856      $_REQUEST['comment1'] = "This is test comment for product of Invoice";
 857      
 858      $_REQUEST['deleted1'] = 0;
 859      $_REQUEST['discount_type1'] = 'amount';
 860      $_REQUEST['discount_amount1'] = $discount_amount = '300';
 861  
 862      $_REQUEST['taxtype'] = $taxtype = 'individual';
 863      $_REQUEST['subtotal'] = $subtotal = $qty*$listprice-$discount_amount;
 864      $_REQUEST['discount_type_final'] = 'amount';
 865      $_REQUEST['discount_amount_final'] = $discount_amount_final = '100';
 866      
 867      $_REQUEST['shipping_handling_charge'] = $shipping_handling_charge = '50';
 868      $_REQUEST['adjustmenttype'] = '+';
 869      $_REQUEST['adjustment'] = $adjustment = '100';
 870  
 871      $_REQUEST['total'] = $subtotal-$discount_amount_final+$shipping_handling_charge+$adjustment;
 872  
 873      //Upto this added to set the request values which will be used to save the inventory product details
 874  
 875      //Now call the saveInventoryProductDetails function
 876      saveInventoryProductDetails(&$invoice, 'Invoice');
 877  
 878  }
 879  
 880  //Populate RSS Data
 881  
 882  
 883  
 884  
 885  //Populate Email Data
 886  
 887  $esubj_array =  array ("Vtiger 5 Released", "Try vtigercrm!", "Hi There!!!", "Welcome to Open Source", "Help needed in customization of Vtiger");
 888  $startdate_array =  array ("2006-1-2","2003-3-4","2003-4-5","2001-2-1","2005-8-8");
 889  $filename_array = array ("vtiger5alpha.tar.gz", "zohowriter.zip", "hi.doc", "welcome.pps", "sos.doc");
 890  
 891  $to_array = array("a@a.com","b@b.com", "tester@testvtiger.com","xanth@yaz.com","violet@bing.com");
 892  $cc_array = array("andrewa@a.com","casterb@b.com", "indomine@variancevtiger.com","becker@nosbest.com","electra@violet.com");
 893  $bcc_array = array("nathan@nathantests.com","jeff@karl1.com", "isotope@uranium.com","bunny@bugs.com","explosive@dud.com");
 894  $from_array = array("harvest@zss.com","rain@sunshine.com", "gloom@rainyday.com");
 895  $body_array = array("This is a good product! Have a go at it! ","Nice to have you visit us, very nice of you. Stay for sometime and have a look at our product. I am sure you will like it", "This will take some time to fix. Can you provide me more details please?","What a cool tool! I wish I had found it earlier. Oh it has a lot of my friends name in it too! I too can contribute. But how?","Urgent. I need this done last week! Guys, you are the ones I am depending on. Do something!");
 896  
 897  for($i=0;$i<5;$i++)
 898  {
 899      $email = new Emails();
 900  
 901      $email->column_fields["assigned_user_id"] = $assigned_user_id;
 902      
 903      $rand = array_rand($num_array);
 904      $email->column_fields["subject"] = $esubj_array[$i];
 905      $email->column_fields["filename"] = $filename_array[$i];    
 906      $email->column_fields["date_start"] = $startdate_array[$i];
 907      $email->column_fields["semodule"] = 'Tasks';
 908      $email->column_fields["activitytype"] = 'Emails';
 909      $email->column_fields["description"] = $body_array[$i];    
 910      $email->save("Emails");
 911      $email_ids[] = $email->id;
 912      
 913      $query = "insert into vtiger_emaildetails(emailid,from_email,to_email,cc_email,bcc_email) values (".$email->id.", '".$from_array[$i]."', '".$to_array[$i]."','".$cc_array[$i]."','".$bcc_array[$i] ."')";
 914          $res = $adb->query($query);
 915  }
 916  
 917  
 918  //Populate PriceBook data
 919  
 920  $PB_array = array ("Cd-R PB", "Vtiger PB", "Gator PB", "Kyple PB", "Pastor PB", "Zoho PB", "PB_100", "Per_PB", "CST_PB", "GATE_PB", "Chevron_PB", "Pizza_PB");
 921  $Active_array = array ("0", "1", "1", "0", "1","0", "1", "1", "0", "1","0","1");
 922  
 923  //$num_array = array(0,1,2,3,4);
 924  for($i=0;$i<12;$i++)
 925  {
 926      $pricebook = new PriceBooks();
 927  
 928      $rand = array_rand($num_array);
 929      $pricebook->column_fields["bookname"]   = $PB_array[$i];
 930      $pricebook->column_fields["active"]     = $Active_array[$i];
 931  
 932      $pricebook->save("PriceBooks");
 933      $pricebook_ids[] = $pricebook ->id;
 934  }
 935  
 936  
 937  //Populate Notes Data
 938  
 939  $notes_array = array ("Cont_Notes", "Prod_Notes", "Vendor_Notes", "Invoice_Notes", "Task_Notes", "Event_Notes", "Email_Notes");
 940  
 941  for($i=0;$i<7;$i++)
 942  {
 943      $notes = new Notes();
 944  
 945      $rand = array_rand($num_array);
 946      $contact_key = array_rand($contact_ids);
 947          $notes->column_fields["contact_id"]     =     $contact_ids[$contact_key];
 948      $notes->column_fields["notes_title"]        =    $notes_array[$i];
 949  
 950      $notes->save("Notes");
 951      $notes_ids[] = $notes ->id;
 952      
 953      $product_key = array_rand($product_ids);
 954          $query = "insert into vtiger_senotesrel (crmid, notesid) values (".$product_ids[$product_key].", ".$notes->id.")";
 955      $db->query($query);
 956          
 957  }
 958  
 959  
 960  
 961  // Populate Ticket data
 962  
 963  
 964  //$severity_array=array("Minor","Major","Critical","");
 965  $status_array=array("Open","In Progress","Wait For Response","Open","Closed");
 966  $category_array=array("Big Problem ","Small Problem","Other Problem","Small Problem","Other Problem");
 967  $ticket_title_array=array("Upload Attachment problem",
 968              "Individual Customization -Menu and RSS","Export Output query",
 969          "Import Error CSV Leads","How to automatically add a lead from a web form to VTiger");
 970  
 971  for($i=0;$i<5;$i++)
 972  {
 973      $helpdesk= new HelpDesk();
 974      
 975      $rand=array_rand($num_array);
 976      $contact_key = array_rand($contact_ids);
 977          $helpdesk->column_fields["parent_id"]     =     $contact_ids[$contact_key];
 978  
 979      $helpdesk->column_fields["ticketpriorities"]= "Normal";
 980      $helpdesk->column_fields["product_id"]    =     $product_ids[$i];
 981  
 982      $helpdesk->column_fields["ticketseverities"]    = "Minor";
 983      $helpdesk->column_fields["ticketstatus"]    = $status_array[$i];
 984      $helpdesk->column_fields["ticketcategories"]    = $category_array[$i];
 985      //$rand_key = array_rand($s);$contact_key = array_rand($contact_ids);
 986          $notes->column_fields["contact_id"]     =     $contact_ids[$contact_key];
 987      $helpdesk->column_fields["ticket_title"]    = $ticket_title_array[$i];
 988          $helpdesk->column_fields["assigned_user_id"] = $assigned_user_id;
 989      
 990      $helpdesk->save("HelpDesk");
 991      $helpdesk_ids[] = $helpdesk->id;
 992      
 993      if ($i > 3)
 994      {
 995          $freetag = $adb->getUniqueId('vtiger_freetags');
 996          $query = "insert into vtiger_freetags values ($freetag, '$cloudtag[3]', '$cloudtag[3]')";
 997          $res_tkt = $adb->query($query);
 998  
 999          $date = $adb->formatDate(date('YmdHis')); 
1000          $query_tag = "insert into vtiger_freetagged_objects values ($freetag, 1,".$helpdesk->id.", $date, 'HelpDesk')";
1001          $result_tkt = $adb->query($query_tag);
1002      }
1003  
1004  }
1005  
1006  // Populate Activities Data
1007  $task_array=array("Tele Conference","Call user - John","Send Fax to Mary Smith");
1008  $event_array=array("","","Call Smith","Team Meeting","Call Richie","Meeting with Don");
1009  $task_status_array=array("Planned","In Progress","Completed");
1010  $task_priority_array=array("High","Medium","Low");
1011  $visibility=array("","","Private","Public","Private","Public");
1012  
1013  for($i=0;$i<6;$i++)
1014  {
1015      $event = new Activity();
1016      
1017      $rand_num=array_rand($num_array);
1018  
1019      $rand_date = & create_date();
1020      $en=explode("-",$rand_date);
1021      if($en[1]<10)
1022          $en[1]="0".$en[1];
1023      if($en[2]<10)
1024          $en[2]="0".$en[2];
1025      $recur_daily_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+5,date($en[0])));
1026      $recur_week_date=date('Y-m-d',mktime(0,0,0,date($en[1]),date($en[2])+30,date($en[0])));
1027  
1028  
1029      $start_time_hr=rand(00,23);
1030      $start_time_min=rand(00,59);
1031      $end_time_hr=rand(00,23);
1032      $end_time_min=rand(00,59);
1033      if($start_time_hr<10)
1034          $start_time_hr="0".$start_time_hr;
1035      if($start_time_min<10)
1036          $start_time_min="0".$start_time_min;
1037      if($end_time_hr<10)
1038          $end_time_hr="0".$end_time_hr;
1039      if($end_time_min<10)
1040          $end_time_min="0".$end_time_min;
1041      $end_time=$end_time_hr.":".$end_time_min;
1042      $start_time=$start_time_hr.":".$start_time_min;
1043      if($i<2)
1044      {
1045          $event->column_fields["subject"]    = $task_array[$i];    
1046          if($i==1)
1047          {
1048              $account_key = array_rand($account_ids);
1049              $event->column_fields["parent_id"]    = $account_ids[$account_key];;    
1050          }
1051          $event->column_fields["taskstatus"]    = $task_status_array[$i];    
1052          $event->column_fields["taskpriority"]    = $task_priority_array[$i];    
1053          $event->column_fields["activitytype"]    = "Task";
1054          $event->column_fields["visibility"] = $visibility[$i];    
1055                  
1056      }
1057      else
1058      {
1059          $event->column_fields["subject"]    = $event_array[$i];    
1060          $event->column_fields["visibility"] = $visibility[$i];
1061          $event->column_fields["duration_hours"]    = rand(0,3);    
1062          $event->column_fields["duration_minutes"]= rand(0,59);    
1063          $event->column_fields["eventstatus"]    = "Planned";    
1064          $event->column_fields["time_end"]     = $end_time;
1065      }
1066      $event->column_fields["date_start"]    = $rand_date;    
1067      $_REQUEST["date_start"] = $rand_date;
1068      $event->column_fields["time_start"]    = $start_time;    
1069      $event->column_fields["due_date"]    = $rand_date;    
1070      $_REQUEST["due_date"] = $rand_date;
1071      $contact_key = array_rand($contact_ids);
1072          $event->column_fields["contact_id"]    =     $contact_ids[$contact_key];
1073      if($i==4)
1074      {
1075              $event->column_fields["recurringtype"]     = "Daily";
1076          $_REQUEST["recurringtype"]  = "Daily";
1077          $event->column_fields["activitytype"]    = "Meeting";    
1078          $event->column_fields["due_date"]    = $recur_daily_date;    
1079      }
1080      elseif($i==5)
1081      {    
1082              $event->column_fields["recurringtype"]     = "Weekly";
1083          $_REQUEST["recurringtype"]  = "Weekly";
1084          $event->column_fields["activitytype"]    = "Meeting";    
1085          $event->column_fields["due_date"]    = $recur_week_date;    
1086      }
1087      elseif($i>1) 
1088      {
1089          $event->column_fields["activitytype"]    = "Call";    
1090      }
1091      $event->column_fields["assigned_user_id"] = $assigned_user_id;
1092      $event->save("Calendar");
1093          $event_ids[] = $event->id;
1094  
1095  }
1096  
1097  
1098  $adb->query("update vtiger_crmentity set smcreatorid=".$assigned_user_id);
1099  
1100  $expected_revenue = Array("250000","750000","500000");
1101  $budget_cost = Array("25000","50000","90000");
1102  $actual_cost = Array("23500","45000","80000");
1103  $num_sent = Array("2000","2500","3000");
1104  $clo_date = Array('2003-1-2','2004-2-3','2005-4-12');
1105  
1106  $expected_response_count = Array("2500","7500","5000");
1107  $expected_sales_count = Array("25000","50000","90000");
1108  $expected_roi = Array("23","45","82");
1109  
1110  $actual_response_count = Array("250","750","1500");
1111  $actual_sales_count = Array("1250","5200","2390");
1112  $actual_roi = Array("21","14","12");
1113  
1114  $sponsor = Array("Finace","Marketing","Sales");
1115  $targetsize = Array("210000","13390","187424");
1116  $targetaudience = Array("Managers","CEOs","Rookies");
1117  
1118  //$expected_response = Array(null,null,null);
1119  for($i=0;$i<count($campaign_name_array);$i++)
1120  {
1121      $campaign = new Campaigns();
1122      $campaign_name = $campaign_name_array[$i];
1123      $campaign->column_fields["campaignname"] = $campaign_name;
1124      $campaign->column_fields["campaigntype"] = $campaign_type_array[$i];
1125      $campaign->column_fields["campaignstatus"] = $campaign_status_array[$i];
1126      $campaign->column_fields["numsent"] = $num_sent[$i];
1127      $campaign->column_fields["expectedrevenue"] = $expected_revenue[$i];
1128      $campaign->column_fields["budgetcost"] = $budget_cost[$i];
1129      $campaign->column_fields["actualcost"] = $actual_cost[$i];
1130      $campaign->column_fields["closingdate"] = $clo_date[$i];
1131      $campaign->column_fields["expectedresponse"] = $expected_response[$i];
1132      $campaign->column_fields["assigned_user_id"] = $assigned_user_id;
1133      
1134      $campaign->column_fields["expectedresponsecount"] = $expected_response_count[$i];
1135      $campaign->column_fields["expectedsalescount"] = $expected_sales_count[$i];
1136      $campaign->column_fields["expectedroi"] = $expected_roi[$i];
1137      $campaign->column_fields["actualresponsecount"] = $actual_response_count[$i];
1138      $campaign->column_fields["actualsalescount"] = $actual_sales_count[$i];
1139      $campaign->column_fields["actualroi"] = $actual_roi[$i];
1140      $campaign->column_fields["sponsor"] = $sponsor[$i];
1141      $campaign->column_fields["targetsize"] = $targetsize[$i];
1142      $campaign->column_fields["targetaudience"] = $targetaudience[$i];
1143  
1144  
1145      
1146      $campaign->save("Campaigns");
1147  }
1148  
1149  //Populate My Sites Data 
1150  
1151  $portalname = array ("Vtiger", "Vtiger Blogs", "Vtiger Forums", "VtigerForge", "Vtiger Docs");
1152  $portalurl = array ("http://vtiger.com", "http://blogs.vtiger.com", "http://forums.vtiger.com", "http://vtigerforge.com", "http://wiki.vtiger.com");
1153  
1154  for($i=0;$i<5;$i++)
1155  {
1156      $portalid = $adb->getUniqueId('vtiger_portal');
1157      $portal_qry = "insert into vtiger_portal values (".$portalid.", '".$portalname[$i]."','".$portalurl[$i]."',0)";
1158      $result_qry = $adb->query($portal_qry);
1159  }
1160  
1161  //Populate RSS Data
1162  $rssname = array("vtiger - Forums","vtiger development - Active Tickets");
1163  $rssurl = array("http://forums.vtiger.com/rss.php?name=forums&file=rss","http://vtiger.fosslabs.com/cgi-bin/trac.cgi/report/1?format=rss&USER=anonymous");
1164  
1165  for($i=0;$i<2;$i++)
1166  {
1167      $rssid = $adb->getUniqueId('vtiger_rss');
1168      $rss_qry = "insert into vtiger_rss values (".$rssid.", '".$rssurl[$i]."','".$rssname[$i]."',0,0)";
1169      $result_qry = $adb->query($rss_qry);
1170  }
1171  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7