function scan() { $invoice = array("invoice" => "Scan Invoice"); $barcode = flashRed($invoice); $barcode = $barcode["invoice"]; $sorder_num = decrypt_barcode($barcode); if (empty($sorder_num) || !is_numeric($sorder_num)) { $sorder_num = 0; } $prd_union = array(); for ($i = 1; $i <= 14; $i++) { $prd_union[] = "SELECT pslip_sordid FROM \"{$i}\".pinvoices WHERE pslip_sordid='{$sorder_num}'"; } $pinvoices_sql = implode(" UNION ", $prd_union); $sql = "SELECT pslip_sordid FROM cubit.invoices WHERE pslip_sordid='{$sorder_num}' UNION {$pinvoices_sql}"; $invoice_rslt = db_exec($sql) or errDie("Unable to check sales order id."); if (!pg_num_rows($invoice_rslt) || $sorder_num == 0) { return scan_error("Scanned invoice does not exist."); } $sql = "SELECT sordid FROM cubit.pslip_signed_index WHERE sordid='{$sorder_num}'"; $psi_rslt = db_exec($sql) or errDie("Unable to retrieve index."); if (pg_num_rows($psi_rslt) > 0) { scan_error("Signed invoice already uploaded"); } return enter($sorder_num); }
function scan() { // Check setting $sql = "SELECT set FROM cubit.picking_slip_setting"; $setting_rslt = db_exec($sql) or errDie("Unable to retrieve setting."); $setting = pg_fetch_result($setting_rslt, 0); if ($setting == "n") { header("Location: picking_slip_settings.php"); } $invoice = array("invoice" => "Scan Invoice"); list($barcode) = array_values(flashRed($invoice)); $sordid = decrypt_barcode($barcode); if (empty($sordid) || !is_numeric($sordid)) { $sordid = 0; } // Has this invoice been scanned before $sql = "SELECT id FROM cubit.pslip_scans WHERE sordid='{$sordid}'"; $scan_rslt = db_exec($sql) or errDie("Unable to retrieve scans."); $sql = "SELECT sordid FROM cubit.sorders WHERE sordid='{$sordid}'"; $sorder_rslt = db_exec($sql) or errDie("Unable to retrieve sales order."); if (pg_num_rows($sorder_rslt)) { $reason = ""; if (pg_num_rows($scan_rslt)) { $reason = "DUPLICATE (No reason)"; } $sql = "\n\t\t\tINSERT INTO cubit.pslip_scans (\n\t\t\t\tsordid, timestamp, userid, reason\n\t\t\t) VALUES (\n\t\t\t\t'{$sordid}', current_timestamp, '" . USER_ID . "', '{$reason}'\n\t\t\t)"; db_exec($sql) or errDie("Unable to record scan."); } else { return scan_error(); } if (pg_num_rows($scan_rslt)) { $scan_id = pglib_lastid("cubit.pslip_scans", "id"); return reason($scan_id); } return dispatch($sordid); }
$cmd_brightness = ""; if ($do_brightness && strtolower($mode) != 'lineart') { if ($brightness >= $contrast_minimum && $brightness <= $contrast_maximum) { $cmd_brightness = " --brightness " . $brightness; } else { $lang[$lang_id][22] = "<span class=\"input_error\">" . $lang[$lang_id][22] . "</span>"; scan_error($scan_output, $error_input, $lang_error); } } $cmd_contrast = ""; if ($do_contrast) { if ($contrast >= $contrast_minimum && $contrast <= $contrast_maximum) { $cmd_contrast = " --contrast " . $contrast; } else { $lang[$lang_id][23] = "<span class=\"input_error\">" . $lang[$lang_id][23] . "</span>"; scan_error($scan_output, $error_input, $lang_error); } } $cmd_usr_opt = " " . $usr_opt; //////////////////////////////////////////////////////////////////////// // build the device command $scan_yes = ''; $cmd_device = ''; $file_save = ''; $file_save_image = 0; $cmd_scan = $SCANIMAGE . " -d " . $scanner . $cmd_geometry_l . $cmd_geometry_t . $cmd_geometry_x . $cmd_geometry_y . $cmd_mode . $cmd_resolution . $cmd_brightness . $cmd_contrast . $cmd_usr_opt; if ($error_input == 0) { if ($action_preview) { $preview_images = $temp_dir . "preview_" . $sid . ".jpg"; $cmd_device = $SCANIMAGE . " -d " . $scanner . " --resolution " . $PREVIEW_DPI . "dpi -l 0mm -t 0mm -x " . $MAX_SCAN_WIDTH_MM . "mm -y " . $MAX_SCAN_HEIGHT_MM . "mm" . $cmd_mode . $cmd_brightness . $cmd_contrast . $cmd_usr_opt . " | " . $PNMTOJPEG . " --quality=50 > " . $preview_images; } else {