retrieve($printer); $output = shell_exec("ping -c 1 ".$s->ip." >/dev/null && echo 'true'"); if($check=='1'){ if($output==''){ echo 'false'; return; } else { echo 'true'; return; } } else { require_once ("modules/".$module."/createPDF.php"); $opt = explode("&", $pdf_options); if (count($opt) > 0) foreach ($opt as $o) { $arg = explode("=", $o); $_REQUEST[$arg[0]] = $arg[1]; } $module = substr($module, 0, - 1); $function='create'.$module.'Pdf'; $fn=$function($id, 'FILE'); //echo "lpr -P ".$s->description." /var/www/html/crm/".$fn; $output = shell_exec("lpr -P ".$s->description." /var/www/html/crm/".$fn); echo 'true'; return; } } function justScan($id,$name,$check,$type){ $new_name=create_guid(); $s=new EcmDevice(); $s->retrieve($id); $path = '/var/www/html/crm/upload/'.$new_name; $return=array(); if($type==0){ $command="scanimage -d '".$s->description."' -y 297 -x 205 --format tiff > ".$path; } else { $command="scanimage -d '".$s->description."' -y 297 -x 210 -l 35 --batch=/var/www/html/crm/tmpscan/".$new_name."_%03d.tif --resolution 300 --format tiff"; } $output = shell_exec("ping -c 1 ".$s->ip." >/dev/null && echo 'true'"); if($check=='1'){ if($output==''){ echo 'false'; return; } else { echo 'true'; return; } } else { if($type==0){ $output =shell_exec($command); $filename='upload/'.$new_name; if (file_exists($filename)) { $command="convert -quality 50% ".$path." /var/www/html/crm/upload/".$new_name.".jpeg"; $output =shell_exec($command); shell_exec('rm -fr /var/www/html/crm/upload/'.$new_name); shell_exec('mv /var/www/html/crm/upload/'.$new_name.'.jpeg /var/www/html/crm/upload/'.$new_name); echo $new_name; return; } else { echo $output; echo 'false'; return; } } else { // echo $command; $output =shell_exec($command); shell_exec('tiffcp /var/www/html/crm/tmpscan/'.$new_name.'_???.tif /var/www/html/crm/tmpscan/mm_'.$new_name.'.tif'); shell_exec('tiff2pdf -o /var/www/html/crm/upload/tmp_'.$new_name.' /var/www/html/crm/tmpscan/mm_'.$new_name.'.tif'); shell_exec('gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=/var/www/html/crm/upload/'.$new_name.' /var/www/html/crm/upload/tmp_'.$new_name); shell_exec('rm -fr /var/wwww/html/crm/tmpscan/mm_'.$new_name.'*'); shell_exec('rm -fr /var/wwww/html/crm/tmpscan/'.$new_name.'*'); shell_exec('rm -fr /var/wwww/html/crm/upload/tmp_'.$new_name); echo $new_name; return; } } // echo exec('ping 192.168.1.116'); } function getScannerList(){ $return=array(); $a=$GLOBALS['db']->query('select id,name,description from ecmdevices where type="1"'); while($b=$GLOBALS['db']->fetchByAssoc($a)){ $return[]=$b; } unset($a); unset($b); echo json_encode($return); return; } global $sugar_config; if($_POST['uploadFieldName']!=''){ $success=false; //$upload_file = new UploadFile($prefix . $field); foreach ($_FILES[$_POST['uploadFieldName']]['name'] as $key => $value) { $new_name=create_guid(); $target_file=$sugar_config['upload_dir'].basename($new_name); if(move_uploaded_file($_FILES[$_POST['uploadFieldName']]["tmp_name"][$key], $target_file)){ echo '
Plik '.$_FILES[$_POST['uploadFieldName']]['name'][$key].' wgrany.
'; /* $Revision = new DocumentRevision(); //save revision. $Revision->change_log = 'test'; $Revision->revision = 1; $Revision->document_id = $bean->id; $Revision->filename = $_FILES[$_POST['uploadFieldName']]['name'][$key]; $Revision->file_ext = pathinfo($_FILES[$_POST['uploadFieldName']]['name'][$key], PATHINFO_EXTENSION); $Revision->file_mime_type = $_FILES[$_POST['uploadFieldName']]['type'][$key]; $Revision->save(); $success=true; $bean->new_with_id = true; */ } else { echo 'Plik '.$_FILES[$_POST['uploadFieldName']]['name'][$key].' nie został wgrany.