<?php
   //20150825 - Split cronjob into 8 cronjobs and change process to handle multiple cronjobs running on the same data. - chris
   //20160610 - NemoFIM - pj/gael/CL
   //20170511 - New Controller for the FIM -  Gael.

   include_once("_framework/_nemo.cls.php");
   include_once("_framework/_nemo.list.cls.php");
   include_once("_framework/_nemo.email.cls.php");
   include_once("_framework/_nemo.fim.cls.php");


   $page = new NemoBasic();
   print_rr($_REQUEST);


   ini_set('display_errors', '1');
   //fix for php ending before entire import is done; http://www.rajamm.info/2008/09/22/magic-with-htaccess-file-increase-execution-time-session-expiry-time-and-file-upload-size-limit/
   ini_set('max_execution_time', 1200);
   ini_set("memory_limit","256M"); //fix for memory limit exceeded.

   $ID = $_REQUEST["ID"];
   $state = $_REQUEST["state"];
   $Action = $_REQUEST["Action"];


   switch($Action)
   {
      case "FIM: PULL MASTER DATA":
         break;

      case "FIM: RESET MASTER":
         NemoFIM::ResetMaster();
         die($Action);
         break;

      case "FIM: IGNORE":
         NemoFIM::Ignore($ID, $state);
         die($Action);
         break;

      case "FIM: UPDATE":
         NemoFIM::Update($ID, $state);
         die($Action);
         break;
   }


   switch($Action)
   {
      default:
         global $xdb, $HTTP, $db, $MYSQLI;
         //20160610 - NemoFIM - pj/gael/CL
         $fim = new NemoFIM();
         //1 - record local data/file permissions, etc.
         $xdb->doQuery("DELETE FROM `sysAudit_". $DATABASE_SETTINGS[$_SERVER[SERVER_NAME]]->environment ."` WHERE dtAudit = LEFT(NOW(),10)", 1);

         $result = $fim->Record($result);

         //2 - pull live data to Dev/QA
         //$result = $fim->PullData("www.knowmore.co.za"); //n/a
         //vd($result);
         //3 - comapre MASTER - $ENV data
         $fim->Compare();

         //x - set Permissions LIVE
         $result = $fim->iniSetPermissions($result);
         //print_rr($result);
      break;
   }
//die("lknsdf");
?>