$csv_file_array[] = array('', $filename, $filename, '', '', '', '', '', '', 0, $exception_path, $exception_file, $exception_path, '', 'exception_filename_convention', 0, ''); continue; } //Filename date format if (!smv_sitecron_validate_date_format($returned_file_info[6])) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array('', $filename, $filename, '', '', '', '', '', '', 0, $exception_path, $exception_file, $exception_path, '', 'exception_invalid_date', 0, ''); continue; } //construct variables from filename info $po_number = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[1]); $vendor_no = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[2]); $po_org = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[3]); $po_maker = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[4]); $po_status = strtolower(smv_sitecron_remove_special_characters($importer_id, $returned_file_info[5])); $po_date = smv_sitecron_convert_date_to_timestamp($returned_file_info[6]); /* * Process only if it theres existing vendor number */ $vendor_uid = smv_sitecron_vendor_uid($vendor_no); if (!$vendor_uid) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array('', $filename, $filename, '', $vendor_no, '', $po_org, $po_maker, '', 0, $exception_path, $exception_file, $exception_path, '', 'exception_no_vendorno', 0, ''); continue; } /* * Columns: PO No | Line No | Material No | Material Desc | Quantity | UOM | Unit Price | Total Price * Process only if it has correct number of columns (8) */ $column_count = smv_sitecron_csv_column_count($file); if ($column_count != 8) {
*/ $column_count = smv_sitecron_csv_column_count($file); if ($column_count != 3) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array($filename, '', '', '', '', '', $exception_path, $exception_file, $exception_path, '', 0, 'exception_column_count'); continue; } //Read contents of csv $csv_lines = smv_sitecron_csv_to_array($file); $line_count = count($csv_lines); if ($line_count == 0) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array($filename, '', '', '', '', '', $exception_path, $exception_file, $exception_path, '', 0, 'exception_empty_csv'); continue; } $date = smv_sitecron_convert_date_to_timestamp($csv_lines[0][1]); $amount_csv = $csv_lines[0][2]; if ($amount_csv != '' || $amount_csv != 0) { $amount = str_replace(",", "", $amount_csv); } else { $amount = $amount_csv; } $raw_path = 'sm_vendor/vendors/' . $vendor_no . '/active/nonpo'; $raw_file = smv_sitecron_move_to_active_folder($importer_id, $file, $vendor_no); $csv_file_array[] = array($filename, $vendor_uid, $docno, $vendor_no, $date, $amount, $raw_path, $raw_file, $raw_path, '', 1, ''); } else { //invalid file type, continue continue; } $num++; }
$number_returned_info = count($returned_file_info); if ($number_returned_info <= 2) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array($filename, '', '', '', '', '', $exception_path, $exception_file, 0, 'exception_filename_convention'); continue; } //Filename date format if (!smv_sitecron_validate_date_format($returned_file_info[1])) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array($filename, '', '', '', '', '', $exception_path, $exception_file, 0, 'exception_invalid_date'); continue; } //construct variables from filename info $vendor_no = $returned_file_info[0]; $file_date = $returned_file_info[1]; $bir_date = smv_sitecron_convert_date_to_timestamp($file_date); //get readable date $dtime = DateTime::createFromFormat("Ymd", $file_date); $month = $dtime->format('n'); $quarter_yr = $dtime->format('Y'); $quarter_no = smv_sitecron_date_quarterno($month); /* * Process only if it theres existing vendor number */ $vendor_uid = smv_sitecron_vendor_uid($vendor_no); if (!$vendor_uid) { $exception_file = smv_sitecron_move_to_exception_folder($importer_id, $file); $csv_file_array[] = array($filename, '', '', '', '', '', $exception_path, $exception_file, 0, 'exception_no_vendorno'); continue; } //construct title of node