Exemplo n.º 1
0
 } else {
     echo "Account already exist";
 }
 $file = $_FILES['inputFile']['tmp_name'];
 echo "File opened " . "<br>" . $_POST['ClassID'];
 $messageHandler = fopen($file, "r");
 while (($fileOpen = fgetcsv($messageHandler, 1000, ",")) !== false) {
     $StudentID = $fileOpen[0];
     //echo $StudentID;
     $classID = $_POST['ClassID'];
     //echo $Status;
     $Fname = $fileOpen[1];
     $Lname = $fileOpen[2];
     $RFID = $fileOpen[3];
     $attendance = $fileOpen[4];
     $student = new csvClass($StudentID, $classID, $Fname, $Lname, $RFID, $attendance);
     $result = $student->Selection($myDBconnection->db);
     echo $RFID . "<br>";
     // $mycsvClass = new csvClass($StudentID, $classID, $Fname, $Lname, $RFID);
     if ($result->rowCount() == 0) {
         echo "rowcount 0";
         $response = $student->Insertion($myDBconnection->db);
     }
     //echo 'File has been uploaded SUCCESSFULLY';
 }
 if ($response <= 1) {
     if ($response == 0) {
         echo "Error inserting students in the DB";
     } else {
         echo "You have added students to the class";
     }
 /**
  * create tickets from form data
  */
 function submit()
 {
     $authenticationAndSecurity = new authenticationAndSecurity();
     $csvClass = new csvClass();
     $isAjax = $authenticationAndSecurity->getGet("ajax");
     $GLOBALS['newline'] = '<br/>';
     $newLine = $GLOBALS["newline"];
     if ($isAjax !== 'true') {
         echo $newLine . $newLine . "------------------------------" . $newLine . "    Youtrack csv importer     " . $newLine . "------------------------------" . $newLine;
         if (null !== $authenticationAndSecurity->getPost("test")) {
             echo "-- Testing progress --" . $newLine;
         } else {
             echo "-- Progress --" . $newLine;
         }
     }
     $posts = $this->organisePosts();
     $posts = $this->organiseAttachments($posts);
     date_default_timezone_set('Europe/London');
     $csvLogFolder = __DIR__ . '/../../log/createByForm/' . date("Y-m-d");
     $csvLogFileName = time() . '.csv';
     // creates csv log before sending to guzzle as guzzle dosnt fail gracefully
     if ($GLOBALS['createByFormTransferLog']) {
         $this->createFolder($csvLogFolder);
         $csvClass->createCsv($posts, $csvLogFolder . '/' . $csvLogFileName);
     }
     $posts = $this->sendPostData($posts);
     if ($GLOBALS['createByFormTransferLog']) {
         $csvClass->createCsv($posts, $csvLogFolder . '/' . $csvLogFileName);
     } elseif ($GLOBALS['createByFormTransferErrorLog']) {
         $posts = $this->removeSuccessfulPosts($posts);
         $this->createFolder($csvLogFolder);
         $csvClass->createCsv($posts, $csvLogFolder . '/' . $csvLogFileName);
     }
     if ($isAjax !== 'true') {
         if (null !== $authenticationAndSecurity->getPost("test")) {
             echo $newLine . "---- Test Finished -----" . $newLine;
         } else {
             echo $newLine . "---- Upload Finished -----" . $newLine;
         }
     } else {
         echo json_encode($GLOBALS['createByFormAjax']);
     }
 }
<?php

/**
 * download a csv with field options
 */
require_once __DIR__ . '/../../vendor/autoload.php';
require_once __DIR__ . '/getCustomSettings.php';
require_once __DIR__ . '/getDataFromYoutrack.php';
require_once __DIR__ . '/authenticationAndSecurity.php';
$getYoutrackData = new getDataFromYoutrack();
$authenticationAndSecurity = new authenticationAndSecurity();
require_once __DIR__ . '/csv.php';
$csvClass = new csvClass();
use Ddeboer\DataImport\Writer\CsvWriter;
$youtrackFields = [];
$filename = $authenticationAndSecurity->getPost('filename');
list($youtrackFieldsList, $youtrackFields) = $getYoutrackData->getCustomFieldsWithDetails();
$youtrackFields['user'] = $getYoutrackData->getUsers();
array_push($youtrackFieldsList, 'user');
/**
 * organises fields into more usable format, removing empty
 * @param array $array youtrack fields
 * @return array
 */
function reorganiseArray($array)
{
    $newArray = [];
    foreach ($array as $key => $value) {
        $i = 0;
        foreach ($value as $key2 => $val) {
            if (!isset($newArray[$i])) {