Example #1
0
            $invoice_number = !empty($doc['template']) ? $doc['template'] : '%N/LMS/%Y';
            $body = $mail_body;
            $subject = $mail_subject;
            $invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z'));
            $body = preg_replace('/%invoice/', $invoice_number, $body);
            $body = preg_replace('/%balance/', $LMS->GetCustomerBalance($doc['customerid']), $body);
            $day = sprintf("%02d", $day);
            $month = sprintf("%02d", $month);
            $year = sprintf("%04d", $year);
            $body = preg_replace('/%today/', $year . "-" . $month . "-" . $day, $body);
            $body = str_replace('\\n', "\n", $body);
            $subject = preg_replace('/%invoice/', $invoice_number, $subject);
            $filename = preg_replace('/%docid/', $doc['id'], $invoice_filename);
            if (!$quiet || $test) {
                printf("Invoice No. {$invoice_number} for " . $doc['name'] . " <{$custemail}>\n");
            }
            if (!$test) {
                $headers = array('From' => $from, 'To' => qp_encode($doc['name']) . ' <' . $custemail . '>', 'Subject' => $subject);
                if (!empty($notify_email)) {
                    $headers['Cc'] = $notify_email;
                }
                $res = $LMS->SendMail($custemail . ',' . $notify_email, $headers, $body, array(0 => array('content_type' => $ftype, 'filename' => $filename . '.' . $fext, 'data' => $res)));
                if (is_string($res)) {
                    fprintf(STDERR, "Error sending mail: {$res}\n");
                }
            }
        }
    }
}
curl_close($ch);
unlink(COOKIE_FILE);
Example #2
0
                        $covenant += 3 * $assignment['discounted_value'];
                    } else {
                        $covenant += $assignment['discounted_value'];
                    }
                    if (preg_match('/' . ConfigHelper::getConfig('finances.tariff_regexp') . '/i', $assignment['name'])) {
                        $oplata = 1;
                    }
                }
            }
        }
        if ($covenant > 0 and $balance < 0 and $balance <= -$covenant * $divisor) {
            $ilosc++;
            $razem += $balance;
            $message = sprintf("%4d %-50s saldo:%8.2f (abo:%8.2f) ", $customer['id'], $customer['lastname'] . ' ' . $customer['name'], $balance, $covenant);
            $tresc .= send_message($mode, $customer['id'], $message, $msgid, $oplata);
        }
    }
    $tresc = sprintf("Łącznie %d klientów na kwotę %2.2f:", $ilosc, -$razem) . "\n" . $tresc;
    $tytul = ucfirst($mode) . ' o zadłużeniu: ';
    #if ($divisor>0)
    $tytul .= sprintf('%3d%%|%4d|%9.2f', $divisor * 100, $ilosc, -$razem);
    if ($test) {
        echo $tytul . "\n" . $tresc;
        $tytul = 'TEST: ' . $tytul;
    }
    if (!$test) {
        $to = $mail_to;
        $headers = array('From' => $mail_from, 'To' => $to, 'Subject' => $tytul);
        $LMS->SendMail($to, $headers, $tresc);
    }
}
Example #3
0
        curl_setopt_array($ch, array(CURLOPT_URL => $lms_url . '/?m=invoice&override=1&original=1&id=' . $doc['id'] . '&loginform[login]=' . $lms_user . '&loginform[pwd]=' . $lms_password, CURLOPT_HTTPGET => TRUE, CURLOPT_POST => FALSE, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_COOKIEJAR => COOKIE_FILE, CURLOPT_COOKIEFILE => COOKIE_FILE, CURLOPT_SSLVERSION => 3, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_USERAGENT => USER_AGENT));
        $res = curl_exec($ch);
        if (!empty($res)) {
            $custemail = !empty($debug_email) ? $debug_email : $doc['email'];
            $invoice_number = !empty($doc['template']) ? $doc['template'] : '%N/LMS/%Y';
            $body = $mail_body;
            $subject = $mail_subject;
            $invoice_number = docnumber($doc['number'], $invoice_number, $doc['cdate'] + date('Z'));
            $body = preg_replace('/%invoice/', $invoice_number, $body);
            $body = preg_replace('/%balance/', $LMS->GetCustomerBalance($doc['customerid']), $body);
            $day = sprintf("%02d", $day);
            $month = sprintf("%02d", $month);
            $year = sprintf("%04d", $year);
            $body = preg_replace('/%today/', $year . "-" . $month . "-" . $day, $body);
            $body = str_replace('\\n', "\n", $body);
            $subject = preg_replace('/%invoice/', $invoice_number, $subject);
            $filename = preg_replace('/%docid/', $doc['id'], $invoice_filename);
            if (!$quiet || $test) {
                printf("Invoice No. {$invoice_number} for " . $doc['name'] . " <{$custemail}>\n");
            }
            if (!$test) {
                $res = $LMS->SendMail($custemail . ',' . $notify_email, array('From' => $from, 'To' => $doc['name'] . ' <' . $custemail . '>', 'Cc' => $notify_email, 'Subject' => $subject), $body, array(0 => array('content_type' => $ftype, 'filename' => $filename . '.' . $fext, 'data' => $res)));
                if (is_string($res)) {
                    fprintf(STDERR, "Error sending mail: {$res}\n");
                }
            }
        }
    }
}
curl_close($ch);
unlink(COOKIE_FILE);
Example #4
0
if (!$lastchange || time() - $lastchange > 30 * 86400) {
    if (!$quiet) {
        printf("Changing BGZ password ... ");
    }
    $oldpass = ConfigHelper::getConfig('finances.bgz_password');
    $newpassarray = str_split($oldpass);
    array_unshift($newpassarray, array_pop($newpassarray));
    $newpass = implode('', $newpassarray);
    $res = change_password($oldpass, $newpass);
    if ($res) {
        $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'finances' AND var = 'bgz_password'", array($newpass));
        $DB->Execute("DELETE FROM uiconfig WHERE section = 'finances' AND var = 'bgz_password_lastchange'");
        $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('finances', 'bgz_password_lastchange', ?NOW?)");
        $bgz_newpassword_email = ConfigHelper::getConfig('finances.bgz_newpassword_email');
        if (!empty($bgz_newpassword_email)) {
            $LMS->SendMail($bgz_newpassword_email, array('From' => 'lms-cashimport-bgz.php', 'Subject' => 'Aktualne hasło do panelu BGŻ'), $newpass);
        }
    }
    if (!$quiet) {
        if ($res) {
            printf("Done." . PHP_EOL);
        } else {
            printf("Error!" . PHP_EOL);
        }
    }
}
if (!$quiet) {
    printf("Logging out from BGZ ... ");
}
log_out_from_bgz();
if (!$quiet) {
Example #5
0
        $filename = str_replace('%number', $invoice_number, $filename);
        $filename = preg_replace('/[^[:alnum:]_\\.]/i', '_', $filename);
        $doc['name'] = '"' . $doc['name'] . '"';
        $mailto = array();
        $mailto_qp_encoded = array();
        foreach (explode(',', $custemail) as $email) {
            $mailto[] = $doc['name'] . " <{$email}>";
            $mailto_qp_encoded[] = qp_encode($doc['name']) . " <{$email}>";
        }
        $mailto = implode(', ', $mailto);
        $mailto_qp_encoded = implode(', ', $mailto_qp_encoded);
        if (!$quiet || $test) {
            printf("Invoice No. {$invoice_number} for {$mailto}" . PHP_EOL);
        }
        if (!$test) {
            $files = array();
            $files[] = array('content_type' => $ftype, 'filename' => $filename . '.' . $fext, 'data' => $res);
            if ($extrafile) {
                $files[] = array('content_type' => mime_content_type($extrafile), 'filename' => basename($extrafile), 'data' => file_get_contents($extrafile));
            }
            $headers = array('From' => $from, 'To' => $mailto_qp_encoded, 'Subject' => $subject);
            if (!empty($notify_email)) {
                $headers['Cc'] = $notify_email;
            }
            $res = $LMS->SendMail($custemail . ',' . $notify_email, $headers, $body, $files, $host, $port, $user, $pass, $auth);
            if (is_string($res)) {
                fprintf(STDERR, "Error sending mail: {$res}" . PHP_EOL);
            }
        }
    }
}
Example #6
0
$lastchange = !empty($CONFIG['finances']['bgz_password_lastchange']) ? intval($CONFIG['finances']['bgz_password_lastchange']) : 0;
if (!$lastchange || time() - $lastchange > 30 * 86400) {
    if (!$quiet) {
        printf("Changing BGZ password ... ");
    }
    $oldpass = $CONFIG['finances']['bgz_password'];
    $newpassarray = str_split($oldpass);
    array_unshift($newpassarray, array_pop($newpassarray));
    $newpass = implode('', $newpassarray);
    $res = change_password($oldpass, $newpass);
    if ($res) {
        $DB->Execute("UPDATE uiconfig SET value = ? WHERE section = 'finances' AND var = 'bgz_password'", array($newpass));
        $DB->Execute("DELETE FROM uiconfig WHERE section = 'finances' AND var = 'bgz_password_lastchange'");
        $DB->Execute("INSERT INTO uiconfig (section, var, value) VALUES('finances', 'bgz_password_lastchange', ?NOW?)");
        if (!empty($CONFIG['finances']['bgz_newpassword_email'])) {
            $LMS->SendMail($CONFIG['finances']['bgz_newpassword_email'], array('From' => 'lms-cashimport-bgz.php', 'Subject' => 'Aktualne hasło do panelu BGŻ'), $newpass);
        }
    }
    if (!$quiet) {
        if ($res) {
            printf("Done.\n");
        } else {
            printf("Error!\n");
        }
    }
}
if (!$quiet) {
    printf("Logging out from BGZ ... ");
}
log_out_from_bgz();
if (!$quiet) {
Example #7
0
                case DOC_DNOTE:
                    printf("Debit Note No. {$invoice_number} for {$mailto}" . PHP_EOL);
                    break;
                case DOC_CNOTE:
                    printf("Credit Note No. {$invoice_number} for {$mailto}" . PHP_EOL);
                    break;
                case DOC_INVOICE:
                    printf("Invoice No. {$invoice_number} for {$mailto}" . PHP_EOL);
                    break;
            }
        }
        if (!$test) {
            $files = array();
            $files[] = array('content_type' => $doc['doctype'] == DOC_DNOTE ? $dnote_ftype : $invoice_ftype, 'filename' => $filename . '.' . ($doc['doctype'] == DOC_DNOTE ? $dnote_fext : $invoice_fext), 'data' => $res);
            if ($extrafile) {
                $files[] = array('content_type' => mime_content_type($extrafile), 'filename' => basename($extrafile), 'data' => file_get_contents($extrafile));
            }
            $headers = array('From' => $from, 'To' => $mailto_qp_encoded, 'Subject' => $subject);
            if (!empty($reply_email)) {
                $headers['Reply-To'] = $reply_email;
            }
            if (!empty($notify_email)) {
                $headers['Cc'] = $notify_email;
            }
            $res = $LMS->SendMail($custemail . (!empty($notify_email) ? ',' . $notify_email : ''), $headers, $body, $files, $host, $port, $user, $pass, $auth);
            if (is_string($res)) {
                fprintf(STDERR, "Error sending mail: {$res}" . PHP_EOL);
            }
        }
    }
}