Ejemplo n.º 1
0
 public function profilegetdata($stateid = 0, $councilid = 0, $schemeid = 0, $zoneid = 0, $overlayids = array(), $precinctid = 0)
 {
     $stateid = intval($stateid);
     $councilid = intval($councilid);
     $schemeid = intval($schemeid);
     $zoneid = intval($zoneid);
     $overlayidsnew = array();
     if (!is_array($overlayids)) {
         $overlayids = explode(',', $overlayids);
     }
     $hz = false;
     foreach ($overlayids as $overlayid) {
         $overlayid = intval($overlayid);
         if ($overlayid == 0) {
             if (!$hz) {
                 $hz = true;
             }
         }
         $overlayidsnew[] = $overlayid;
     }
     if ($hz) {
         $overlayidsnew = array();
     }
     unset($overlayids);
     $precinctid = intval($precinctid);
     $data = array();
     if ($councilid > 0) {
         $data['council'] = profilef::profilegetname($councilid);
     }
     if ($schemeid > 0) {
         $data['scheme'] = profilef::profilegetname($schemeid);
     }
     $data['muddefinition'] = '';
     $data['muddisclaimer'] = '';
     $md = profilef::profilegetmuddefinition($stateid);
     if (!empty($md[0])) {
         $data['muddefinition'] = $md[0];
         $data['muddisclaimer'] = $md[1];
     }
     $md = profilef::profilegetmuddefinition($councilid);
     if (!empty($md[0])) {
         $data['muddefinition'] = $md[0];
         $data['muddisclaimer'] = $md[1];
     }
     $md = profilef::profilegetmuddefinition($schemeid);
     if (!empty($md[0])) {
         $data['muddefinition'] = $md[0];
         $data['muddisclaimer'] = $md[1];
     }
     if (empty($data['muddefinition'])) {
         $data['muddefinition'] = '';
         $data['muddisclaimer'] = '';
     }
     $numfields = array('maxcover', 'maxdensity', 'maxstorey', 'min', 'minfrontage', 'minmultiple', 'minmultiplefrontage', 'maxheight', 'maxgfa');
     $generaltextfields = array('mudsetback', 'housesetback', 'smalllotsetback', 'secondarysetback');
     foreach ($generaltextfields as $textfield) {
         $overlaydata['field_' . $textfield] = '';
         $data[$textfield] = '';
         $data[$textfield . 'fromzone'] = false;
         $data[$textfield . 'fromplan'] = false;
         $data[$textfield . 'fromoverlay'] = false;
     }
     foreach ($numfields as $fieldname) {
         $overlaydata['field_' . $fieldname] = NULL;
         $data[$fieldname] = NULL;
     }
     $overlaydata['field_heightinfo'] = '';
     $overlaydata['field_lotinfo'] = '';
     $overlaydata['field_lotmultipleinfo'] = '';
     $overlaydata['field_gfainfo'] = '';
     $overlaydata['field_densityinfo'] = '';
     $overlaydata['field_coverinfo'] = '';
     $overlaydata['field_storeyinfo'] = '';
     $overlaydata['field_frontagelotinfo'] = '';
     $overlaydata['field_frontagelotmultipleinfo'] = '';
     $data['heightinfo'] = '';
     $data['lotinfo'] = '';
     $data['lotmultipleinfo'] = '';
     $data['gfainfo'] = '';
     $data['densityinfo'] = '';
     $data['coverinfo'] = '';
     $data['maxheightfromzone'] = false;
     $data['minfromzone'] = false;
     $data['minmultiplefromzone'] = false;
     $data['maxgfafromzone'] = false;
     $data['maxdensityfromzone'] = false;
     $data['maxcoverfromzone'] = false;
     if ($zoneid > 0) {
         $zonefields = profilef::profilegetdetailfields($zoneid);
         $data['zone'] = $zonefields['field_name'];
         profilef::profilegroupoverride($data, $zonefields, array('maxheight', 'maxstorey'), 'heightinfo', 'maxheightfromzone');
         profilef::profilegroupoverride($data, $zonefields, array('min', 'minfrontage'), 'lotinfo', 'minfromzone');
         profilef::profilegroupoverride($data, $zonefields, array('minmultiple', 'minmultiplefrontage'), 'lotmultipleinfo', 'minmultiplefromzone');
         profilef::profilegroupoverride($data, $zonefields, 'maxgfa', 'gfainfo', 'maxgfafromzone');
         profilef::profilegroupoverride($data, $zonefields, 'maxdensity', 'densityinfo', 'maxdensityfromzone');
         profilef::profilegroupoverride($data, $zonefields, 'maxcover', 'coverinfo', 'maxcoverfromzone');
         foreach ($generaltextfields as $textfield) {
             if (isset($zonefields['field_' . $textfield])) {
                 $text = trim($zonefields['field_' . $textfield]);
                 if (!empty($text)) {
                     $data[$textfield] = $text;
                     $data[$textfield . 'fromzone'] = true;
                 }
             }
         }
     }
     $data['maxheightfromplan'] = false;
     $data['minfromplan'] = false;
     $data['minmultiplefromplan'] = false;
     $data['maxgfafromplan'] = false;
     $data['maxdensityfromplan'] = false;
     $data['maxcoverfromplan'] = false;
     $data['maxheightfromoverlay'] = false;
     $data['minfromoverlay'] = false;
     $data['minmultiplefromoverlay'] = false;
     $data['maxgfafromoverlay'] = false;
     $data['maxdensityfromoverlay'] = false;
     $data['maxcoverfromoverlay'] = false;
     if ($precinctid > 0) {
         $precinctfields = profilef::profilegetdetailfields($precinctid);
         $data['precinct'] = $precinctfields['field_name'];
         profilef::profilegroupoverride($data, $precinctfields, array('maxheight', 'maxstorey'), 'heightinfo', 'maxheightfromplan', 'maxheightfromzone');
         profilef::profilegroupoverride($data, $precinctfields, array('min', 'minfrontage'), 'lotinfo', 'minfromplan', 'minfromzone');
         profilef::profilegroupoverride($data, $precinctfields, array('minmultiple', 'minmultiplefrontage'), 'lotmultipleinfo', 'minmultiplefromplan', 'minmultiplefromzone');
         profilef::profilegroupoverride($data, $precinctfields, 'maxgfa', 'gfainfo', 'maxgfafromplan', 'maxgfafromzone');
         profilef::profilegroupoverride($data, $precinctfields, 'maxdensity', 'densityinfo', 'maxdensityfromplan', 'maxdensityfromzone');
         profilef::profilegroupoverride($data, $precinctfields, 'maxcover', 'coverinfo', 'maxcoverfromplan', 'maxcoverfromzone');
         foreach ($generaltextfields as $textfield) {
             if (isset($precinctfields['field_' . $textfield])) {
                 $text = trim($precinctfields['field_' . $textfield]);
                 if (!empty($text)) {
                     $data[$textfield] = $text;
                     $data[$textfield . 'fromzone'] = false;
                     $data[$textfield . 'fromplan'] = true;
                 }
             }
         }
     }
     $data['overlays'] = array();
     $orphantext = array();
     if (!empty($overlayidsnew)) {
         $mergekeys = array(array('heightinfo', 'storeyinfo'), array('lotinfo', 'frontagelotinfo'), array('lotmultipleinfo', 'frontagelotmultipleinfo'));
         foreach ($overlayidsnew as $overlayid) {
             $overlayfields = profilef::profilegetdetailfields($overlayid);
             $overlayname = $overlayfields['field_name'];
             $data['overlays'][] = array($overlayname, $overlayfields['field_overlayinfo']);
             foreach ($mergekeys as $mergekeyspair) {
                 $overlayfields['field_' . $mergekeyspair[1]] = $overlayfields['field_' . $mergekeyspair[0]];
             }
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'maxheight', true, 'heightinfo');
             //,'maxstorey'
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'min', false, 'lotinfo');
             //,'minfrontage'
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'minmultiple', false, 'lotmultipleinfo');
             //,'minmultiplefrontage'
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'maxstorey', true, 'storeyinfo');
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'minfrontage', false, 'frontagelotinfo');
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'minmultiplefrontage', false, 'frontagelotmultipleinfo');
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'maxgfa', true, 'gfainfo');
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'maxdensity', true, 'densityinfo');
             profilef::profilegroupoverlayoverride($overlaydata, $overlayfields, $orphantext, 'maxcover', true, 'coverinfo');
             foreach ($mergekeys as $mergekeyspair) {
                 $test = trim($overlaydata['field_' . $mergekeyspair[0]]);
                 if (empty($test)) {
                     $test = trim($overlaydata['field_' . $mergekeyspair[1]]);
                     if (!empty($test)) {
                         $overlaydata['field_' . $mergekeyspair[0]] = $test;
                     }
                 }
                 unset($overlaydata['field_' . $mergekeyspair[1]]);
             }
             foreach ($generaltextfields as $textfield) {
                 if (isset($overlayfields['field_' . $textfield])) {
                     $text = trim($overlayfields['field_' . $textfield]);
                     if (!empty($text)) {
                         $texttest = trim($overlaydata['field_' . $textfield] . '');
                         if (!empty($texttest)) {
                             $overlaydata['field_' . $textfield] .= "\n\n" . $text;
                         } else {
                             $overlaydata['field_' . $textfield] = $text;
                         }
                     }
                 }
             }
             //$primarynumfield,$ismax=false,$textfields=array(),$numfields=array(),$setfields=array(),$clearfields=array()
             /*profilef::profilegroupoverlayoverride($data,$overlayfields,'maxheight',true,'heightinfo','maxstorey','maxheightfromoverlay',array('maxheightfromplan','maxheightfromzone'));
             		profilef::profilegroupoverlayoverride($data,$overlayfields,'min',false,'lotinfo','minfrontage','minfromoverlay',array('minfromplan','minfromzone'));
             		profilef::profilegroupoverlayoverride($data,$overlayfields,'minmultiple',false,'lotmultipleinfo','minmultiplefrontage','minmultiplefromoverlay',array('minmultiplefromplan','minmultiplefromzone'));
             		profilef::profilegroupoverlayoverride($data,$overlayfields,'maxgfa',true,'gfainfo','maxgfafromoverlay',array('maxgfafromplan','maxgfafromzone'));
             		profilef::profilegroupoverlayoverride($data,$overlayfields,'maxdensity',true,'densityinfo','maxdensityfromoverlay',array('maxdensityfromplan','maxdensityfromzone'));
             		profilef::profilegroupoverlayoverride($data,$overlayfields,'maxcover',true,'coverinfo','maxcoverfromoverlay',array('maxcoverfromplan','maxcoverfromzone'));
             		foreach($generaltextfields as $textfield) {
             			if(isset($overlayfields['field_'.$textfield])) {
             				$text=trim($overlayfields['field_'.$textfield]);
             				if(!empty($text)) {
             					$data[$textfield]=$text;
             					$data[$textfield.'fromzone']=false;
             					$data[$textfield.'fromplan']=false;
             					$data[$textfield.'fromoverlay']=true;
             				}
             			}
             		}*/
         }
         foreach ($mergekeys as $mergekeyspair) {
             if (isset($orphantext[$mergekeyspair[1]])) {
                 $test = trim($orphantext[$mergekeyspair[0]]);
                 if (empty($test)) {
                     $test = trim($orphantext[$mergekeyspair[1]]);
                     if (!empty($test)) {
                         $orphantext[$mergekeyspair[0]] = $test;
                     }
                 }
                 unset($orphantext[$mergekeyspair[1]]);
             }
         }
         $basictextf = array('heightinfo', 'lotinfo', 'lotmultipleinfo', 'gfainfo', 'densityinfo', 'coverinfo');
         foreach ($basictextf as $textfield) {
             if (isset($orphantext[$textfield])) {
                 $test = trim($overlaydata['field_' . $textfield]);
                 if (empty($test)) {
                     $overlaydata['field_' . $textfield] = $orphantext[$textfield];
                 }
             }
         }
         //foreach
         profilef::profilegroupoverride($data, $overlaydata, array('maxheight', 'maxstorey'), 'heightinfo', 'maxheightfromoverlay', array('maxheightfromplan', 'maxheightfromzone'));
         profilef::profilegroupoverride($data, $overlaydata, array('min', 'minfrontage'), 'lotinfo', 'minfromoverlay', array('minfromplan', 'minfromzone'));
         profilef::profilegroupoverride($data, $overlaydata, array('minmultiple', 'minmultiplefrontage'), 'lotmultipleinfo', 'minmultiplefromoverlay', array('minmultiplefromplan', 'minmultiplefromzone'));
         profilef::profilegroupoverride($data, $overlaydata, 'maxgfa', 'gfainfo', 'maxgfafromoverlay', array('maxgfafromplan', 'maxgfafromzone'));
         profilef::profilegroupoverride($data, $overlaydata, 'maxdensity', 'densityinfo', 'maxdensityfromoverlay', array('maxdensityfromplan', 'maxdensityfromzone'));
         profilef::profilegroupoverride($data, $overlaydata, 'maxcover', 'coverinfo', 'maxcoverfromoverlay', array('maxcoverfromplan', 'maxcoverfromzone'));
         foreach ($generaltextfields as $textfield) {
             if (isset($overlaydata['field_' . $textfield])) {
                 $text = trim($overlaydata['field_' . $textfield]);
                 if (!empty($text)) {
                     $data[$textfield] = $text;
                     $data[$textfield . 'fromzone'] = false;
                     $data[$textfield . 'fromplan'] = false;
                     $data[$textfield . 'fromoverlay'] = true;
                 }
             }
         }
     }
     //echo '<!-- '.str_replace('-->','- - >',print_r($overlayidsnew,true).print_r($overlayfields,true)).$overlayid.' -->';
     return $data;
 }