<?php
/*=======================================================================
 *
 * import_JOBARTICLE.php
 *
 * Autor: Marc Vollmann
 *
 =======================================================================*/

include_once ("../import/import.php");
include_once ("../include/inc_vehicle.inc.php");
include_once ("../include/inc_job.inc.php");


// Execution-Time for script
set_time_limit(0);


// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "statusMessage", "importFile", "executeImportProcess", "deactivateMenu", "objType", "objId"));


getLanguage(__FILE__);

$deactivateMenuStatic = "1";
$pageTitel = getLngt("IMPORT AUFTRAGSARTIKEL");
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
getCurrentScript(__FILE__);

// Check for authentication access
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
if (!(authCheckEmployeeRights($emp_id, "22"))) : gotoReferer("1"); endif;

$empHasAdminRights = false;
$empIdRootAdmin = getEmpIdOfRootAdmin($userTypeName);
if ($empIdRootAdmin != "" && $emp_id == $empIdRootAdmin) : 
   $empHasAdminRights = true;
endif;
$debug = false;
if ($empIdRootAdmin == $emp_id) :
   $debug = false;
endif;

if ($f_act != "executeImport" || $executeImportProcess != "1") : $executeImportProcess = ""; endif;    // Execute import after check run
$showExecutionProcessButton = true;
$outText = "";
$closeWindow = "0";
$delimiter = ";";
$fire = true;


// Set headquarters to import jobs
$hqId = $objId;
if ($hqId == "") : $hqId = $hq_id; endif;

$tratSort = 1;
$remJbId = "";

$f_jb_id_addM = $db->getOne("SELECT MAX(jb_id) FROM job WHERE (jb_id > 265000 AND jb_id < 270000)");
if ($f_jb_id_addM == "")
  $f_jb_id_addM = 265001;
else
  $f_jb_id_addM++;

// Current file to be imported
$importFile = urldecode($importFile);
$posLastSlash = strripos($importFile, "/");
$posLastSlash++;
$pathname = substr($importFile, 0, $posLastSlash);
$filename = substr($importFile, $posLastSlash);
$outText = "<span class=\"f10bp1_blue\">" . getLngt("IMPORTDATEI:") . "</span>&nbsp;" . $filename . "<br><br>";



if ($importFile != "" && $hqId != "" && is_numeric($hqId)) :

   if (file_exists($importFile)) :

      $currentTime = getDateTime("0");


      // ***********************
      // * IMPORT FILE article *
      // ***********************
      if (!(strpos($filename, "import_JOBARTICLE_") === false)) :

         $executionCount = 0;
         $insertCount = 0;
         $updateCount = 0;
         $failedCount = 0;

         $rowToImport = array();
         
         $parImportArticleFieldsGroup == "";
         if ($groupId != "") :
            $parImportArticleFieldsGroup = getParameterValue("0", "IMPORT_JOBARTICLE_FIELDS", "0");
         endif;
         if ($parImportArticleFieldsGroup != "") :
            $rowToImport = spliti(",", $parImportArticleFieldsGroup);
         else :
            // Default 
            $rowToImport[0]  = "f_jb_id";                // Job ID, "KV-Nr."
            $rowToImport[1]  = "f_jb_dummy_01";          // ????
            $rowToImport[2]  = "f_at_name";              // Article number (name)
            $rowToImport[3]  = "f_at_description";       // Article description
            $rowToImport[4]  = "f_at_price";             // Article price
            $rowToImport[5]  = "f_trat_price";           // Tourarticle price
            $rowToImport[6]  = "f_trat_quantity";        // Tourarticle quantity
            $rowToImport[7]  = "f_stock";                // Stock information
            $rowToImport[8]  = "f_stock_name";           // Stock information
            $rowToImport[9]  = "f_inst_mode";            // Versandart (NUMERISCH) ("Lieferung IKEA" [= 51], "Austausch" [= 57], "Lieferung + Sofa-Montage IKEA" [= 53], "Lieferung + Montage IKEA" [= 52])
            $rowToImport[10]  = "f_trat_remark";         // Remark ("Lieferung, Montage, Abholung, ...")
            $rowToImport[11]  = "f_inst_timeunits";      // Zusatzmontage
            $rowToImport[12]  = "f_trat_packingpieces";  // Customer delivery.address.floor
            $rowToImport[13]  = "f_dummy";               // Dummy
         endif;

         $rowToImportLen = count($rowToImport);

         // Read file to import
         $data = importCSV($importFile, $delimiter);
         $dataLen = count($data);

         // Loop all rows (EXCEPT header row [$j = 1])
         for ($j = 0; $j < $dataLen; $j++) {

            // Loop for all fields of $fields of the row
            for ($i = 0; $i < $rowToImportLen; $i++) {
                ${$rowToImport[$i]} = $data[$j][$i];
            }


            $f_jb_id = removeFieldSigns($f_jb_id);
            $f_at_name = removeFieldSigns($f_at_name);
            $f_at_description = removeFieldSigns($f_at_description);
            $f_at_price = removeFieldSigns($f_at_price);
              $f_at_price = str_replace (",", ".", $f_at_price);
            $f_trat_price = removeFieldSigns($f_trat_price);
              $f_trat_price = str_replace (",", ".", $f_trat_price);
            $f_trat_quantity = removeFieldSigns($f_trat_quantity);
              $f_trat_quantity = str_replace (",", ".", $f_trat_quantity);
            $f_stock = removeFieldSigns($f_stock);
            $f_stock_name = removeFieldSigns($f_stock_name);
            $f_inst_mode = removeFieldSigns($f_inst_mode);
            $f_trat_remark = removeFieldSigns($f_trat_remark);
              $gdcTratInstallation = $f_trat_remark;  // TEXT ZUR "VERSANDART" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
              $f_trat_remark = $f_at_description;  // !!!!
            $f_inst_timeunits = removeFieldSigns($f_inst_timeunits);
            $f_trat_packingpieces = removeFieldSigns($f_trat_packingpieces);

            if ($remJbId != $f_jb_id) :
               $tratSort = 1;
               $remJbId = $f_jb_id;
               
               // Init job services regarding article
               $jbServiceDel = 0;
               $jbServiceInst = 0;
               
               // Init job has no addmont
               $jbHasAddmont = false;
            endif;

            // "Addmont"            
            if ($f_at_name == "80100" && $f_inst_timeunits != "" && is_numeric($f_inst_timeunits)) :
echo "ZM-Std.: " . $f_inst_timeunits . " => ";
               $f_inst_timeunits = round(round(round($f_inst_timeunits / 12, 1) * 2) / 2, 1);
echo $f_inst_timeunits . "<br>";

               $jbHasAddmont = true;
            else :
               $f_inst_timeunits = 0;
            endif;

            // Article is delivery AND installation
            $articleIsDelvAndInst = false;
            if ($f_inst_mode == "52" || $f_inst_mode == "56" || $f_inst_mode == "58") :
               $articleIsDelvAndInst = true;
            endif;

            // Article is "sofa-montage"
            $articleIsCouchInstallation = false;
            if ($f_inst_mode == "53") :
               $articleIsCouchInstallation = true;
            endif;

            $installationOnly = false;
            if ($f_inst_mode == "54") :
               $installationOnly = true;
            endif;

            // "Versandart" (NUMERISCH) 
            // ("Lieferung IKEA" [= 51], "Austausch" [= 57], "Lieferung + Sofa-Montage IKEA" [= 53], 
            //  "Lieferung + Montage IKEA" [= 52], "Montage" [= 54], "Abholung und Demontage" [= 56], "Austausch und Montage" [= 58])
            if ($f_inst_mode == "52" || $f_inst_mode == "54" || $f_inst_mode == "56" || $f_inst_mode == "58") :
            
               // Set job services
               if ($f_inst_mode == "56") :
                  (int)$jbServiceInst = ((int)$jbServiceInst | 128);
               endif;
               if ($f_inst_mode == "58") :
                  (int)$jbServiceInst = ((int)$jbServiceInst | 256);
               endif;
            
               $f_inst_mode = "1";
            else :

               // Set job services
               if ($f_inst_mode == "57") :
                  (int)$jbServiceDel = ((int)$jbServiceDel | 256);
               endif;

               $f_inst_mode = "0";
            endif;
            


            if (true) :

               // Insert new article
               if ($fire && $executeImportProcess == "1") :

                  TA("B");

                  if ($articleIsDelvAndInst || $f_inst_mode == "0" || $installationOnly) :

                     if (existsEntry("job",array("jb_id",$f_jb_id))) :
                     
                        // Search article
                        $atId = getFieldValueFromId("article", "at_name", $f_at_name, "at_id");

                        // if ($atId != "") :
                     
                           // Insert into table "tourarticle"
                           insertStmt("tourarticle", array("jb_id", $f_jb_id, "tr_sort", "2", "trat_sort", $tratSort, 
                                      "at_id", $atId, "trat_quantity", $f_trat_quantity, "trat_weight", "", "trat_price", $f_trat_price,
                                      "trat_packingpieces", $f_trat_packingpieces, "trat_remark", $f_trat_remark));
                     
                           $tratIdNew = getLastInsertId();

                           if ($tratIdNew != "") :

                              // Insert article installation mode ("Lieferung IKEA" [= 51], "Austausch" [= 57], etc)
                              if ($articleIsCouchInstallation) :
                                 $gdcContentAddInfo = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'jb' AND gdc_obj_id = '" . $f_jb_id . "' AND gdc_gen_fieldname = 'jb_addinfo'");
                                 if ($gdcContentAddInfo == "") :
                                    insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $f_jb_id, "gdc_gen_fieldname", "jb_addinfo", "gdc_content", "ACHTUNG: Sofa-Montage", "gdc_context", ""));
                                 endif;
                              endif;

                              $tratSort++;

                              $executionCount++;

                              // Update jb_service
                              if ($installationOnly) :                              
                                 (int)$jbServiceDel = ((int)$jbServiceDel | 2);
                              endif;

                              $jbService = getFieldValueFromId("job", "jb_id", $f_jb_id, "jb_service");
                              (int)$jbServiceDel = ((int)$jbServiceDel | (int)$jbService);
                              updateStmt("job", "jb_id", $f_jb_id, array("jb_service", $jbServiceDel));

                           else :
                              $outText .= getLngt("TOURARTICLE WURDE NICHT ANGELEGT!") . " [JOB " . $f_jb_id . "]<br>";
                           endif;
                     
                        // else :
                        //    $outText .= getLngt("ARTIKEL NICHT IM ARTIKELSTAMM!") . " [JOB " . $f_jb_id . "]<br>";
                        // endif;
                        if ($atId == "") : $outText .= getLngt("ARTIKEL NICHT IM ARTIKELSTAMM!") . " [JOB " . $f_jb_id . " | NR.: " . $f_at_name . " | ARTIKELTEXT : " . $f_trat_remark . "]<br>"; endif;
                     else :
                        $outText .= getLngt("AUFTRAG /1 EXISTIERT NICHT!") . " [JOB " . $f_jb_id . "]<br>";
                     endif;
                  endif;

// ----
                  if ($articleIsDelvAndInst) :
                     $f_jb_id_M = getFieldValueFromId("job","jb_id_parent",$f_jb_id,"jb_id");
                        // Search article
                        $atId = getFieldValueFromId("article", "at_name", $f_at_name, "at_id");
                        // if ($atId != "") :
                           // Insert into table "tourarticle"
                           insertStmt("tourarticle", array("jb_id", $f_jb_id_M, "tr_sort", "2", "trat_sort", $tratSort, 
                                      "at_id", $atId, "trat_quantity", $f_trat_quantity, "trat_weight", "", "trat_price", $f_trat_price,
                                      "trat_packingpieces", $f_trat_packingpieces, "trat_remark", $f_trat_remark));
                     
                           $tratIdNew = getLastInsertId();
                     
                           if ($tratIdNew != "") :
                     
                              // Insert article installation mode ("Lieferung IKEA" [= 51], "Austausch" [= 57], etc)
                              // insertStmt("genericdatacontainer", array("gdc_obj_type", "trat", "gdc_obj_id", $tratIdNew, "gdc_gen_fieldname", "sofa-montage", "gdc_content", $f_inst_mode, "gdc_context", $gdcTratInstallation));
                     
                              $tratSort++;
                              
                              $executionCount++;

                              // Update jb_service
                              $jbService = getFieldValueFromId("job", "jb_id", $f_jb_id_M, "jb_service");
                              (int)$jbServiceInst = ((int)$jbServiceInst | (int)$jbService);
                              updateStmt("job", "jb_id", $f_jb_id_M, array("jb_service", $jbServiceInst));

                           else :
                              $outText .= getLngt("TOURARTICLE WURDE NICHT ANGELEGT!") . " [JOB " . $f_jb_id_M . "]<br>";
                           endif;
                     
                        // else :
                        //    $outText .= getLngt("ARTIKEL NICHT IM ARTIKELSTAMM!") . " [JOB " . $f_jb_id_M . "]<br>";
                        // endif;
                        if ($atId == "") : $outText .= getLngt("ARTIKEL NICHT IM ARTIKELSTAMM!") . " [JOB " . $f_jb_id_M . " | NR.: " . $f_at_name . " | ARTIKELTEXT : " . $f_trat_remark . "]<br>"; endif;
                  else:
                     $f_jb_id_M = $f_jb_id;
                  endif;

                 
                  if ($jbHasAddmont) :
// ----

                  // ($jbHasAddmont && $f_inst_mode == "0") <=> Delivery only but addmont does exist!
                  // if ($articleIsDelvAndInst || $f_inst_mode == "1" || ($jbHasAddmont && $f_inst_mode == "0")) :

//                     $f_jb_id_M = getFieldValueFromId("job","jb_id_parent",$f_jb_id,"jb_id");
                     
// **** NEW (START) ****
// Job could not exist because JOB IMPORT had delivery job only but added installation is in article !!!!

                     // if (($jbHasAddmont && $f_inst_mode == "0") && !existsEntry("job",array("jb_id",$f_jb_id_M))) :
//                     if ($jbHasAddmont && $f_jb_id_M != "" && !existsEntry("job",array("jb_id",$f_jb_id_addM))) :
                    if ($f_jb_id_M == ""):
                                          
                        $csc_id_new = getFieldValueFromId("job","jb_id",$f_jb_id,"csc_id");
                        $vhtId = getFieldValueFromId("job","jb_id",$f_jb_id,"vht_id");
                        $csc_id_new = getFieldValueFromId("job","jb_id",$f_jb_id,"csc_id_payer");
                        $cscIdRelated = getFieldValueFromId("job","jb_id",$f_jb_id,"csc_id_related");
                        $f_jb_ordertime = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_ordertime");
                        $crId = getFieldValueFromId("job","jb_id",$f_jb_id,"cr_id");
                        $crSid = getFieldValueFromId("job","jb_id",$f_jb_id,"cr_sid");
                        $jbCrFilter = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_cr_filter");
                        $usr_id = getFieldValueFromId("job","jb_id",$f_jb_id,"emp_id");
                        $csInvmode = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_invmode");
                        $srvzId = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_mediationarea_id");
                        $srvzName = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_mediationarea_name");
                        $jbRemark = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_freetext_1");
                        $jbTourdata = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_tourdata");
                        $txValue = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_sales_tax_rate");
                        $txSign = getFieldValueFromId("job","jb_id",$f_jb_id,"jb_sales_tax_rate_sign");

                        $jbTimeUnits_M = "2";
                        $jbService_M = "2";

                        $sum_totalprice_M = "0";
                        $f_jb_cr_price_M = "0";

                        insertStmt("job", array("jb_id", $f_jb_id_addM, "hq_id", $hqId, "csc_id", $csc_id_new, "vht_id", $vhtId, "csc_id_payer", $csc_id_new, "csc_id_related", $cscIdRelated, "jb_payment", "0",
                                                "jb_ordertime", $f_jb_ordertime, "jb_reserv", "0", "cr_id", $crId, "cr_sid", $crSid, "cr_id_order", $crId,
                                                "jb_cr_filter", $jbCrFilter, "jb_cr_filter_opt", "", "jb_waitstorno", "0", 
                                                "jb_taketime", "", "jb_status", $jbStatus, "jb_autoranking", "0", "jb_type", $jbType, 
                                                "jb_incomplete", "0", "jb_globaljob", "0", "jb_tourname", $jbTourname,
                                                "jb_finishtime", $jbFinishtime, "emp_id", $usr_id, 
                                                "jb_serviceprice", "0", "jb_fixprice", $sum_totalprice_M, "jb_totalprice", $sum_totalprice_M, "jb_subtotalprice", $sum_totalprice_M, 
                                                "jb_cr_price", $f_jb_cr_price_M, "jb_cr_subprice", $f_jb_cr_price_M,
                                                "jb_postage", "0", "jb_invmode", $csInvmode, "jb_mediationarea_id", $srvzId, "jb_mediationarea_name", $srvzName,
                                                "jb_freetext_1", $jbRemark,
                                                "jb_weight", $jbCrvhWeight, "jb_crvh_length", $jbCrvhLength, "jb_crvh_width", $jbCrvhWidth, 
                                                "jb_crvh_height", $jbCrvhHeight, "jb_crvh_position", $jbCrvhPosition, 
                                                "jb_tourdata", $jbTourdata, "jb_lockuser", "0", "jb_id_parent", $f_jb_id, "jb_dispoinfo", "",
                                                "jb_sales_tax_rate", $txValue, "jb_sales_tax_rate_sign", $txSign, "jb_timeunits", $jbTimeUnits_M, 
                                                "jb_service", $jbService_M, "jb_booktime", ""));
                        // $jbIdNew = getLastInsertId();
                        $jbIdNew = $f_jb_id_addM;  // Take existing job ID from import file
                        $outText .= "JB_ID_INST : " . $jbIdNew . "<br>";
                        
                        $tr1_adId = getFieldValueFromClause("tour", "ad_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
                        $tr1_comp = getFieldValueFromClause("tour", "tr_comp", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
                        $f_ad_floor = getFieldValueFromClause("tour", "tr_floor", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
                        $tr1_cscId = getFieldValueFromClause("tour", "csc_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
                        $f_voucher = getFieldValueFromClause("tour", "tr_commission_no", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
                        
                        // Insert tour data
                        // Station 1
                        insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $tr1_adId, "tr_sort", "1", "tr_comp", $tr1_comp, "tr_comp2", "",
                                                 "tr_hsno", "", "tr_floor", $f_ad_floor, "csc_id", $tr1_cscId, "tr_status", "0", 
                                                 "tr_commission_no", $f_voucher, "tr_ware_from_to", "", 
                                                 "tr_person", "", "tr_phone", "", "tr_remark", ""));

                        $ad_id_new = getFieldValueFromClause("tour", "ad_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");
                        $f_cmp_comp = getFieldValueFromClause("tour", "tr_comp", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");
                        $f_ad_floor = getFieldValueFromClause("tour", "tr_floor", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");
                        $csc_id_new = getFieldValueFromClause("tour", "csc_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");
                        $f_order_id = getFieldValueFromClause("tour", "tr_commission_no", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");
                        $f_tr_phone = getFieldValueFromClause("tour", "tr_phone", "jb_id = '" . $f_jb_id . "' AND tr_sort = '2'");

                        // Station 2
                        insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $ad_id_new, "tr_sort", "2", "tr_comp", $f_cmp_comp, "tr_comp2", "",
                                                 "tr_hsno", "", "tr_floor", $f_ad_floor, "csc_id", $csc_id_new, "tr_status", "0", 
                                                 "tr_commission_no", $f_order_id, "tr_ware_from_to", "", 
                                                 "tr_person", "", "tr_phone", $f_tr_phone, "tr_remark", ""));

                        $csc_id_new = getFieldValueFromClause("tourservice", "csc_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '0'");

                        // Insert tourservice data
                        insertStmt("tourservice", array("jb_id", $jbIdNew, "csc_id", $csc_id_new, "tr_sort", "0", 
                                                        "srv_id", "0", "trs_srv_name", "Fixpreis", "srvt_id", "0", "trs_srvt_name", "",
                                                        "trs_price", $sum_totalprice_M));
                        
//                        insertStmt("jobcalculator", array("jb_id", $jbIdNew, "tr_sort", "2", "srv_id", "0", "srv_name", "Grundpauschale&nbsp;Montage", "srvt_id", "0",
//                                                          "srvt_name", "0002:par_01", "jbc_amount", "1.00", "jbc_price", $sum_totalprice_M, "jbc_totalprice", $sum_totalprice_M));
                                                          
                        $f_jb_id_M = $f_jb_id_addM++;                        
                    endif;
// **** NEW (END) ****
//                     if (existsEntry("job",array("jb_id",$f_jb_id_M))) :
//echo "|" . $f_inst_timeunits . "|<br>";
                        // Added installation
                        if ($f_inst_timeunits > 0) :
                           if (existsEntry("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_gen_fieldname", "jb_addmont", "gdc_obj_id", $f_jb_id_M))) :
                           
                              $gdcContextAddMon = getFieldValueFromClause("genericdatacontainer", "gdc_context", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'jb_addmont' AND gdc_obj_id = '" . $f_jb_id_M . "'");
                              if ($gdcContextAddMon == "" || !is_numeric($gdcContextAddMon)) : 
                                 $gdcContextAddMon = 0;
                              endif;
                              $f_inst_timeunits += $gdcContextAddMon;
                              updateStmt("genericdatacontainer", "gdc_obj_id", $f_jb_id_M, array("gdc_context", $f_inst_timeunits), "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'jb_addmont'");
//echo "update $f_jb_id_M<br>";
                           else :
                              // if ($f_inst_timeunits > 0) :
                                 insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $f_jb_id_M, "gdc_gen_fieldname", "jb_addmont", "gdc_context", $f_inst_timeunits));
//echo "insert $f_jb_id_M<br>";
                                 updateStmt("job", "jb_id", $f_jb_id_M, array("jb_incomplete", "1"));
//                                 $jbCscIdRelated = getFieldValueFromId("job", "jb_id", $f_jb_id_M, "csc_id_related");
//                                 insertStmt("jobpayment", array("jb_id", $f_jb_id_M, "tr_sort", "2", "csc_id", $jbCscIdRelated, "jbp_mode", "0", "jbp_price", "0.000", "jbp_bookingtime", "", "jbp_counter", "0"));
//                                 $jbpIdNew = getLastInsertId();
//                                 insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $f_jb_id_M, "gdc_gen_fieldname", "jbp_id", "gdc_content", $jbpIdNew));
                              // endif;
                           endif;
                        endif;
//                  else :
//                     if ($f_jb_id_M != "")
//                       $outText .= getLngt("AUFTRAG /2 EXISTIERT NICHT!") . " [JOB " . $f_jb_id_M . "]<br>";
//                  endif;
                  endif;
                  TA("C");
                  TA("E");

                  // $closeWindow = "1";
               endif;
            else :
               $outText .= getLngt("XXXX!") . "<br>";
            endif;
         }

         $outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "<br>");
         $outText .= getLngt("Verarbeitete Einträge: " . $executionCount . "<br>");
      else :
         $statusMessage .= getLngt("Die angegebene Datei scheint nicht kompatibel zur angeforderten Importfunktionalität!");
      endif;
   else :
      $statusMessage .= getLngt("Die angegebene Datei existiert nicht!");
   endif;
else :
   $statusMessage .= getLngt("Es wurde keine Datei spezifiziert!");
endif;
?>

<html>
<head>
<title><?php echo $pageTitel ?></title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
  <?php include_once ("../css/navigation.css.php"); ?>
</style>

<?php include_once ("../include/js_framework.inc.php"); ?>

<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>

function finishPageExecuteImportProcess(f_act) {  
  document.forms[0].f_act.value=f_act;
  document.forms[0].executeImportProcess.value = '1';
  document.forms[0].submit();
};

function onBodyLoad() {
	displayStatusMessage();
	var closeWindow = '<?php echo $closeWindow ?>';
	if (closeWindow == '1') {
     opener.document.forms[0].submit();
     window.close();
  };
};
-->
</script>

</head>

<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?>onBodyLoad();">

<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>

<div class="maincontent" name="maincontent" id="maincontent">

  <div>
    <form name="import_form" action="../import/import_JOBARTICLE.php" method="post">
      <input type="hidden" name="f_act" value="">
      <?php echo $phpCurrentNavigationInputHidden ?>
      <input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
      <input type="hidden" name="importFile" value="<?php echo $importFile; ?>">
      <input type="hidden" name="executeImportProcess" value="<?php echo $executeImportProcess; ?>">
      <input type="hidden" name="objType" value="<?php echo $objType; ?>">
      <input type="hidden" name="objId" value="<?php echo $objId; ?>">

      <?php echo htmlDivLineSpacer("10px"); ?>

      <?php
        if ($showExecutionProcessButton && $executeImportProcess != "1") :
           echo defineButtonType10(getLngt("Import starten"), "action_import", "finishPageExecuteImportProcess('executeImport');", "200");
           echo htmlDivLineSpacer("5px");
           echo defineButtonType10(getLngt("Schließen"), "action_close", "window.close();", "200");
           echo htmlDivLineSpacer("5px");
        endif;
      ?>

      <?php echo htmlDivLineSpacer("20px"); ?>

      <div>
        <table border="1" margin="10" padding="10">
        	<tr>
        		<td style="vertical-align:top;">
              <?php echo $outText; ?>
            </td>
          </tr>
        </table>    
      </div>
    </form>
  </div>

</div>

</body>

</html>