$exception_path = 'sm_vendor/exception'; /* * Filename convention: <Vendor Code>_<Document Number>_<Year>_<Payment Type> * 0700000001_2100000101_2015_MC * Process only if filename has correct number of info based on filename convention (payment type - optional) * Acceptable file extension: pdf, csv */ $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, $filename, '', '', '', '', $exception_path, $exception_file, $exception_path, '', $exception_path, '', 0, 'exception_filename_convention', ''); continue; } //construct variables from filename info $vendor_no = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[0]); $pv_number = smv_sitecron_remove_special_characters($importer_id, $returned_file_info[1]); $pv_year = $returned_file_info[2]; //Managers check if (isset($returned_file_info[3]) && $returned_file_info[3] != "" && !empty($returned_file_info[3])) { $filename_mc = strtolower($returned_file_info[3]); $ptype = $filename_mc == 'mc' || $filename_mc == 'c' ? 1 : 0; } else { $ptype = 0; } /* * 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, '', '', '', '', $exception_path, $exception_file, $exception_path, '', $exception_path, '', 0, 'exception_no_vendorno', '');
$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_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);