params ['useLogin'] && ( in_array ( Yii::$app->request->userIP, Yii::$app->params ['authorizedIPs'] ) || in_array("all", Yii::$app->params['authorizedIPs'] ))) {
if (! \Yii::$app->user->isGuest) {
// Get the predefined user settings from the database and pass them to javascript
$settings=Yii::$app->user->identity->getUserSettings ();
$page = $settings['default_hits_per_page'];
$order = $settings['default_sort'];
$asc = $settings['order'];
$this->registerJs ( "var ops = " . json_encode ( $page ) . "; var or = " . json_encode ( $order ) . "; var asc = " . json_encode ( $asc ) . ";", View::POS_HEAD, 'my-options' );
Yii::$app->session ['search'] = Yii::$app->request->url;
Yii::$app->session ['records'] = $item_count;
// Create a Pjax widget which does not change the url.
// It contains two buttons one which saves the search and one which saves it by setting the
// subscription boolean to true.
Pjax::begin ( [
'enablePushState' => false
] );
?>
Subscribe to this search and get notified by email if new records
are added to the database.
= Html::a("Subscribe", ['account/subscribe'], ['class' => 'btn btn-primary','data-pjax'=>'w1','timeout'=>'100000'])?>
Save your search parameters without subscription
= Html::a("Save search", ['account/save'], ['class' => 'btn btn-primary','data-pjax'=>'w1','timeout'=>'100000'])?>
";
Pjax::begin ( [
'id' => 'shoppingCartContent',
'enablePushState' => false
] );
?>
There are = $shoppingCart?> samples in your basket.
= Html::a('View Basket', ['cart/addedlist'],['class' => 'btn btn-primary', 'id' => 'cartButton','timeout'=>'100000']);?>
= Html::button('Add to basket', ['class' => 'btn btn-primary', 'id' => 'addButton', 'title'=>'Add your selected samples to your cart']);?>
= Html::a('View Basket', ['cart/cart'],['class' => 'btn btn-primary', 'name' => 'cart-button'])?>
'.Html::a('Log in',['site/login']).' to save your search parameters or to access the sample request system
';
$this->registerJs ( "var ops = 25; var or = 0 ; var asc = 'asc';", View::POS_HEAD, 'my-options' );
}
}
else
$this->registerJs ( "var ops = 25; var or = 0; var asc = 'asc';", View::POS_HEAD, 'my-options' );
echo "";
$contentLeft = "";
$contentRight = "";
// $model = new SearchForm ();
// Yii::info ( "listView" );
$elements = $model->getParameters ();
function createFilters($doc, $recordFilters) {
$docFilters = [
'unitID' => $doc->unitID,
'collectioncode' => $doc->collectioncode,
'institutioncode' => $doc->institutioncode,
'guid' => $doc->guid,
// 'trick17ID' => $doc->trick17ID,
'kindofunit' => $doc->sampletype
];
$i = 1;
return $docFilters;
}
function createRecordActionUrl($docFilters) {
// Yii::info ( $docFilters );
$docCP = array_slice ( $docFilters, 0, 4 );
$nurl = Url::to ( array_merge ( [
'search/record'
], $docCP ) );
return $nurl;
}
$nl = "';
echo "
";
if (isset ( $response ))
if ($response != null && $item_count) {
if($item_count_total == '0')
{ $item_count_total = $item_count; }
else {$item_count_total = $item_count_total;}
echo $item_count_total . " record";
if ($item_count_total > 1) {
echo "s";
}
echo " found (unique samples, not counting multiple samples from the same specimen).";
if ($item_count_total > Yii::$app->params['maxLines'])
{ echo " The display is limited to ".Yii::$app->params['maxLines']." records."; }
} else
echo "No records found.";
echo "
Your search:
";
$form = ActiveForm::begin ( [
'method' => 'get',
'action' => $submitURL,
'enableClientValidation' => true,
'validateOnSubmit' => true
] );
$label = false;
$placeholder = true;
$cssClassSearchFields = 'complete_field searchfields';
CreateFormManager::prepareUpdateFormFields($form, $model, $elements, $this, $filters, $cssClassSearchFields, $selectionLists, $label, $placeholder);
$notUsedFields = [];
$notUsedElements = [];
// echo '
';
echo '
';
echo "
";
echo Html::submitButton ( $model->refineSearchButtonLabel, [
'class' => 'btn btn-primary'
] );
echo " ";
echo "
";
$headerTitle = "Add search field";
$headerClass = "btn btn-primary";
$itemContent = $this->render ( '@common/views/search/searchFieldSelection', [
'hideable_fields' => $model->getCompleteListFields (),
'hidden_elements' => $model->getCompleteList ()
], true );
CreateFormManager::AddAccordion($headerTitle, $headerClass, $itemContent);
echo "
";
echo Html::button ( $model->newSearchButtonLabel, array (
'onclick' => 'js:document.location.href="' . Yii::$app->getUrlManager ()->createUrl ( [
'search/index'
] ) . '"',
'class' => 'btn btn-primary'
) );
echo "
";
$searchPage = Yii::$app->getUrlManager ()->createUrl ( [
'search/index'
] );
ActiveForm::end ();
$content_array = array (
"value" => [],
"url" => [],
"isocountrycode" => [],
"unitID" => [],
"institutioncode" => [],
// "trick17ID" => [],
"kindofunit" => [],
"country" => [],
"collectioncode" => [] ,
"collectors" => [],
"collectornumber" => [],
"gatheringyear" => [],
"biodatasourcename" =>[],
"tripleidstoreid"=>[],
"guid"=>[]
);
// "associatedID" => []
if (isset ( $response ))
foreach ( $response as $doc ) {
if ($doc->fullScientificName == "" || $doc->fullScientificName == "N/A" ) {
if ($doc->familyName != "") {
$value = ucfirst(strtolower($doc->familyName));
} else {
if ($doc->orderName != "") {
$value = $doc->orderName;
} else {
if ($doc->className != "") {
$value = $doc->className;
} else {
if ($doc->phylumName != "") {
$value = $doc->phylumName;
} else {
if ($doc->kingdomName != "") {
$value = $doc->kingdomName;
} else
$value = "no identification";
}
}
}
}
array_push ( $content_array ["value"], $value );
} else {
$value = $doc->fullScientificName;
array_push ( $content_array ["value"], $value );
}
// if (is_array ( $doc ['upperUnitIDs'] )) {
// array_push ( $content_array["associatedID"],implode($doc ['upperUnitIDs'],", "));
// }
// else array_push ( $content_array["associatedID"],"nothing");
$filters = createFilters ( $doc, $recordFilters );
$url = createRecordActionUrl ( $filters );
array_push ( $content_array ["tripleidstoreid"], $doc->tripleidstoreid );
array_push ( $content_array ["url"], $url );
array_push ( $content_array ["isocountrycode"], $doc->isocountrycode );
array_push ( $content_array ["unitID"], $doc->unitID );
// array_push ( $content_array ["trick17ID"], $doc->trick17ID );
array_push ( $content_array ["institutioncode"], $doc->institutioncode );
array_push ( $content_array ["collectioncode"], $doc->collectioncode );
array_push ( $content_array ["guid"], $doc->guid );
array_push ( $content_array ["kindofunit"], $doc->sampletype );
array_push ( $content_array ["country"], $doc->country );
array_push ( $content_array ["collectors"], $doc->collectors );
array_push ( $content_array ["collectornumber"], $doc->collectornumber );
array_push ( $content_array ["gatheringyear"], $doc->gatheringyear );
array_push ( $content_array ["biodatasourcename"], $doc->biodatasourcename );
}
if (isset ( $response )) {
// Added by Anne Hartebrodt:
// If the user is logged in, a form is created containing a named checkbox for every hit. The submission mode
// is ajax to prevent entire (long) page reloading every time a checkbox is clicked. Futhermore the form is only
// submitted when the submit button is clicked.
$form = ActiveForm::begin ( [
'id' => 'form',
'type' => ActiveForm::TYPE_INLINE,
'enableAjaxValidation' => true,
'enableClientScript' => true,
'validateOnSubmit' => true,
'validateOnType' => false,
'validateOnChange' => false,
'validationUrl' => [
'cart/add'
]
] );
// if (! Yii::$app->user->isGuest) {
// } else {
// echo ("Log in to access shopping system!");
// }
echo "
Scientific Name
Country
Record No.
Repository
Type ";
if (! Yii::$app->user->isGuest) {
echo "Requests ";
}
echo "
";
for($i = 0; $i <= sizeof ( $content_array ["value"] ) - 1; $i ++) {
echo "" . $content_array ["value"] [$i] . " ";
echo "" . $content_array ["isocountrycode"] [$i] . " ";
echo "" . $content_array ["unitID"] [$i] . " ";
echo "" . $content_array ["institutioncode"] [$i] . " ";
echo "" . $content_array ["kindofunit"] [$i] . " ";
if (! Yii::$app->user->isGuest) {
if (isAvailable ( $shopping [$content_array ["tripleidstoreid"] [$i]] )) {
// At the moment only DNA and tissue are selectable
// Creation of the checkboxes. During submission the variables names are url-encoded, therefore, they cannot contain slashes.
// Some of the unit_ids which serve as var-names contain slashes, so for submission they need to be changed.
// a '/' is replaced by 'SLASH' during var-creation.
echo '' . $form->field ( $shopM, 'checked[' . preg_replace ( '*\/*', 'SLASH', $content_array ["unitID"] [$i] . "---" . $content_array ["collectioncode"] [$i] . "---" . $content_array ["institutioncode"] [$i] ) . ']', [
'validateOnBlur' => false,
'validateOnChange' => false,
'options'=>["title"=>"select for the basket"]
] )->checkbox () . ' ';
} else {
echo ''.Html::img ( "".Yii::$app->request->baseUrl."/images/icons/na.png", [
"title" => "not available",
"alt" => "not available",
] ).' ';
}
}
echo " ";
}
echo "
";
if ($item_count >10)
echo "
Go to page
";
ActiveForm::end ();
}
/**
* This function checks whether a sample is available for order.
*
* @param unknown $line
* an array containing the information on the sample
* @return boolean true, if the sample can be ordered; false if it is missing, consumed or blocked.
*/
function isAvailable($line) {
// sample missing or consumed
if ($line ["disposition_clean"] === 'missing' || $line ['disposition_clean'] === 'consumed') {
return false;
} // sample still blocked
elseif (strtotime ( $line ['blockedUntil'] ) - time () > 0) {
return false;
} elseif ($line ['blocked'] == 'yes' or $line ['blocked'] == 'Yes') {
return false;
} else {
return true;
}
}
function handleCoordinates($filters,$key,$param, $selectionLists, $this, $model, $form, $selectedValue) {
try {
$latitudeFrom = $filters ['latitudeFrom'];
} catch ( Exception $e ) {
$latitudeFrom = NULL;
}
try {
$latitudeTo = $filters ['latitudeTo'];
} catch ( Exception $e ) {
$latitudeTo = NULL;
}
try {
$longitudeFrom = $filters ['longitudeFrom'];
} catch ( Exception $e ) {
$longitudeFrom = NULL;
}
try {
$longitudeTo = $filters ['longitudeTo'];
} catch ( Exception $e ) {
$longitudeTo = NULL;
}
$hide_option = "";
$hide_button = "
request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>";
$htmlOpts = [
"name" => $param ['config'] ['name'],
"attribute1" => "latitudeFrom",
"attribute2" => "latitudeTo",
"attribute3" => "longitudeFrom",
"attribute4" => "longitudeTo",
"attribute1value" => $latitudeFrom,
"attribute2value" => $latitudeTo,
"attribute3value" => $longitudeFrom,
"attribute4value" => $longitudeTo,
'type' => \kartik\field\FieldRange::INPUT_TEXT
];
echo "
";
CreateFormManager::createField ( $this, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue, $hide_option, $hide_button );
echo $hide_button;
echo "
";
}
function handleGatheringyear($filters,$key, $param, $selectionLists, $this, $model, $form, $selectedValue) {
try {
$collectionYearFrom = $filters ['collectionYearFrom'];
} catch ( Exception $e ) {
$collectionYearFrom = NULL;
}
try {
$collectionYearTo = $filters ['collectionYearTo'];
} catch ( Exception $e ) {
$collectionYearTo = NULL;
}
$hide_option = "";
$hide_button = "
request->baseUrl . "/images/close.png \" parent_name=\"" . $key . "\" class=\"hide_button\" alt=\"close\"/>";
$htmlOpts = [
"name" => $param ['config'] ['name'],
"attribute1" => "collectionYearFrom",
"attribute2" => "collectionYearTo",
"attribute1value" => $collectionYearFrom,
"attribute2value" => $collectionYearTo,
"type" => \kartik\field\FieldRange::INPUT_TEXT
];
echo "
";
CreateFormManager::createField ( $this, $model, $form, $key, $param, $selectionLists, $htmlOpts, $selectedValue, $hide_option, $hide_button );
echo $hide_button;
echo "
";
}
?>