Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.87 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * This file is part of Breeding4Rice.
  5. *
  6. * Breeding4Rice is a free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Breeding4Rice is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Breeding4Rice. If not, see <http://www.gnu.org/licenses/>
  18. */
  19.  
  20. Yii::import('gms.models.Germplasm');
  21. Yii::import('gms.models.Names');
  22.  
  23. class CreateProgeniesCommand extends CConsoleCommand{
  24.  
  25. public $userId;
  26. public $creationTimestamp;
  27.  
  28. public function run(){
  29.  
  30. $gmworker = new GearmanWorker();
  31. $gmworker->addServer();
  32.  
  33. // start of function
  34.  
  35. $gmworker->addFunction("createProgenies", function($job){
  36.  
  37. $wJob = json_decode($job->workload());
  38.  
  39. //set globals
  40. $this->userId = $wJob->userId;
  41. $this->creationTimestamp = 'now()';
  42.  
  43. $params = $wJob->workload;
  44. $transaction = CreateProgenyTransaction::model()->findByPk($params->transactionId);
  45. $baseUrl = $wJob->baseUrl;
  46.  
  47. //get transaction terminal records
  48. $sql = "
  49. select * from operational_data_terminal.create_progeny_terminal
  50. where transaction_id = $transaction->id
  51. and is_void = false
  52. ";
  53.  
  54. $terminalRecords = Yii::app()->db->createCommand($sql)->queryAll();
  55.  
  56. $this->updateTransaction($transaction->id, 'In Progress', 'false');
  57.  
  58. //loop through transaction terminal records
  59. foreach($terminalRecords as $terminalRecord){
  60.  
  61. $productId = '';
  62. //create product
  63. if($terminalRecord['will_create_progenies']){
  64. $productId = $this->createProduct($terminalRecord);
  65. $this->updateTerminal($terminalRecord, 'Product Created');
  66. }
  67.  
  68. //create seed lot
  69. if($terminalRecord['will_create_seedlots']){
  70.  
  71. if($productId == ''){
  72. $productId = $this->getProductByIdDesignation(trim($terminalRecord['designation']));
  73. }
  74.  
  75. $newGid = $this->createGermplasm($terminalRecord, $productId);
  76. $this->createProductGid($terminalRecord,$productId,$newGid);
  77. $seedStorageId = $this->createSeedStorage($terminalRecord, $productId, $newGid);
  78. $this->updateTerminal($terminalRecord, 'Seedlot Created');
  79.  
  80. }
  81.  
  82. $this->addFamilyRecord($terminalRecord, $productId);
  83.  
  84. $product = Product::model()->findByPk($productId);
  85.  
  86. echo $product->designation." created! \n";
  87.  
  88. $this->updateTerminal($terminalRecord, 'Finished');
  89.  
  90. }
  91.  
  92. $this->updateTransaction($transaction->id, 'Finished', 'true');
  93. });
  94.  
  95.  
  96. while($gmworker->work())
  97. {
  98. if ($gmworker->returnCode() != GEARMAN_SUCCESS)
  99. {
  100. echo "return_code: " . $gmworker->returnCode() . "\n";
  101. break;
  102. }
  103. }
  104. }
  105.  
  106. public function updateTerminal($terminalRecord, $status){
  107. $terminalRecordId = $terminalRecord['id'];
  108.  
  109. $sql = "
  110. update
  111. operational_data_terminal.create_progeny_terminal
  112. set
  113. job_status = '$status'
  114. where
  115. id = '$terminalRecordId'
  116. ";
  117.  
  118. Yii::app()->db->createCommand($sql)->execute();
  119.  
  120. }
  121.  
  122. public function addFamilyRecord($terminalRecord, $productId){
  123.  
  124. $plot = Plot::model()->findByPk($terminalRecord['plot_id']);
  125. $entry = Entry::model()->findByPk($plot->entry_id);
  126. $study = Study::model()->findByPk($entry->study_id);
  127. $oldProduct = Product::model()->findByPk($entry->product_id);
  128. $product = Product::model()->findByPk($productId);
  129.  
  130. $crossId = $this->getCrossId($productId);
  131. if(!$crossId){
  132. $crossId = 'null';
  133. }
  134.  
  135. $selectionNumber = $this->getSelectionNumberFromDesignation($product->designation);
  136.  
  137. $sql = "
  138. insert into master.family
  139. (
  140. cross_id,parent_product_id,child_product_id,
  141. source_study_id,source_entry_id,source_plot_id,
  142. selection_number, creator_id,notes
  143. )
  144. values
  145. (
  146. $crossId, '$oldProduct->id', '$productId',
  147. '$study->id', '$entry->id', '$plot->id',
  148. '$selectionNumber', '$this->userId', 'created via create progenies tool'
  149. )
  150. ";
  151.  
  152. Yii::app()->db->createCommand($sql)->execute();
  153.  
  154. }
  155.  
  156. public function getSelectionNumberFromDesignation($designation){
  157.  
  158. $selectionNumber = substr($designation, -1);
  159.  
  160. if(is_numeric($selectionNumber)){
  161. return $selectionNumber;
  162. }else{
  163.  
  164. //bulk
  165. if($selectionNumber == 'B'){
  166. return 0;
  167. }else{
  168. if($this->endsWith(trim($designation), 'RGA')){
  169. $sel = substr($designation, -5, 1);
  170.  
  171. if(is_numeric($sel)){
  172. return $sel;
  173. }else{
  174. return 0;
  175. }
  176. }else{
  177. return 0;
  178. }
  179. }
  180.  
  181. }
  182.  
  183. }
  184.  
  185. public function getCrossId($newProductId){
  186.  
  187. $product = Product::model()->findByPk($newProductId);
  188. $desig = $product->designation;
  189.  
  190. //get cross id
  191. $sql = "
  192. select id from operational.cross
  193. where '$desig' ilike cross_name || '%'
  194. ";
  195.  
  196. $crossId = Yii::app()->db->createCommand($sql)->queryScalar();
  197. return $crossId;
  198.  
  199. }
  200.  
  201. public function updateTransaction($transactionId, $status, $isCommited){
  202.  
  203. $sql = "
  204. update
  205. operational_data_terminal.create_progeny_transaction
  206. set
  207. job_status = '$status',
  208. is_committed = '$isCommited'
  209. where
  210. id = '$transactionId'
  211. ";
  212.  
  213. Yii::app()->db->createCommand($sql)->execute();
  214.  
  215. }
  216.  
  217. public function createProductGid($terminalRecord, $productId, $newGid){
  218.  
  219. $product = Product::model()->findByPk($productId);
  220.  
  221. $sql = "
  222. insert into master.product_gid
  223. (
  224. product_id, gid, gid_type,
  225. creation_timestamp, creator_id,
  226. notes, is_void
  227. )
  228. values
  229. (
  230. '$productId', '$newGid', 'derivative',
  231. '$this->creationTimestamp', '$this->userId',
  232. 'created via create progenies tool', 'false'
  233. )
  234. returning id
  235. ";
  236.  
  237. $productGidId = Yii::app()->db->createCommand($sql)->queryScalar();
  238.  
  239. //update product with new gid
  240. $gidUpdateSql = "
  241. update master.product
  242. set
  243. gid = '$newGid',
  244. product_gid_id = '$productGidId'
  245. where id = '$productId'
  246. ";
  247.  
  248. Yii::app()->db->createCommand($gidUpdateSql)->execute();
  249.  
  250. //create new name
  251. $nameSql = "
  252. insert into master.product_name
  253. (
  254. product_id, name_type, value,
  255. language_code, creation_timestamp, creator_id,
  256. is_void, notes, product_gid_id
  257. )
  258. values
  259. (
  260. '$productId', 'derivative_name', '$product->designation',
  261. 'eng','$this->creationTimestamp', '$this->userId',
  262. 'false', 'created via create progenies tool', '$productGidId'
  263. )
  264. ";
  265.  
  266. Yii::app()->db->createCommand($nameSql)->execute();
  267.  
  268. }
  269.  
  270. public function createSeedStorage($terminalRecord, $productId, $newGid){
  271.  
  272. //get plot,entry,study levels
  273. $plot = Plot::model()->findByPk($terminalRecord['plot_id']);
  274. $entry = Entry::model()->findByPk($plot['entry_id']);
  275. $study = Study::model()->findByPk($entry->study_id);
  276. $program = Program::model()->findByPk($study->program_id);
  277. $product = Product::model()->findByPk($productId);
  278.  
  279. $volume_data = PlotData::model()->findByAttributes(array('is_void'=>false, 'plot_id' => $plot->id, 'variable_id' => Constants::AYLD_CONT));
  280.  
  281. if (!empty($volume_data)){
  282. $volume = $volume_data->value;
  283. }else{
  284. $volume = 0;
  285. }
  286.  
  287. //original seed storage id
  288. $original_storage_id = 'null';
  289. $seed_storage_log_obj = SeedStorageLog::model()->findByPk($entry->seed_storage_log_id);
  290. if (!empty($seed_storage_log_obj)){
  291. $original_storage_id = $seed_storage_log_obj->seed_storage_id;
  292. }
  293.  
  294. //get unit based on harvest method
  295. $harvestMethod = $this->getHarvestMethod($plot->id);
  296.  
  297. if (strpos(strtolower($harvestMethod), 'panicle') !== false) {
  298. $unit = 'panicles';
  299. }else{
  300. $unit = 'g';
  301. }
  302.  
  303. $selectionNumber = $this->getSelectionNumberFromDesignation($product->designation);
  304.  
  305. $containerId = 'null';
  306. $facilityId = 'null';
  307. if($terminalRecord['container_id'] != ''){
  308. $containerId = $terminalRecord['container_id'];
  309. }
  310.  
  311. if($terminalRecord['facility_id'] != ''){
  312. $containerId = $terminalRecord['facility_id'];
  313. }
  314.  
  315.  
  316. $sql = "
  317. insert into operational.seed_storage
  318. (
  319. product_id, seed_lot_id, key_type,
  320. seed_manager, gid, volume, unit,
  321. label, original_storage_id, creation_timestamp,
  322. creator_id, notes, is_void, selection_number, container_id, facility_id
  323. )
  324. values
  325. (
  326. '$productId', '$plot->key', 'plot_key',
  327. '$program->abbrev', '$newGid', '$volume', '$unit',
  328. '$plot->code','$original_storage_id','$this->creationTimestamp',
  329. '$this->userId','created via create progenies tool', 'false' ,'$selectionNumber', $containerId, $facilityId
  330. )
  331. returning id
  332. ";
  333.  
  334. $seedStorageId = Yii::app()->db->createCommand($sql)->queryScalar();
  335.  
  336. //create log
  337. $this->createSeedStorageLog($plot->key, $seedStorageId, $volume, $unit);
  338.  
  339. //create tons of metadata
  340. $this->createSeedStorageMetadata($plot, $seedStorageId);
  341.  
  342. return $seedStorageId;
  343.  
  344. }
  345.  
  346.  
  347. public function createSeedStorageMetadata($plot, $seedStorageId){
  348.  
  349. //get plot,entry,study levels
  350. $entry = Entry::model()->findByPk($plot->entry_id);
  351. $study = Study::model()->findByPk($entry->study_id);
  352. $program = Program::model()->findByPk($study->program_id);
  353.  
  354. //study short name
  355. $studyShortNameVariable = Constants::STUDY_NAME_VAR;
  356. $plotCodeVariable = Constants::PLOT_CODE;
  357. $sourceStudyVariable = Constants::SOURCE_STUDY_NAME;
  358. $sourceStudyShortNameVariable = Constants::SOURCE_STUDY;
  359.  
  360. $seasonSql = "
  361. select name from master.season where id = (
  362. select season_id from operational.study where id = $study->id
  363. )
  364. ";
  365. $season = Yii::app()->db->createCommand($seasonSql)->queryScalar();
  366.  
  367. $studyShortNameSql = "
  368. select value from operational.study_metadata
  369. where study_id = $study->id and variable_id = $studyShortNameVariable and is_void = false
  370. ";
  371.  
  372. $studyShortName = Yii::app()->db->createCommand($studyShortNameSql)->queryScalar();
  373.  
  374. $harvestDate = $this->getHarvestDate($plot->id);
  375. $harv = explode('-',$harvestDate);
  376. $harvestYear = $harv[0];
  377.  
  378.  
  379. //seed storage metadata
  380. $sql = "
  381. insert into operational.seed_storage_metadata
  382. (seed_storage_id,variable_id,value,creation_timestamp,creator_id,notes)
  383. values
  384. ('$seedStorageId','".Constants::SOURCE_STUDY_NAME."','$study->name','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  385. ('$seedStorageId','".Constants::STUDY_NAME_VAR."','$studyShortName','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  386. ('$seedStorageId','".Constants::SOURCE_STUDY_SEASON."','$season','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  387. ('$seedStorageId','".Constants::SRC_HARV_YEAR."','$harvestYear','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  388. ('$seedStorageId','".Constants::SRC_ENTRY."','$entry->entcode','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  389. ('$seedStorageId','".Constants::SOURCE_ENTRY_NUMBER."','$entry->entno','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  390. ('$seedStorageId','".Constants::PLOT_CODE."','$plot->code','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  391. ('$seedStorageId','".Constants::REP_VAR."','$plot->rep','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  392. ('$seedStorageId','".Constants::SOURCE_PLOT."','$plot->plotno','$this->creationTimestamp', '$this->userId','created via create progenies tool'),
  393. ('$seedStorageId','".Constants::HARVEST_DATE."','$harvestDate','$this->creationTimestamp', '$this->userId','created via create progenies tool')
  394. ";
  395.  
  396. Yii::app()->db->createCommand($sql)->execute();
  397.  
  398. }
  399.  
  400. public function createSeedStorageLog($plotKey, $seedStorageId, $volume, $unit){
  401.  
  402. $sql = "
  403. insert into operational.seed_storage_log
  404. (
  405. sender,seed_storage_id,encoder_id,
  406. encode_timestamp,transaction_type,volume,
  407. unit,event_timestamp,creation_timestamp,
  408. creator_id,notes
  409. )
  410. values
  411. (
  412. '$plotKey', '$seedStorageId','$this->userId',
  413. '$this->creationTimestamp','deposit','$volume',
  414. '$unit','$this->creationTimestamp','$this->creationTimestamp',
  415. '$this->userId','created via create progenies tool'
  416. )
  417. ";
  418.  
  419. Yii::app()->db->createCommand($sql)->execute();
  420.  
  421. }
  422.  
  423.  
  424. public function createGermplasm($terminalRecord, $productId){
  425.  
  426. //get plot,entry,study levels
  427. $plot = Plot::model()->findByPk($terminalRecord['plot_id']);
  428. $entry = Entry::model()->findByPk($plot['entry_id']);
  429. $study = Study::model()->findByPk($entry->study_id);
  430.  
  431. //new product
  432. $newProduct = Product::model()->findByPk($productId);
  433.  
  434. //old product
  435. $oldProduct = Product::model()->findByPk($entry->product_id);
  436.  
  437. //get gpid1 gpid2
  438. $gpid1 = null;
  439. $sql = "
  440. select gid
  441. from master.product_gid
  442. where product_id = {$oldProduct->id}
  443. and gid > 0 and is_void = false
  444. ";
  445. $gpid2 = Yii::app()->db->createCommand($sql)->queryScalar();
  446.  
  447. //get the gid of F1
  448. $gpid1 = null;
  449. $sql1 = "
  450. select gpid1
  451. from gms.germplsm
  452. where gid = {$gpid2}
  453. ";
  454. $gpid1 = Yii::app()->db->createCommand($sql1)->queryScalar();
  455.  
  456. if($newProduct->generation == 'F2'){
  457. $gpid1 = $gpid2;
  458. }
  459.  
  460. //get gdate
  461. $harvestDate = $this->getHarvestDate($plot->id);
  462.  
  463. $harvestYear = '';
  464. if(!empty($harvestDate)){
  465. $hvDate = explode('-',$harvestDate);
  466. $gdate = $hvDate[0].$hvDate[1].$hvDate[2];
  467. $harvestYear = $hvDate[0];
  468. }
  469.  
  470. //get harvest method
  471. $harvestMethod = $this->getHarvestMethod($plot->id);
  472.  
  473. //get iris id
  474. $userMetadata = UserMetadata::model()->findByAttributes(array('user_id' => $this->userId, 'variable_id' => Constants::IRIS_USER_ID));
  475. if (!empty($userMetadata)){
  476. $germuid = $userMetadata->value;
  477. }
  478. else{
  479. $germuid = 2; //guest user id
  480. }
  481.  
  482. //get glocn
  483. $glocn = $this->getGlocnValue($study->program_id, $study->place_id);
  484.  
  485. //special case for RGA
  486. if(($this->endsWith(trim($newProduct['designation']),'B RGA')) || ($this->endsWith(trim($newProduct['designation']),'B'))){
  487. $bulkMethNo = 207;
  488. }
  489.  
  490. $data2 = array(
  491. 'methn' => (isset($bulkMethNo))? $bulkMethNo : $this->getMethodNo($harvestMethod),
  492. 'gnpgs' => -1,
  493. 'gpid1' => $gpid1,
  494. 'gpid2' => $gpid2,
  495. 'germuid' => $germuid, //the person who do the knowledge work [user_id in GMS]
  496. 'lgid' => 0, //default for now
  497. 'glocn' => $glocn, //corresponding code of user's pipeline/group in GMS [location in GMS]
  498. 'gdate' => $gdate, //this should be the harvest date
  499. 'gref' => 0, //default for now
  500. 'grplce' => 0, //default for now
  501. 'mgid' => 0, //default for now
  502. 'ntype' => 5,
  503. 'nstat' => 1,
  504. 'nuid' => $germuid,
  505. 'nval' => $newProduct['designation'],
  506. 'nlocn' => $glocn,
  507. 'ndate' => date("Ymd"),
  508. 'nref' => 0,
  509. );
  510.  
  511. $gidCreateSuccessful = false;
  512.  
  513. while(!$gidCreateSuccessful){
  514.  
  515. try{
  516. $get_gid = Germplasm::create($data2);
  517. $gidCreateSuccessful = true;
  518. }catch(Exception $e) {
  519. $gidCreateSuccessful = false;
  520. }
  521. }
  522.  
  523. $newGid = ($get_gid != null) ? $get_gid : 'NULL';
  524. return $newGid;
  525.  
  526. }
  527.  
  528.  
  529. public function getMethodNo($harvestMethod){
  530.  
  531. $methNo = 0;
  532.  
  533. switch(strtolower($harvestMethod)){
  534.  
  535. case 'single plant selection':
  536. $methNo = 205;
  537. break;
  538. case 'single plant selection and bulk':
  539. $methNo = 205;
  540. break;
  541. case 'bulk':
  542. $methNo = 207;
  543. break;
  544. case 'plant-specific':
  545. $methNo = 205;
  546. break;
  547. case 'single plant seed increase':
  548. $methNo = 301;
  549. break;
  550. default:
  551. $methNo = 205;
  552. break;
  553. }
  554.  
  555. return $methNo;
  556.  
  557. }
  558.  
  559. public function endsWith($haystack, $needle){
  560.  
  561. $length = strlen($needle);
  562. if ($length == 0) {
  563. return true;
  564. }
  565.  
  566. return (substr($haystack, -$length) === $needle);
  567.  
  568. }
  569.  
  570. public function getHarvestMethod($plotId){
  571.  
  572. //get harvest METHOD
  573. $hvMethVariable = Constants::HARVEST_METHOD;
  574.  
  575. $harvestMethodSql = "
  576. select value from
  577. operational.plot_metadata
  578. where
  579. variable_id = '$hvMethVariable' and
  580. plot_id = '$plotId'
  581. and is_void = 'false'
  582. ";
  583. $harvestMethod = Yii::app()->db->createCommand($harvestMethodSql)->queryScalar();
  584.  
  585. return $harvestMethod;
  586.  
  587. }
  588.  
  589. public function getGlocnValue($programId, $placeId){
  590.  
  591. //iris loc
  592. $irisVarId = Constants::IRIS_LOCATION_ID;
  593.  
  594. $glocnSql = "
  595. select value from
  596. master.program_place_metadata
  597. where program_place_id in (
  598. select id from
  599. master.program_place
  600. where
  601. program_id = $programId
  602. and place_id = $placeId
  603. and is_void = false
  604. ) and variable_id = $irisVarId and is_void = false
  605. ";
  606.  
  607. $glocnValue = Yii::app()->db->createCommand($glocnSql)->queryScalar();
  608. if(!empty($glocnValue)){
  609. return $glocnValue;
  610. }else{
  611. return 0;
  612. }
  613.  
  614. }
  615.  
  616.  
  617. public function getHarvestDate($plotId){
  618.  
  619. //get harvest METHOD
  620. $hvMethVariable = Constants::HARVEST_DATE;
  621.  
  622. $harvestDateSql = "
  623. select value from
  624. operational.plot_metadata
  625. where
  626. variable_id = '$hvMethVariable' and
  627. plot_id = '$plotId'
  628. and is_void = 'false'
  629. ";
  630. $harvestDate = Yii::app()->db->createCommand($harvestDateSql)->queryScalar();
  631.  
  632. return $harvestDate;
  633.  
  634. }
  635.  
  636. public function getProductByIdDesignation($designation){
  637.  
  638. $sql = "
  639. select id from master.product
  640. where id = (
  641. select
  642. product_id
  643. from
  644. master.product_name
  645. where
  646. trim(value) = trim('$designation')
  647. and is_void = false
  648. limit 1
  649. ) and is_void = false
  650. ";
  651.  
  652. $productId = Yii::app()->db->createCommand($sql)->queryScalar();
  653.  
  654. return $productId;
  655. }
  656.  
  657. public function createProduct($terminalRecord){
  658.  
  659. //get entry
  660. $plot = Plot::model()->findByPk($terminalRecord['plot_id']);
  661. $entry = Entry::model()->findByPk($plot['entry_id']);
  662.  
  663. //old product
  664. $oldProduct = Product::model()->findByPk($entry->product_id);
  665.  
  666. //new generation
  667. if(trim(strtolower($oldProduct->generation)) == 'unkown'){
  668. $newGeneration = 'UNKNOWN';
  669. }else{
  670. $gen = explode('F', $oldProduct->generation);
  671. $newGeneration = 'F'. (intval(trim($gen[1])) + 1);
  672. }
  673.  
  674. $designation = $terminalRecord['designation'];
  675.  
  676. //check if old product exists
  677. $checkProd = ProductName::model()->findByAttributes(array(
  678. 'value'=>trim($designation),
  679. 'is_void'=>false
  680. ));
  681.  
  682. //product does not exist yet
  683. if(empty($checkProd)){
  684.  
  685. $year = date('Y',time());
  686. $seasonId = ($oldProduct->season_id != NULL) ? $oldProduct->season_id : 'null';
  687.  
  688.  
  689.  
  690.  
  691. $irisPreferredId = isset($oldProduct->iris_preferred_id) ? pg_escape_string($oldProduct->iris_preferred_id) : 'null';
  692. $crossId = isset($oldProduct->cross_id) ? pg_escape_string($oldProduct->cross_id) : 'null';
  693.  
  694. $sql = "
  695. insert into master.product
  696. (
  697. program_id, designation, name_type,
  698. product_type, year, season_id, mta_status,
  699. parentage, cross_id, generation,
  700. iris_preferred_id, breeding_line_name, derivative_name,
  701. fixed_line_name, selection_method, description,
  702. display_name, notes, creation_timestamp,
  703. creator_id, is_void
  704. )
  705. values
  706. (
  707. '$oldProduct->program_id', '$designation', 'derivative_name',
  708. 'progeny', '$year', $seasonId, '$oldProduct->mta_status',
  709. '$oldProduct->parentage',$crossId,'$newGeneration',
  710. $irisPreferredId,'$oldProduct->breeding_line_name', '$oldProduct->derivative_name',
  711. '$oldProduct->fixed_line_name','$oldProduct->selection_method','$oldProduct->description',
  712. '$designation','created via create progenies tool','$this->creationTimestamp',
  713. '$this->userId','false'
  714. )
  715. returning id
  716. ";
  717. $newProductId = Yii::app()->db->createCommand($sql)->queryScalar();
  718. return $newProductId;
  719.  
  720. }else{
  721. return $checkProd->product_id;
  722.  
  723. }
  724. }
  725.  
  726. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement