#!/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);

$db = FronkDB::singleton();

$res = $db->select("OrderProduct", "id", "price_nne = 0 AND price_nbe = 0");
if(!$db->num_rows($res)) {
  exit;
}

while($data = $db->fetch_object($res)) {
  $op = new OrderProduct($data->id);
  
  
  
  if(!($op->product->price_nne > 0) && !($op->product->price_nbe > 0)) {
    //echo "nope\n";
    continue;
  }
  
  echo $op->product->name."\n    ".$op->price_nne. " ".$op->price_nbe." -> ".$op->product->price_nne." ".$op->product->price_nbe."\n";
  
  //continue;
  $op->price_nne = $op->product->price_nne;
  $op->price_nbe = $op->product->price_nbe;
  $op->save();
}
