<?php      
/*=======================================================================
 *
 * cron_export.php
 *
  =======================================================================*/


include_once ("../include/mcglobal.inc.php");

if ($argv[1] == "acapella7890") :

   $path = getAbsoluteSystemPath();
   $passwd = "acapella7890";
   $emptyArgument = "\"\"";
   $fileNamePrefix = substr(getDateTime("6"), 0, 12);  // eq. "YmdHi"
   
   if ($argv[2] == "today") :
      $toDay = getDateTime("day");   
      $toMonth = getDateTime("month");
      $toYear = getDateTime("year");
   else :
      $toDay = getDateTime("day_yesterday");   
      $toMonth = getDateTime("month_yesterday");
      $toYear = getDateTime("year_yesterday");
   endif;
   
   // Arguments
   // $hq_id $usr_id $dummy_01 $f_act $f_exp_category $f_delimiter $f_parname $f_parname_export $f_fileName $day_to $month_to $year_to $f_cs_eid_filter $f_jbp_filter $specialJbPayment $jbpc_id
   
   $exportPars = array();
   $exportPars["HTM_HTHH_ABR"] = array("1020","18086","_","export","5","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.abr",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001028");
   $exportPars["HTM_HTHH_GUT"] = array("1020","18086","_","export","6","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.gut",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001029");
     
   /*
   $exportParsKeys = array_keys($exportPars);
   $exportParsKeysLen = count($exportParsKeys);
   for ($i = 0; $i < $maskDisplayedArrayLen; $i++) :
   
       list($hq_id,$usr_id,$dummy_01,$f_act,$f_exp_category,$f_delimiter,$f_parname,$f_parname_export,$f_fileName,
            $day_to,$month_to,$year_to,$f_cs_eid_filter,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars[$exportParsKeys[$i]];
   
       $cmd = "php " . $path . "/export/export.php " . $passwd . " " . $hq_id . " " . $usr_id . " " . $dummy_01 . " " . $f_act . " " . $aaaa . " " . $aaaa . " " . $aaaa . " " . $aaaa . " &";
       $cmdOutput = null;
       exec($cmd, $cmdOutput);
   
       // list($errNo, $errDesc) = $cmdOutput;
   endfor;
   */
   
   
   // TEST
   
   list($hq_id,$usr_id,$dummy_01,$f_act,$f_exp_category,$f_delimiter,$f_parname,$f_parname_export,$f_fileName,
        $day_to,$month_to,$year_to,$f_cs_eid_filter,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_ABR"];
   
   $cmd = "php " . $path . "/export/export.php " . $passwd . " " . $hq_id . " " . $usr_id . " " . $dummy_01 . " " . $f_act . " " . $f_exp_category . " " . "\"" . $f_delimiter. "\"" . " " 
                                                 . "\"" . $f_parname . "\"" . " " . "\"" . $f_parname_export . "\"" . " " . "\"" . $f_fileName . "\"" . " " . $day_to . " " . $month_to . " " . $year_to . " " 
                                                 . $f_cs_eid_filter . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
   echo $cmd . "\n";
   $cmdOutput = null;
   exec($cmd, $cmdOutput);

   list($hq_id,$usr_id,$dummy_01,$f_act,$f_exp_category,$f_delimiter,$f_parname,$f_parname_export,$f_fileName,
        $day_to,$month_to,$year_to,$f_cs_eid_filter,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_GUT"];
   
   $cmd = "php " . $path . "/export/export.php " . $passwd . " " . $hq_id . " " . $usr_id . " " . $dummy_01 . " " . $f_act . " " . $f_exp_category . " " . "\"" . $f_delimiter. "\"" . " " 
                                                 . "\"" . $f_parname . "\"" . " " . "\"" . $f_parname_export . "\"" . " " . "\"" . $f_fileName . "\"" . " " . $day_to . " " . $month_to . " " . $year_to . " " 
                                                 . $f_cs_eid_filter . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
   echo $cmd . "\n";
   $cmdOutput = null;
   exec($cmd, $cmdOutput);

endif;      
?>