protected static function get_control_lux5kgrid($auth, $args, $tabalias, $options)
 {
     $ret = iform_mnhnl_lux5kgridControl($auth, $args, parent::$node, $options);
     return $ret;
 }
Example #2
0
function iform_mnhnl_locModTool($auth, $args, $node)
{
    global $indicia_templates;
    if (!isset($args['clientSideValidation']) || $args['clientSideValidation']) {
        data_entry_helper::enable_validation('entry_form');
    }
    if ($args['locationMode'] == 'multi') {
        $args['locationMode'] = 'parent';
    }
    data_entry_helper::$entity_to_load = array();
    $retVal = "<div id=\"locations\">";
    if ($args['shpFileDownloadURL'] != "") {
        $request = $args['shpFileDownloadURL'] . "/geoserver/wfs?request=GetFeature&service=wfs&version=1.0.0&outputformat=SHAPE-ZIP&srsName=EPSG:2169";
        if ($args['LocationTypeTerm'] == '' && isset($args['loctoolsLocTypeID'])) {
            $args['LocationTypeTerm'] = $args['loctoolsLocTypeID'];
        }
        $primary = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['LocationTypeTerm']);
        $request .= "&cql_filter=website_id=" . $args['website_id'] . " AND ";
        if ($args['SecondaryLocationTypeTerm'] != '') {
            $secondary = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['SecondaryLocationTypeTerm']);
            $request .= "(type_id=" . $primary . "OR type_id=" . $secondary . ")";
        } else {
            $request .= "type_id=" . $primary;
        }
        $request .= "&typename=" . $args['shpFileFeaturePrefix'] . ':';
        $filedetails = "&format_options=filename:" . $args['reportFilenamePrefix'];
        $retValList = "";
        if ($args['usePoints'] != 'none' || isset($args['shpDownloadPoints']) && $args['shpDownloadPoints']) {
            $retValList .= "<a href=\"" . $request . "point_locations" . $filedetails . "_Points.zip\">" . lang::get('Points') . "</a>";
        }
        if ($args['useLines'] != 'none' || isset($args['shpDownloadLines']) && $args['shpDownloadLines']) {
            $retValList .= ($retValList == "" ? "" : " : ") . "<a href=\"" . $request . "line_locations" . $filedetails . "_Lines.zip\">" . lang::get('Lines') . "</a>";
        }
        if ($args['usePolygons'] != 'none' || isset($args['shpDownloadPolygons']) && $args['shpDownloadPolygons']) {
            $retValList .= ($retValList == "" ? "" : " : ") . "<a href=\"" . $request . "polygon_locations" . $filedetails . "_Polygons.zip\">" . lang::get('Polygons') . "</a>";
        }
        $retVal .= "<fieldset><legend>" . lang::get('LANG_SHP_Download_Legend') . "</legend>\n      <p>" . lang::get('LANG_Shapefile_Download') . " " . $retValList . "</p></fieldset>";
    }
    $includeOutsideSquare = $args['locationMode'] == 'parent';
    // includes multi - see above
    // filtered
    if ($args['locationMode'] == 'filtered') {
        $filterAttrs = explode(',', $args['filterAttrs']);
        foreach ($filterAttrs as $idx => $filterAttr) {
            $filterAttr = explode(':', $filterAttr);
            if ($filterAttr[0] == 'Parent' && $filterAttr[1] == "true") {
                $includeOutsideSquare = true;
            }
        }
    }
    if ($includeOutsideSquare) {
        $confirmedLocationTypeID = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['SecondaryLocationTypeTerm']);
        if (is_null($confirmedLocationTypeID)) {
            $confirmedLocationTypeID = "0";
        }
        $submittedLocationTypeID = iform_mnhnl_getTermID($auth, 'indicia:location_types', $args['LocationTypeTerm']);
        $retVal .= "<fieldset><legend>" . lang::get('LANG_Outside_Square_Reports') . "</legend>\n  \t<form method='post' action='" . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/luxbio_outside_squares_1.xml&reportSource=local&auth_token=' . $auth['read']['auth_token'] . '&nonce=' . $auth['read']['nonce'] . '&mode=csv&filename=' . $args['reportFilenamePrefix'] . "CentreOutsideSquaresReport'>\n      <label style='width:auto;'>" . lang::get('LANG_Outside_Square_Download_1') . ":</label>\n      <input type='hidden' name='params' value='{\"website_id\":" . $args['website_id'] . ", \"survey_id\":" . $args['survey_id'] . ", \"primary_loc_type_id\":" . $submittedLocationTypeID . ", \"secondary_loc_type_id\":" . $confirmedLocationTypeID . "}' />\n      <input type='submit' class='ui-state-default ui-corner-all' value='" . lang::get('Download') . "'>\n    </form>\n  \t<form method='post' action='" . data_entry_helper::$base_url . '/index.php/services/report/requestReport?report=reports_for_prebuilt_forms/MNHNL/luxbio_outside_squares_2.xml&reportSource=local&auth_token=' . $auth['read']['auth_token'] . '&nonce=' . $auth['read']['nonce'] . '&mode=csv&filename=' . $args['reportFilenamePrefix'] . "BoundaryCutsSquaresReport'>\n      <label style='width:auto;'>" . lang::get('LANG_Outside_Square_Download_2') . ":</label>\n      <input type='hidden' name='params' value='{\"website_id\":" . $args['website_id'] . ", \"survey_id\":" . $args['survey_id'] . ", \"primary_loc_type_id\":" . $submittedLocationTypeID . ", \"secondary_loc_type_id\":" . $confirmedLocationTypeID . "}' />\n      <input type='submit' class='ui-state-default ui-corner-all' value='" . lang::get('Download') . "'>\n    </form>\n    </fieldset>";
    }
    $retVal .= "<form method=\"post\" id=\"entry_form\">" . $auth['write'] . "<input type=\"hidden\" id=\"source\" name=\"source\" value=\"iform_mnhnl_locModTool\" />" . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />" . "<input type=\"hidden\" id=\"survey_id\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />";
    $retVal .= iform_mnhnl_lux5kgridControl($auth, $args, $node, array('Instructions2' => lang::get('LANG_LocModTool_Instructions2'), 'MainFieldLabel' => lang::get('LANG_LocModTool_IDLabel'), 'NameLabel' => lang::get('LANG_LocModTool_NameLabel'), 'ParentLabel' => lang::get('LANG_LocModTool_ParentLabel'), 'AdminMode' => true));
    $retVal .= "<label for=\"location-delete\">" . lang::get("LANG_LocModTool_DeleteLabel") . ":</label> <input type=checkbox id=\"location-delete\" name=\"location:deleted\" value='t'><br />\n  <p>" . lang::get("LANG_LocModTool_DeleteInstructions") . "</p>";
    // location comments are included as a separate control on the main form.
    if (isset($args['includeLocationComment']) && $args['includeLocationComment']) {
        $retVal .= data_entry_helper::textarea(array('id' => 'location-comment', 'fieldname' => 'location:comment', 'label' => lang::get("LANG_LocationModTool_CommentLabel"))) . "<br />";
    }
    $laArgs = array("lookUpKey" => "meaning_id", "sep" => " ", "class" => "wide", "tabNameFilter" => "", "numValues" => 10000);
    $defs = array();
    if (isset($args['siteTabSplitAttrs']) && $args['siteTabSplitAttrs'] != "") {
        $defs = explode(':', $args['siteTabSplitAttrs']);
        $defs1 = explode(',', $defs[0]);
        $laArgs["tabNameFilter"] = $defs1[0];
        $laArgs["class"] = $defs1[1];
    }
    $retVal .= iform_mnhnl_locationattributes($auth, $args, '', $laArgs);
    $retVal .= iform_mnhnl_SrefFields($auth, $args, true);
    if (count($defs) > 1) {
        $defs1 = explode(',', $defs[1]);
        $laArgs["tabNameFilter"] = $defs1[0];
        $laArgs["class"] = $defs1[1];
        $retVal .= iform_mnhnl_locationattributes($auth, $args, '', $laArgs);
    }
    $args['interface'] = 'Tabs';
    $mapOptions = iform_map_get_map_options($args, $auth['read']);
    $olOptions = iform_map_get_ol_options($args);
    if ($args['locationMode'] != 'parent') {
        // this includes multi as well (see above)
        // can't call the protested control function
        $georefOpts = iform_map_get_georef_options($args, $auth['read']);
        // can't use place search without the driver API key
        if ($georefOpts['driver'] == 'geoplanet' && empty(helper_config::$geoplanet_api_key)) {
            $retVal .= '<p>The form structure includes a [place search] control but needs a geoplanet api key.</p>';
        } else {
            $retVal .= data_entry_helper::georeference_lookup($georefOpts);
        }
        $mapOptions['searchLayer'] = true;
        $mapOptions['searchUpdatesSref'] = false;
        $mapOptions['searchDisplaysPoint'] = false;
    }
    // For main page we force to Tabs to ensure map drawn correctly
    $mapOptions['tabDiv'] = 'locations';
    $mapOptions['standardControls'] = array('layerSwitcher', 'panZoomBar');
    $mapOptions['editLayer'] = false;
    $mapOptions['maxZoom'] = $args['zoomLevel'];
    if (isset($args['locationLayerWMS']) && $args['locationLayerWMS'] != '') {
        $mapOptions['layers'] = array('ParentWMSLayer', "ParentLocationLayer", "SiteLabelLayer", "SiteAreaLayer", "SitePathLayer", "SitePointLayer");
        $mapOptions['clickableLayers'] = array('ParentWMSLayer');
        $mapOptions['clickableLayersOutputMode'] = 'custom';
        $mapOptions['clickableLayersOutputDiv'] = 'clickableLayersOutputDiv';
        $mapOptions['clickableLayersOutputFn'] = 'setClickedParent';
    } else {
        $mapOptions['layers'] = array("ParentLocationLayer", "SiteLabelLayer", "SiteAreaLayer", "SitePathLayer", "SitePointLayer");
    }
    $retVal .= data_entry_helper::map_panel($mapOptions, $olOptions);
    $retVal .= iform_mnhnl_PointGrid($auth, $args, array('srefs' => '2169,LUREF (m),X,Y,;4326,Lat/Long Deg,Lat,Long,D;4326,Lat/Long Deg:Min,Lat,Long,DM;4326,Lat/Long Deg:Min:Sec,Lat,Long,DMS'));
    $retVal .= '    <input type="submit" class="ui-state-default ui-corner-all" value="' . lang::get('LANG_Submit') . '">
    <a href="' . iform_mnhnl_getReloadPath() . '"><input class="ui-state-default ui-corner-all" type="button" name="cancel" value="' . lang::get('LANG_Cancel') . '" /></a>
    </form></div>';
    data_entry_helper::$javascript .= "\nmapInitialisationHooks.push(function(mapdiv) {\n// try to identify if this map is the secondary small one\n  if(mapdiv.id=='map')\n    jQuery(\"#dummy-parent-id\").val('').change();});\n";
    return $retVal;
}
Example #3
0
 /**
  * Get the location module control
  */
 protected static function get_control_locationmodule($auth, $args, $tabalias, $options)
 {
     if (self::$mode === self::MODE_EXISTING_RO) {
         $options['disabled'] = true;
     }
     $retVal = iform_mnhnl_lux5kgridControl($auth, $args, parent::$node, array_merge(array('initLoadArgs' => '{initial: true}'), $options));
     self::set_code_functionality($auth, $args, user_access($args['edit_permission']));
     return $retVal;
 }
 protected static function get_control_lux5kgrid2($auth, $args, $tabalias, $options)
 {
     // can only change the location for a new sample: fixed afterwards. *
     global $indicia_templates;
     $countAttr = iform_mnhnl_getAttrID($auth, $args, 'occurrence', 'Count');
     if (!$countAttr) {
         return lang::get('This form must be used with a survey that has the Count Occurrence attribute associated with it.');
     }
     $noObAttr = iform_mnhnl_getAttrID($auth, $args, 'sample', 'No observation', isset($args['sample_method_id']) && $args['sample_method_id'] != "" ? $args['sample_method_id'] : false);
     if (!$noObAttr) {
         return lang::get('This form must be used with a survey that has the No observation Sample attribute associated with it.');
     }
     data_entry_helper::$javascript .= "\n// because the fetch is generic, we can't guarentee that the sort order will be numeric eg name 2 comes after 10.\nhook_loadLocation= function(feature) {\n  if(feature.attributes['new']) setNameDropDowns(false, false);\n  else setNameDropDowns(true, false);\n}\ncreateGridEntries = function(feature, isnew) {\n  cgRowNum++;\n  var mySiteNum=false;\n  var name = '';\n  if(typeof(feature)=='object'&&(feature instanceof Array)){\n    mySiteNum = feature[0].attributes.SiteNum;\n  } else {\n    mySiteNum = feature.attributes.SiteNum;\n  }\n  var newCGRows = jQuery('#cgCloneableTable').find('tr').clone();\n  for(var i = 0; i< newCGRows.length; i++){\n    jQuery.each(jQuery(newCGRows[i]).children(), function(i, cell) {cell.innerHTML = cell.innerHTML.replace(/--rownum--/g, cgRowNum);});\n  }\n  for(var i = 0; i< newCGRows.length; i++){\n    jQuery(newCGRows[i]).removeClass('cgCloneableRow'+(i+1)).addClass((isnew ? 'cgAddedRow':'cggrid-row')+(i==0?'':i+1)).data('cgRowNum', cgRowNum).data('SiteNum', mySiteNum);\n  }\n  jQuery(newCGRows[0]).find('td:not(.cggrid-datecell,.cggrid-namecell,.remove-cgnewrow)').css('opacity',0.25);\n  jQuery(newCGRows[0]).find('*:.cggrid-date,.cggrid-datecell,.cggrid-name,.cggrid-namecell,.remove-cgnewrow').removeAttr('disabled');\n  for(var i = 1; i< newCGRows.length; i++){\n    jQuery(newCGRows[i]).find('*').attr('disabled','disabled').filter('td').css('opacity',0.25);\n  }\n  if(!isnew){\n    if(typeof(feature)=='object'&&(feature instanceof Array)){\n      myID = feature[0].attributes.data.id;\n      name = feature[0].attributes.data.name;\n    } else {\n      myID = feature.attributes.data.id;\n      name = feature.attributes.data.name;\n    }\n    var fieldname=jQuery(newCGRows[0]).find('.cggrid-name').attr('name');\n    jQuery(newCGRows[0]).find('.cggrid-namecell').empty().append('<input name=\"'+fieldname+'\" class=\"cggrid-name narrow\" value=\"'+name+'\" readonly=\"readonly\" ><input type=\"hidden\" name=\"CG:'+cgRowNum+':--sampleid--:location_id\" value=\"'+myID+'\" >');\n    //  cggrid-centroid_sref,cggrid-centroid_geom,cggrid-boundary_geom,cggrid-location_type_id are all removed by the cggrid-name empty above\n    jQuery(newCGRows[0]).find('.remove-cgnewrow').removeClass('remove-cgnewrow').addClass('clear-cgrow');\n  } else {\n    jQuery('#dummy-name').find('option').each(function (index, option){\n      if(name == '' && jQuery('.cggrid-row,.cgAddedRow').find('.cggrid-name').filter('[value='+jQuery(option).val()+']').length == 0)\n        name=jQuery(option).val();\n    });\n    jQuery(newCGRows[0]).find('.cggrid-name').val(name);\n  }\n  var insertPoint=false;\n  insertCount=0; // we'll assume that the existing entries are in numerical order\n  jQuery('#conditions-grid > tbody').find('tr:.cggrid-row,.cgAddedRow').each(function(index,elem){\n    if(parseInt(jQuery(elem).find('.cggrid-name').val()) < parseInt(name)){\n      insertCount++;\n      insertPoint = jQuery(elem);\n      for(var i = 1; i< newCGRows.length; i++)\n        insertPoint = insertPoint.next();\n    }\n  });\n//  insertCount--;\n  if(!insertPoint){\n    for(var i = newCGRows.length-1; i>=0; i--)\n      jQuery('#conditions-grid > tbody').prepend(newCGRows[i]);\n  } else {\n    for(var i = newCGRows.length-1; i>=0; i--)\n      jQuery(newCGRows[i]).insertAfter(insertPoint);\n  }\n  jQuery(newCGRows[0]).find('.cggrid-date').datepicker({dateFormat : 'dd/mm/yy', changeMonth: true, changeYear: true, constrainInput: false, maxDate: '0', onClose: function() { \$(this).valid(); }});\n  recalcNumSites();\n  // Species grid 1) add to header, 2) add to cloneable row, 3) add to existing rows\n  insertCount++;// double cells at start for these rows.\n  insertPoint=jQuery('#mnhnl-species-grid-header').children(':eq('+insertCount+')');\n  jQuery('<th class=\"smp-'+cgRowNum+'\">'+name+'</th>').css('opacity',0.25).insertAfter(insertPoint);\n  jQuery('.sgNoObRow').each(function(i, Row) {\n    insertPoint=jQuery(Row).children(':eq('+insertCount+')');\n    var newNoObCell = jQuery('<td class=\"smp-'+cgRowNum+'\">'+\n      '<input type=\"hidden\" name=\"CG:'+cgRowNum+':--sampleid--:smpAttr:" . $noObAttr . "\" value=\"0\" \"/>'+\n      '<input type=\"checkbox\" name=\"CG:'+cgRowNum+':--sampleid--:smpAttr:" . $noObAttr . "\" value=\"1\" class=\"narrow\" disabled=\"disabled\" />'+\n      '</td>').css('opacity',0.25).insertAfter(insertPoint);\n    newNoObCell.find(':checkbox').rules('add', {no_observation: cgRowNum});\n  });\n  insertPoint=jQuery('.sgCloneableRow').children(':eq('+insertCount+')');\n  jQuery('<td class=\"smp-'+cgRowNum+'\"><input class=\"digits narrow disabled\" name=\"SG:--sgrownum--:'+cgRowNum+':--sampleid--:--ttlid--:--occid--:occAttr:" . $countAttr . "\" disabled=\"disabled\" min=\"1\"></td>').css('opacity',0.25).insertAfter(insertPoint);\n  jQuery('.sgAddedRow,.sgOrigRow').each(function(i, Row) {\n    insertPoint=jQuery(Row).children(':eq('+insertCount+')');\n    jQuery('<td class=\"smp-'+cgRowNum+'\"><input class=\"digits narrow disabled\" name=\"SG:'+jQuery(Row).data('taxonRow')+':'+cgRowNum+':--sampleid--:'+jQuery(Row).data('ttlid')+':--occid--:occAttr:" . $countAttr . "\" disabled=\"disabled\" min=\"1\"></td>').css('opacity',0.25).insertAfter(insertPoint);\n  });\n  resetSpeciesGridHeader();\n  return name;\n};\nmoveGridEntries = function(cgRowNum) {\n  var oldPosition=-1;\n  var newPosition=-1;\n  var numCGRows = jQuery('#cgCloneableTable').find('tr').length;\n  var name;\n  jQuery('#conditions-grid > tbody').find('tr:.cggrid-row,.cgAddedRow').each(function(index,elem){\n    if(jQuery(elem).data('cgRowNum')==cgRowNum){\n      name = jQuery(elem).find('.cggrid-name').val(); // has been updated to new value.\n      oldPosition=index;\n    }});\n  jQuery('#conditions-grid > tbody').find('tr:.cggrid-row,.cgAddedRow').each(function(index,elem){\n    if(index != oldPosition && parseInt(jQuery(elem).find('.cggrid-name').val()) < parseInt(name)){\n      newPosition=index; // points to row we insert after.\n    }});\n  if(newPosition==oldPosition-1) return;\n  var rows=[];\n  for(var i=0; i< numCGRows; i++)\n    rows.push(jQuery('#conditions-grid > tbody').find('tr:eq('+(numCGRows*oldPosition+i)+')'));\n  if(newPosition < 0){\n    for(var i=numCGRows-1; i>=0; i--)\n      jQuery('#conditions-grid > tbody').prepend(rows[i]);\n  } else {\n    var insertPoint=jQuery('#conditions-grid > tbody').find('tr:eq('+(numCGRows*(newPosition+1)-1)+')');  // = item after which we insert\n    for(var i=numCGRows-1; i>=0; i--)\n      rows[i].insertAfter(insertPoint);\n  }\n  // Species grid 1) add to header, 2) add to cloneable row, 3) add to existing rows\n  jQuery('#mnhnl-species-grid-header,.sgNoObRow,.sgCloneableRow,.sgAddedRow,.sgOrigRow').each(function(i, Row) {\n    insertPoint=jQuery(Row).children(':eq('+(newPosition+2)+')');\n    jQuery(Row).children(':eq('+(oldPosition+2)+')').insertAfter(insertPoint);\n  });\n  resetSpeciesGridHeader();\n};\n\nhook_ChildFeatureLoad = function(feature, data, child_id, options){\n  // this is a multisite, so child_id will never be filled in.\n  if(!options.initial){\n    var mySiteNum=false;\n    if(typeof(feature)=='object'&&(feature instanceof Array)){\n      mySiteNum = feature[0].attributes.SiteNum;\n    } else {\n      mySiteNum = feature.attributes.SiteNum;\n    }\n    createGridEntries(feature, false);\n    var allFeatures = SiteAreaLayer.features.concat(SitePathLayer.features,SitePointLayer.features,SiteLabelLayer.features);\n    for(var i=0; i< allFeatures.length; i++){ // need to get the label as well\n      if(typeof allFeatures[i].attributes.SiteNum != 'undefined' &&\n          allFeatures[i].attributes.SiteNum == mySiteNum){\n        allFeatures[i].attributes.cgRowNum = cgRowNum;\n      }}\n  }\n  setNameDropDowns(false, false);\n}\nhook_mnhnl_parent_changed = function(){\n  jQuery('#conditions-grid > tbody').find('tr').remove();\n  jQuery('#mnhnl-species-grid > tbody').find('tr').not('.sgNoObRow').remove();\n  jQuery('#mnhnl-species-grid').find('th:gt(1)').remove();\n  jQuery('#mnhnl-species-grid').find('td:gt(1)').remove();\n  jQuery('.sgCloneableRow').find('td:gt(1)').remove();\n};";
     $retVal = iform_mnhnl_lux5kgridControl($auth, $args, parent::$node, array_merge(array('initLoadArgs' => '{initial: true}'), $options));
     return $retVal;
 }
 protected static function get_control_locationmodule($auth, $args, $tabalias, $options)
 {
     $ret = iform_mnhnl_lux5kgridControl($auth, $args, parent::$node, array_merge(array('initLoadArgs' => '{}'), $options));
     return $ret;
 }