Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['uploadpdffile']))
- {
- $pdffile = $_GET['uploadpdffile'];
- include('lib/PdfToText.phpclass');
- $time_pattern1 = '/(\d{2}:\d{2}:\d{2} [A-Za-z]{2})/';
- $time_pattern2 = '/(\d{2}:\d{2} [A-Za-z]{2})/';
- $space_utf_pattern = '/(\t|\n|\v|\f|\r| |\xC2\x85|\xc2\xa0|\xe1\xa0\x8e|\xe2\x80[\x80-\x8D]|\xe2\x80\xa8|\xe2\x80\xa9|\xe2\x80\xaF|\xe2\x81\x9f|\xe2\x81\xa0|\xe3\x80\x80|\xef\xbb\xbf)+/';
- //$pdf = new PdfToText('schedule 11 efcc sample.pdf');
- $pdf = $pdffile;
- $displaymode = 'false';
- if(isset($_GET['verbose'])){
- $displaymode = $_GET['verbose'];
- }
- $physicians = array();
- $text = preg_replace($space_utf_pattern, ' ', $pdf->Text);
- $header = explode(' ', substr($text, 0, 200));
- if($displaymode == 'true'){
- }
- if($displaymode == 'true'){
- }
- foreach ($header as $key => $value)
- {
- //print_r($value.'<br/>');
- if($value=='Schedule for'){
- $physicians[] = str_replace('TimeNameVisits:', 'Visits:', $header[$key-1]);
- // print_r('TRUE');
- }
- }
- $text = str_replace('Schedule for ', '', $text);
- $tmpdoc = substr($text, 0, strpos($text,','));
- $tmptext = substr($text, strpos($text,','), strlen($text));
- $text = $tmptext;
- $physicians[] = $tmpdoc;
- if(preg_match($time_pattern1, $text))
- {
- }
- if(preg_match($time_pattern2, $text))
- {
- $data_raw = preg_split($time_pattern2, $text, NULL, PREG_SPLIT_DELIM_CAPTURE);
- }
- for($i=1; $i<count($data_raw); $i++) {
- if($i%2==0)
- {
- //$data_raw[$i] = preg_replace('/\s*\([^)]*\)|F\/U|Fully Booked\.|Checked In|OVERBOOKED|Booked|\d{2} MINUTES\.|Missed|FM|See ACPM|Comment|^(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))*$/', '', $data_raw[$i]);
- $data_raw[$i] = preg_replace('/\s*\([^)]*\)|f\/u|fully booked\.|checked in|overbooked|booked|\d{2} minutes\.|missed|FM|see acpm|comment/', '', strtolower($data_raw[$i]));
- $data_raw[$i] = preg_replace('/\s+/', ' ', trim($data_raw[$i]));
- $data[$data_raw[$i-1]] = $data_raw[$i];
- }
- }
- $tmparraykeys = array();
- foreach($data as $key => $value)
- {
- $tmpstr = preg_split('/(([\+]([\d]{2,}))([0-9\.\-\/\s]{5,})|([0-9\.\-\/\s]{5,}))/', $value,NULL, PREG_SPLIT_DELIM_CAPTURE);
- $tmparr_nameandphone = preg_split('/\s+/', $tmpstr[1]);
- $tmparrayvalues = array($tmpstr[0],$tmparr_nameandphone[1],$tmparr_nameandphone[0],);
- $tmparrayvalues[0] = preg_split('/(\d{2})/', $tmparrayvalues[0]);
- $tmparraykeys['physician'] = $physicians[0];
- $tmparraykeys['name'] = $tmparrayvalues[0][0];
- $tmparraykeys['phone'] = $tmparrayvalues[1];
- //$tmparraykeys['min'] = $tmparrayvalues[2];
- $data2[$key] = $tmparraykeys;
- //$data2[$key][phonenumber] = $tmparr[0];
- }
- foreach($data2 as $key1 => $tmparr)
- {
- foreach($tmparr as $key2 => $value)
- {
- if(strtolower($value) =='- not available')
- {
- unset($data2[$key1]);
- }
- }
- }
- $schedule = json_encode($value);
- print_r($schedule);
- // exit;
- /*************************************************************\
- foreach($data2 as $key => $arrtmp) {
- // print_r($arrtmp);
- foreach($data2 as $arrtmp=>$value)
- {
- //$pieces = explode(' ', $value);
- $pieces = $value;
- $data[$arrtmp] = @array($physicians[0]=>$pieces[0].' '.$pieces[1],
- $physicians[1]=>$pieces[2].' '.$pieces[3]);
- }
- }
- *
- */
- }
- //print_r($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement