<?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");

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "1";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10224";
   $f_jbp_filter = "4";   // EXPORT_CAT_09_JBPMODES_04_GRP_11 => Payment mode "16"
   $exportPars["HTM_WAST_UMS_16"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "2";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10224";
   $f_jbp_filter = "5";   // EXPORT_CAT_09_JBPMODES_05_GRP_11 => Payment mode "17"
   $exportPars["HTM_WAST_UMS_17"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");   

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "3";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10224";
   $f_jbp_filter = "6";   // EXPORT_CAT_09_JBPMODES_06_GRP_11 => Payment mode "18"
   $exportPars["HTM_WAST_UMS_18"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "4";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10224";
   $f_jbp_filter = "7";   // EXPORT_CAT_09_JBPMODES_07_GRP_11 => Payment mode "19"
   $exportPars["HTM_WAST_UMS_19"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");


   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "5";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10225";
   $f_jbp_filter = "4";   // EXPORT_CAT_09_JBPMODES_04_GRP_11 => Payment mode "16"
   $exportPars["HTM_WAST_UMS_16_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "6";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10225";
   $f_jbp_filter = "5";   // EXPORT_CAT_09_JBPMODES_05_GRP_11 => Payment mode "17"
   $exportPars["HTM_WAST_UMS_17_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");   

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "7";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10225";
   $f_jbp_filter = "6";   // EXPORT_CAT_09_JBPMODES_06_GRP_11 => Payment mode "18"
   $exportPars["HTM_WAST_UMS_18_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");

   $fileNamePrefix = substr(getDateTime("6"), 0, 11) . "8";  // eq. "YmdHi"
   $f_cs_eid_filter = "WAST10225";
   $f_jbp_filter = "7";   // EXPORT_CAT_09_JBPMODES_07_GRP_11 => Payment mode "19"
   $exportPars["HTM_WAST_UMS_19_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");

   $exportParsKeys = array_keys($exportPars);
   $exportParsKeysLen = count($exportParsKeys);
   for ($i = 0; $i < $exportParsKeysLen; $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 . " " . $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($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;      
?>