function lbl_add_csv($link, $file, $fr_addr, $to_addr) { $row = 1; $handle = fopen($file, "r"); while (!feof($handle)) { $data = fgetcsv($handle, 300, ";"); $num = count($data); // Number of columns //echo "<p> $num полей в строке $row: <br /></p>\n"; //echo "String ".$row." Number of columns " .$num."<br><br>"; $row++; if ($row > 2) { $receiver = $data[0]; $date_lbl = $data[1]; $date = date_form($data[1]); $part_number = $data[2]; $quantity = $data[3]; $quantity = str_replace(" ", "", $quantity); $quantity = (int) $quantity; $action = 'add from csv'; $add = lbl_add($link, $action, $part_number, $quantity, $date, $receiver, $fr_addr, $to_addr); $len = get_max_id($link); $filepath = lbl_update($part_number, $quantity, $date_lbl, $receiver, $len); lbl_print($filepath); //echo $receiver . ' - ' . $date . ' - ' . $part_number . ' - ' . $quantity . "<br><br>"; } } fclose($handle); $labels_added = $row - 2; return $labels_added; }
<?php require_once "database.php"; require_once "models/functions.php"; date_default_timezone_set('Europe/Samara'); $link = db_connect(); //$command = 'Rec_label_print.bat'; $address = "01.01.02"; $rack = "01"; $pallet = "01"; $floor = "02"; $path = lbl_update_wh($address, $rack, $pallet, $floor); echo $path; lbl_print($path);
header("Location: ./views/menu.php"); } } switch ($action) { case 'add': // _______ADD_______ $fr_addr = 'SUPPLIER'; $to_addr = 'DROPZONE'; if (!empty($_POST)) { $date_lbl = $_POST['date']; $date = date_form($_POST['date']); $add = lbl_add($link, $action, $_POST['part_number'], $_POST['quantity'], $date, $_POST['receiver'], $fr_addr, $to_addr); if ($add) { $len = get_max_id($link); $filepath = lbl_update($_POST['part_number'], $_POST['quantity'], $date_lbl, $_POST['receiver'], $len); $command = lbl_print($filepath); //echo $command; header("Location: ./views/menu.php"); } else { $err_msg = "PART NUMBER DOESN'T EXIST!"; require_once "/views/error.php"; } } else { require_once "./views/label_add.php"; } break; case 'add_csv': // _______ADD from CSV_______ $fr_addr = 'SUPPLIER'; $to_addr = 'DROPZONE'; $file = 'F:\\Public\\4. Logistics\\WMS reports\\load' . '\\receiving.csv';