public function location()
 {
     //grab the location values from the systemref table
     $q = Doctrine_Query::create()->select('s.name')->from('SystemRef s')->where("s.refType = 'location'");
     $q->execute();
     $result = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
     //Check for existing record
     $q2 = Doctrine_Query::create()->select('l.orgID')->from('LocationValue l')->where("l.orgID = ?", $this->getOrgID());
     $q2->execute();
     if ($result2 = $q2->execute(array(), Doctrine::HYDRATE_ARRAY)) {
     } else {
         //insert values into the location table
         foreach ($result as $key => $value) {
             //return $key."-".$value['name'];
             //insert into location value table
             $location = new LocationValue();
             $location->orgID = $this->getOrgID();
             $location->locationName = $value['name'];
             $location->isActive = 1;
             $location->rTime = $this->getDateFormat();
             $location->rUser = $this->getUserID();
             $location->save();
         }
     }
 }
 /**
  * @remotable
  */
 public function defaultLocationSetup()
 {
     //grab the location values from the systemref table
     $q = Doctrine_Query::create()->select('s.name')->from('SystemRef s')->where("s.refType = 'location'");
     $q->execute();
     $result = $q->execute(array(), Doctrine::HYDRATE_ARRAY);
     //insert values into the location table
     foreach ($result as $key => $value) {
         //return $key."-".$value['name'];
         //insert into location value table
         $location = new LocationValue();
         $location->orgID = 16;
         $location->locationName = $value['name'];
         $location->isActive = 1;
         $location->rTime = date("d/m/y : H:i:s", time());
         $location->rUser = $this->getUserID();
         $location->save();
     }
 }