Sorts thru PDF documents and puts them into corresponding folders etc.
More...
Sorts thru PDF documents and puts them into corresponding folders etc.
- Parameters
-
- Returns
- none
Definition at line 11 of file ppyrd.sorter.php.
pdfSorter::__construct |
( |
|
$pdf, |
|
|
|
$db |
|
) |
| |
constructor
- Parameters
-
string | $pdf | file name to be processed |
string | $db | database handler |
- Returns
- none
Definition at line 19 of file ppyrd.sorter.php.
pdfSorter::checkRules |
( |
| ) |
|
checks rules
Definition at line 90 of file ppyrd.sorter.php.
92 $rules = $this->db->getActiveArchiveRules();
93 while ($row = $rules->fetchArray()) {
96 $match = fnmatch($row[
'company'], $this->company)
97 && fnmatch($row[
'subject'], $this->subject)
98 && fnmatch($row[
'recipient'], $this->recipient)
99 && fnmatch($row[
'tags'], $this->tags);
104 $toFolder = $row[
'toFolder'];
107 $toFolder = str_replace(
'[year]', $this->year, $toFolder);
108 $toFolder = str_replace(
'[month]', $this->month, $toFolder);
109 $toFolder = str_replace(
'[day]', $this->day, $toFolder);
110 $toFolder = str_replace(
'[recipient]', $this->recipient, $toFolder);
113 $toFolder = rtrim($toFolder,
'/') .
'/';
116 exec(
"mkdir -p '$toFolder'");
119 exec(
'mv --backup=numbered "' . $this->pdf .
'" "' . $toFolder . $this->pdf .
'"');
121 $this->db->writeLog($this->pdf, $this->pdf,
"",
"Moved file to: " . $toFolder);
runs the main process
Definition at line 129 of file ppyrd.sorter.php.
splitUpFilename()
function gets from file name the information what the date, company and subject is.
pdfSorter::splitUpFilename |
( |
| ) |
|
function gets from file name the information what the date, company and subject is.
Definition at line 30 of file ppyrd.sorter.php.
32 $this->
output(
"working on: " . $this->pdf);
35 $newFilenameStructure=$this->db->getConfigValue(
'newFilenameStructure');
39 $unwanted = array(
')',
']');
40 $separators =
"/ - | \(| \[| \-\- /";
41 $templateName = str_replace($unwanted,
'', $newFilenameStructure);
44 $templateParts = array_flip(preg_split($separators, $templateName));
47 $tmpName = str_replace($unwanted,
'', $this->pdf);
48 $filenameParts = preg_split($separators, $tmpName);
53 $parts = explode(
" - ", $this->pdf);
56 $this->date = $filenameParts[$templateParts[
'ddatum']];
57 $this->year = date(
'Y',strtotime($this->date));
58 $this->month = date(
'm',strtotime($this->date));
59 $this->day = date(
'd',strtotime($this->date));
62 $this->company = $filenameParts[$templateParts[
'ffirma']];
63 $this->recipient = $filenameParts[$templateParts[
'wwer']];
64 $this->subject = $filenameParts[$templateParts[
'bbetreff']];
65 $this->amount = $filenameParts[$templateParts[
'bbetrag']];
70 preg_match_all(
'/\[(\d|\w)*\]/',$this->pdf,$tags);
71 $this->tags = implode($tags[0]);
74 $this->
output(
"date: " . $this->date);
75 $this->
output(
"year: " . $this->year);
76 $this->
output(
"month: " . $this->month);
77 $this->
output(
"day: " . $this->day);
79 $this->
output(
"company: " . $this->company);
80 $this->
output(
"recipient: " . $this->recipient);
81 $this->
output(
"subject: " . $this->subject);
82 $this->
output(
"amount: " . $this->amount);
83 $this->
output(
"tags: " . $this->tags);
output($string, $debug=0)
outputs string
The documentation for this class was generated from the following file: