false, 'extensions' => 'png, jpg'], [['targeturl', 'caption', 'query', 'createdby'], 'string', 'max' => 300] ]; } public function upload() { if ($this->validate()) { $fullurl = 'c:/xampp/htdocs/portals/portal/ggbnsandbox/web/images/slider/' . $this->imageurl->baseName . '.' . $this->imageurl->extension; $this->imageurl->saveAs($fullurl); return true; } else { return false; } } private static $countJson = null; public function getCounts(){ if(is_null(self::$countJson)){ $apiLink = Yii::$app->urlManager->createAbsoluteUrl ( [ 'api/search?getCounts', ] ); self::$countJson = file_get_contents($apiLink); } return self::$countJson; } public function getCountsTotal() { $jsonfile = Carousel::getCounts(); $json_array = json_decode($jsonfile); return $json_array->{'nbSamples'}; } public function getCountsSamples() { $jsonfile = Carousel::getCounts(); $json_array = json_decode($jsonfile); if(isset($json_array->{'samples'}->{'DNA'})) { $nbDNA = $json_array->{'samples'}->{'DNA'}; } else { $nbDNA = ""; } if(isset($json_array->{'samples'}->{'tissue'})) { $nbTissue = $json_array->{'samples'}->{'tissue'}; } else { $nbTissue = ""; } return $nbDNA + $nbTissue; } public function getCountsEnviroSamples() { $jsonfile = Carousel::getCounts(); $json_array = json_decode($jsonfile); if(isset($json_array->{'samples'}->{'environmental sample'})) { $nbEnviro = $json_array->{'samples'}->{'environmental sample'}; } else { $nbEnviro = ""; } return $nbEnviro; } public function getCountsVouchers() { $jsonfile = Carousel::getCounts(); $json_array = json_decode($jsonfile); if(isset($json_array->{'samples'}->{'culture'})) { $nbCulture = $json_array->{'samples'}->{'culture'}; } else { $nbCulture = ""; } if(isset($json_array->{'samples'}->{'eVoucher'})) { $nbEVoucher = $json_array->{'samples'}->{'eVoucher'}; } else { $nbEVoucher = ""; } if(isset($json_array->{'samples'}->{'specimen'})) { $nbSpecimen = $json_array->{'samples'}->{'specimen'}; } else { $nbSpecimen = ""; } if(isset($json_array->{'samples'}->{'unknown'})) { $nbUnknown = $json_array->{'samples'}->{'unknown'}; } else { $nbUnknown = ""; } return $nbCulture + $nbEVoucher + $nbSpecimen + $nbUnknown; } public function getCountsSpecies() { $jsonfile = Carousel::getCounts(); $json_array = json_decode($jsonfile); if(isset($json_array->{'nbSpecies'})) { $nbSpecies = $json_array->{'nbSpecies'}; } else { $nbSpecies = ""; } return $nbSpecies; } public function getNbCoreMembers() { $connection = new \yii\db\Connection ( Yii::$app->db ); $connection->open (); $command = $connection->createCommand ( 'SELECT count(parentInstitutionID) as cnt FROM parentInstitution where parentInstitutionID!=38 and memberStatus = "Core"' ); $dataReader = $command->queryAll (); $total = 0; foreach ( $dataReader as $row ) { $total = $row ['cnt']; } Yii::$app->db->close (); // Yii::info("getCounts: ".$counts); return $total; } function getNbMembers(){ $connection = new \yii\db\Connection ( Yii::$app->db ); $connection->open (); $command = $connection->createCommand ( 'SELECT count(parentInstitutionID) as cnt FROM parentInstitution where parentInstitutionID!=38' ); $dataReader = $command->queryAll (); $total = 0; foreach ( $dataReader as $row ) { $total = $row ['cnt']; } Yii::$app->db->close (); // Yii::info("getCounts: ".$counts); return $total; } /** * @inheritdoc */ public function attributeLabels() { return [ 'carouselid' => 'ID', 'imageurl' => 'Image', 'targeturl' => 'Target Website', 'caption' => 'Caption', 'query' => 'Data Query', 'sequence' => 'Change Sequence', 'createdwhen' => 'Created When', 'createdby' => 'Created By', ]; } }