Example #1
0
 public function addNewbuilding($parentid) {
  addtolog("Model addNewBuilding begin");
  $sql="
   INSERT INTO `newbuildings_subitems`
    (`ParentID`)
   VALUES
    ('".$parentid."')
   ; 
  ";
  $ret=$this->db->exec($sql);
  $ret=$this->addEvent('NewbuildingAdded','newbuildings_subitems','ParentID',$parentid,$ret->lastInsertID);
  
  addtolog("Model addNewBuilding end");
 }
Example #2
0
 public function import() {                         // import functionality to get data from ISCentre
  addtolog("Controller import begin");
  include_once ("controller/DBImport.php");
  $this->dbimport = new DBImport($this->settings);  // instantiate a class
  
  $action = getvariablereq   ('action');            // get action from the request
  $data   = getvariablereq   ('data'  );            // get JSON data from the request
  
  $data = str_replace('\"','"',$data);              // fix some escaped paths (if any)
  
  $mtime = microtime(true);
  $thisfolder = substr($_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_NAME'],0,strrpos($_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_NAME'] ,"/"))."/data/temp/dbupdate";
  @mkdirr ($thisfolder);
  
  switch ($action) {
   case ('update'):
    $this->dbimport->importtables($thisfolder);
    echo "Job done\n";
   break;
   default:
    if (sizeof($_FILES)>0) {
     foreach ($_FILES as $file) {
      if (file_exists($thisfolder."/".$file['name'])) {
       unlink($thisfolder."/".$file['name']);
      }
      move_uploaded_file ($file['tmp_name'],$thisfolder."/".$file['name']);
      echo "File accepted";
     }
    }
   break;
  }
  
  $fieldid = array();
  
  addtolog("Controller import end");
 }