Esempio n. 1
0
 /**
  * Generate Data Massive Contact Person
  *
  * @param bool $resultIds
  *
  * @param int  $count
  *
  * @return array|string
  */
 public static function generateMassive($resultIds = false, $count = 100)
 {
     $posIds = Positions::getIdsPositionOrCreateMassiveDummy();
     $deptIds = Dept::getIdsOrCreateMassiveDummy();
     $supplierIds = Suppliers::getRecordIdsOrCreate(200);
     $buyerIds = Buyers::getRecordIdsOrCreate(200);
     $records = static::getFake()->getContacts()->generateContacts($count, $posIds, $deptIds, $supplierIds, $buyerIds);
     $contacts = array();
     foreach ($records as $record) {
         $newrecord = static::create($record);
         $contacts[] = $newrecord->id;
     }
     return $resultIds ? $contacts : 'Generate Contact Person with ' . count($contacts) . ' records';
 }
Esempio n. 2
0
 /**
  * @param int $count
  *
  * @return array
  */
 public static function createSampleAccountBank($count = 10)
 {
     $sample = static::getSample()->getFake();
     $listBanksId = Bank::getIdsOrCreateBanks(true);
     $listtypeId = Bankaccounttype::getDefaultBankTypeIdsOrCreate(true);
     $buyerIds = Buyers::getRecordIdsOrCreate(30);
     $supplierIds = Suppliers::getRecordIdsOrCreate();
     $ids = array();
     for ($rec = 0; $rec < $count; $rec++) {
         $bankId = $sample->randomElement($listBanksId);
         $TypeId = $sample->randomElement($listtypeId);
         $buyerId = $sample->randomElement($buyerIds);
         $supplierId = $sample->randomElement($supplierIds);
         $parents = static::getSample()->getBank()->getListOwners($supplierId, $buyerId);
         $parentId = $parents['id'];
         $parentType = $parents['type'];
         $records = static::create(static::getSample()->getBank()->createAccountBank($bankId, $parentId, $parentType, $TypeId));
         $ids[] = $records->id;
     }
     return $ids;
     //		$bankId,$parentId, $parentType, $typeId
 }
Esempio n. 3
0
 public static function generateSampleProducts($count = 10)
 {
     //		Type
     $typeIds = Producttype::getIdsOrCreateDummy();
     //		category
     $categoryIds = Productcategory::getIdsOrCreateSampelData();
     //		unit berat
     $unitIds = Units::getIdsOrCreateSampleUnits();
     //		parent_id
     $parentId = 0;
     $fake = static::getFake();
     //
     //		Buat Product
     $catId = $fake->getFake()->randomElement($categoryIds);
     $typeId = $fake->getFake()->randomElement($typeIds);
     $unitWeightId = $fake->getFake()->randomElement($unitIds);
     $unitWidthId = $fake->getFake()->randomElement($unitIds);
     $supplierIds = Suppliers::getRecordIdsOrCreate();
     $currencyIds = Currencies::getIdsOrCreateSample();
     //		color
     $colorIds = Colors::getIdsOrCreate();
     //  gradeIds
     $gradeIds = Fabricgrade::getIdsOrCreate();
     $productIds = array();
     for ($rec = 0; $rec < $count; $rec++) {
         $product = $fake->getProduct()->product($catId, $typeId, $unitWeightId, $unitWidthId, $parentId, '\\Emayk\\Ics\\Repo\\Productcategory\\Productcategory');
         $record = static::createRecord($product);
         $productId = $record->id;
         $productIds[] = $productId;
         //		Image/ Photo Product
         $imagesIds[] = Images::getIdsOrCreate($productId, '\\Emayk\\Ics\\Repo\\Products\\Products');
         //			Supplier Product
         //		Product Supplier (Product dapat dari Supplier mana ?)
         $supplierId = $fake->getFake()->randomElement($supplierIds);
         $supplierProduct = Productsuppliers::create(array('master_product_id' => $productId, 'master_supplier_id' => $supplierId));
         $supplierProductId = $supplierProduct->id;
         //			Create Detail
         //		Buat Product Detail
         $unitId = $fake->getFake()->randomElement($unitIds);
         $colorId = $fake->getFake()->randomElement($colorIds);
         $gradeId = $fake->getFake()->randomElement($gradeIds);
         $currSp = $fake->getFake()->randomElement($currencyIds);
         $currSpm = $fake->getFake()->randomElement($currencyIds);
         $detailIds[] = Productdetails::getIdOrCreate($productId, $colorId, $unitId, $gradeId, $currSp, $currSpm);
         //Buat Stock
         //		Buat Stock
         $stockIds[] = Stockproducts::createStock($productId);
     }
     foreach ($stockIds as $stockId) {
         for ($history = 0; $history < 9; $history++) {
             //		Buat Stock Detail/History
             if ($history % 2 == 0 || $history == 0) {
                 $typeHistory = 'in';
             } else {
                 $typeHistory = 'out';
             }
             $firstHistory = $history == 0;
             //                $stockHistoryIds[] =
             Stockproducthistory::createHistoryStockSample($stockId, $typeHistory, $firstHistory);
         }
     }
     return "Sudah Generate sebanyak " . count($productIds) . " records";
     return s($productIds, $supplierProductId, $imagesIds, $detailIds);
 }
Esempio n. 4
0
File: Phones.php Progetto: emayk/ics
 public static function generateMassivePhoneSample($resultIds = false, $count = 10)
 {
     $listBuyerIds = Buyers::getRecordIdsOrCreate();
     $listSupplierIds = Suppliers::getRecordIdsOrCreate();
     $ids = array();
     for ($r = 0; $r < $count; $r++) {
         $buyerId = static::pickOneFromArray($listBuyerIds);
         $supplierId = static::pickOneFromArray($listSupplierIds);
         $parents = static::getParentRecord($buyerId, $supplierId);
         $parent = $parents[rand(0, 1)];
         $parentId = $parent['id'];
         $parentType = $parent['type'];
         $newrecord = static::createRecord(static::getRecordValue($parentId, $parentType));
         $ids[] = $newrecord->id;
     }
     $total = count($ids);
     return $resultIds ? $ids : "Generate Phone with {$total} record ";
 }