#!/usr/bin/php
<?php

//require 'vendor/autoload.php';
require("../config/config.php");

define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));

require_once(LIBDIR."/mvcfronk/mfRouter/mfRouter.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseModel.php");
require_once(LIBDIR."/mvcfronk/mfBase/mfBaseController.php");

$me = new User(1);


$buildings = BuildingModel::search(['status_id' => 1]);


echo TT_WORKFLOW_ITEM_STATUS_FIELD."\n";
echo TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED."\n";
echo TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED."\n";

foreach($buildings as $building) {
  if(array_key_exists(TT_WORKFLOW_ITEM_STATUS_FIELD, $building->workflowitems)) {
    if($building->workflowitems[TT_WORKFLOW_ITEM_STATUS_FIELD]->value->value_string == TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED) {
      echo TT_WORKFLOW_ITEM_STATUS_VALUE_PASSED." (4) ".$building->id."\n";
      //$building->status_id = 4;
      //$building->save();
    }
    if($building->workflowitems[TT_WORKFLOW_ITEM_STATUS_FIELD]->value->value_string == TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED) {
      echo TT_WORKFLOW_ITEM_STATUS_VALUE_CONNECTED." (5) ".$building->id."\n";
      //$building->status_id = 5;
      //$building->save();
    }
  }
}