/**
  * Populate Product Template Model with data
  * @param Product Template object $model
  * @param int $counter
  */
 public function populateModelData(&$model, $counter)
 {
     assert('$model instanceof ProductTemplate');
     parent::populateModel($model);
     $productTemplateRandomData = self::getProductTemplatesRandomData();
     $name = $productTemplateRandomData['names'][$counter];
     $productCategoryName = self::getProductCategoryForTemplate($name);
     $allCats = ProductCategory::getAll();
     foreach ($allCats as $category) {
         if ($category->name == $productCategoryName) {
             $categoryId = $category->id;
         }
     }
     $productCategory = ProductCategory::getById($categoryId);
     $model->name = $name;
     $model->productCategories->add($productCategory);
     $model->priceFrequency = 2;
     $model->cost->value = 200;
     $model->listPrice->value = 200;
     $model->sellPrice->value = 200;
     $model->status = ProductTemplate::STATUS_ACTIVE;
     $model->type = ProductTemplate::TYPE_PRODUCT;
     $sellPriceFormula = new SellPriceFormula();
     $sellPriceFormula->type = SellPriceFormula::TYPE_EDITABLE;
     $model->sellPriceFormula = $sellPriceFormula;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebFormEntry');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebFormEntry');
     }
     $contactFormAttributes = array();
     $contact = new Contact();
     $contact->owner = $model->contactWebForm->defaultOwner;
     $contact->state = $model->contactWebForm->defaultState;
     $contact->firstName = $contactFormAttributes['firstName'] = $this->seedData['firstName'][$this->index];
     $contact->lastName = $contactFormAttributes['lastName'] = $this->seedData['lastName'][$this->index];
     $contact->companyName = $contactFormAttributes['companyName'] = $this->seedData['companyName'][$this->index];
     $contact->jobTitle = $contactFormAttributes['jobTitle'] = $this->seedData['jobTitle'][$this->index];
     if ($contact->validate()) {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
         $contact->save();
     } else {
         $contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
         $contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
         $contact = null;
     }
     $model->contact = $contact;
     $model->status = $contactWebFormEntryStatus;
     $model->message = $contactWebFormEntryMessage;
     $contactFormAttributes['owner'] = $model->contactWebForm->defaultOwner->id;
     $contactFormAttributes['state'] = $model->contactWebForm->defaultState->id;
     $model->serializedData = serialize($contactFormAttributes);
 }
示例#3
0
 public function populateModel(&$model)
 {
     //todo: assert instanceof Person or mixes in Person.
     parent::populateModel($model);
     $personRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ZurmoModule', 'Person');
     $jobTitlesAndDepartments = RandomDataUtil::getRandomValueFromArray($personRandomData['jobTitlesAndDepartments']);
     $lastName = RandomDataUtil::getRandomValueFromArray($personRandomData['lastNames']);
     if ($model->firstName == null && RandomDataUtil::getRandomBooleanValue()) {
         $model->firstName = RandomDataUtil::getRandomValueFromArray($personRandomData['femaleFirstNames']);
         $title = RandomDataUtil::getRandomValueFromArray($personRandomData['femaleTitles']);
     } elseif ($model->firstName == null) {
         $model->firstName = RandomDataUtil::getRandomValueFromArray($personRandomData['maleFirstNames']);
         $title = RandomDataUtil::getRandomValueFromArray($personRandomData['maleTitles']);
     }
     if ($model->lastName == null) {
         $model->lastName = $lastName;
     }
     $model->title->value = $title;
     $model->jobTitle = $jobTitlesAndDepartments[0];
     $model->department = $jobTitlesAndDepartments[1];
     $model->officePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->officeFax = RandomDataUtil::makeRandomPhoneNumber();
     $model->mobilePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->primaryEmail = static::makeEmailAddressByPerson($model);
     $model->primaryAddress = ZurmoRandomDataUtil::makeRandomAddress();
 }
 /**
  * @param $model
  * @param $counter
  */
 public function populateModelData(&$model, $counter)
 {
     assert('$model instanceof ProductCategory');
     parent::populateModel($model);
     $productCategoryRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ProductTemplatesModule', 'ProductCategory');
     $name = $productCategoryRandomData['names'][$counter];
     $model->name = $name;
 }
 /**
  * Populate model with required data
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Project');
     parent::populateModel($model);
     $projectRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ProjectsModule', 'Project');
     $name = RandomDataUtil::getRandomValueFromArray($projectRandomData['names']);
     $model->name = $name;
     $model->description = $name . ' Description';
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Note');
     parent::populateModel($model);
     $taskRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('NotesModule', 'Note');
     $description = RandomDataUtil::getRandomValueFromArray($taskRandomData['descriptions']);
     $occurredOnTimeStamp = time() - mt_rand(1, 200) * 60 * 60 * 24;
     $occurredOnDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($occurredOnTimeStamp);
     $model->description = $description;
     $model->occurredOnDateTime = $occurredOnDateTime;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof ContactWebForm');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('ContactWebFormsModule', 'ContactWebForm');
     }
     $model->name = $this->seedData['name'][$this->index];
     $model->redirectUrl = $this->seedData['redirectUrl'][$this->index];
     $model->submitButtonLabel = $this->seedData['submitButtonLabel'][$this->index];
     $placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
     $model->serializedData = serialize($placedAttributes);
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof AutoresponderItem');
     parent::populateModel($model);
     $model->processed = rand() % 2;
     $difference = rand(1000, 6000);
     if ($model->processed) {
         $processTimestamp = time() - $difference;
     } else {
         $processTimestamp = time() + $difference;
     }
     $model->processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($processTimestamp);
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof MarketingList');
     parent::populateModel($model);
     if (empty($this->seedData)) {
         $this->seedData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('MarketingListsModule', 'MarketingList');
     }
     $model->name = $this->seedData['name'][$this->index];
     $model->description = $this->seedData['description'][$this->index];
     $model->fromName = $this->seedData['fromName'][$this->index];
     $model->fromAddress = $this->seedData['fromAddress'][$this->index];
     $model->anyoneCanSubscribe = rand(10, 20) % 2;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Opportunity');
     $opportunityRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('OpportunitiesModule', 'Opportunity');
     parent::populateModel($model);
     $name = RandomDataUtil::getRandomValueFromArray($opportunityRandomData['names']);
     $model->name = $name;
     $stage = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('SalesStages'));
     $source = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('LeadSources'));
     $model->stage->value = $stage;
     $model->source->value = $source;
     $futureTimeStamp = time() + mt_rand(1, 200) * 60 * 60 * 24;
     $closeDate = Yii::app()->dateFormatter->format(DatabaseCompatibilityUtil::getDateFormat(), $futureTimeStamp);
     $model->closeDate = $closeDate;
     $model->amount->value = mt_rand(5, 350) * 1000;
 }
示例#11
0
 public function populateModel(&$model)
 {
     assert('$model instanceof Task');
     parent::populateModel($model);
     $taskRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('TasksModule', 'Task');
     $name = RandomDataUtil::getRandomValueFromArray($taskRandomData['names']);
     if (RandomDataUtil::getRandomBooleanValue()) {
         $dueTimeStamp = time() - mt_rand(1, 50) * 60 * 60 * 24;
         $completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($dueTimeStamp + mt_rand(1, 24) * 15);
         $model->completedDateTime = $completedDateTime;
         $model->completed = true;
     } else {
         $dueTimeStamp = time() + mt_rand(1, 200) * 60 * 60 * 24;
     }
     $dueDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($dueTimeStamp);
     $model->name = $name;
     $model->dueDateTime = $dueDateTime;
 }
 public function populateModelData(&$model, $counter, $name)
 {
     assert('$model instanceof Product');
     parent::populateModel($model);
     $productTemplateName = self::getProductTemplateForProduct($name);
     $allTemplates = ProductTemplate::getAll();
     foreach ($allTemplates as $template) {
         if ($template->name == $productTemplateName) {
             $templateId = $template->id;
         }
     }
     $productTemplate = ProductTemplate::getById($templateId);
     $model->name = $name;
     $model->quantity = mt_rand(1, 95);
     $model->productTemplate = $productTemplate;
     $model->stage->value = 'Open';
     $model->priceFrequency = $productTemplate->priceFrequency;
     $model->sellPrice->value = $productTemplate->sellPrice->value;
     $model->type = $productTemplate->type;
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof Account');
     parent::populateModel($model);
     $accountRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('AccountsModule', 'Account');
     $name = RandomDataUtil::getRandomValueFromArray($accountRandomData['names']);
     $domainName = static::makeDomainByName(strval($model));
     $type = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('AccountTypes'));
     $industry = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('Industries'));
     $model->name = $name;
     $model->website = static::makeUrlByDomainName($domainName);
     $model->type->value = $type;
     $model->industry->value = $industry;
     $model->officePhone = RandomDataUtil::makeRandomPhoneNumber();
     $model->officeFax = RandomDataUtil::makeRandomPhoneNumber();
     $model->primaryEmail = static::makeEmailAddressByAccount($model);
     $model->billingAddress = ZurmoRandomDataUtil::makeRandomAddress();
     $model->employees = mt_rand(1, 95) * 10;
     $model->annualRevenue = mt_rand(1, 780) * 1000000;
 }
 public function populateModel(&$model, $setInFuture = true)
 {
     assert('$model instanceof Meeting');
     parent::populateModel($model);
     $meetingRandomData = ZurmoRandomDataUtil::getRandomDataByModuleAndModelClassNames('MeetingsModule', 'Meeting');
     $name = RandomDataUtil::getRandomValueFromArray($meetingRandomData['names']);
     $category = RandomDataUtil::getRandomValueFromArray(static::getCustomFieldDataByName('MeetingCategories'));
     $location = RandomDataUtil::getRandomValueFromArray($meetingRandomData['locations']);
     if ($setInFuture) {
         $startTimeStamp = time() + mt_rand(1, 60) * 60 * 60 * 24;
         $startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp);
         $endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp + mt_rand(1, 24) * 15);
     } else {
         $startTimeStamp = time() - mt_rand(1, 30) * 60 * 60 * 24;
         $startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp);
         $endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($startTimeStamp + mt_rand(1, 24) * 15);
     }
     $model->name = $name;
     $model->category->value = $category;
     $model->location = $location;
     $model->startDateTime = $startDateTime;
     $model->endDateTime = $endDateTime;
 }
 /**
  * @param EmailMessageUrl $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof EmailMessageUrl');
     parent::populateModel($model);
     $model->url = 'http://' . $this->index . '.zurmo.com/';
 }
 /**
  * @param RedBeanModel $model
  */
 public function populateModel(&$model)
 {
     assert('$model instanceof MarketingListMember');
     parent::populateModel($model);
     $model->unsubscribed = rand() % 2;
 }
 public function populateModel(&$model)
 {
     assert('$model instanceof CampaignItem');
     parent::populateModel($model);
     $model->processed = rand() % 2;
 }