mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-24 13:40:29 +01:00
mahnwesen added CRM for printed dokumente (email not yet implemented)
This commit is contained in:
parent
2c7f113d6b
commit
1c1c7034f1
@ -9478,7 +9478,7 @@ a.land as land, p.abkuerzung as projekt, a.zahlungsweise as zahlungsweise,
|
||||
if(bearbeiter!="",bearbeiter,a2.name) as bearbeiter,
|
||||
CONCAT(UCASE(LEFT(d.typ, 1)), SUBSTRING(d.typ, 2)) as art,
|
||||
CONCAT(IF(d.sent = 1, "JA", "NEIN"),"<a data-type=dokumente data-id=", d.id, "></a>") as gesendet,
|
||||
"" as pdf,
|
||||
concat("<a href=\"index.php?module=dateien&action=send&id=",(SELECT datei FROM datei_stichwoerter WHERE subjekt="anhang" AND objekt="dokument" AND parameter = d.id LIMIT 1),"\"><img src=./themes/' . $this->app->Conf->WFconf['defaulttheme'] . '/images/pdf.svg></a>") as pdf,
|
||||
concat("1","-",d.id) as did,d.content as suchtext,d.internebezeichnung
|
||||
FROM
|
||||
dokumente d
|
||||
|
@ -17983,7 +17983,8 @@ function Gegenkonto($ust_befreit,$ustid='', $doctype = '', $doctypeId = 0)
|
||||
created = NOW(),
|
||||
uhrzeit = "' . $data['uhrzeit'] . '",
|
||||
projekt = "' . $data['projekt'] . '",
|
||||
bearbeiter = "' . $data['bearbeiter'] . '"
|
||||
bearbeiter = "' . $data['bearbeiter'] . '",
|
||||
sent = "' . $data['sent'] . '"
|
||||
');
|
||||
|
||||
return $this->app->DB->GetInsertID();
|
||||
|
@ -6417,7 +6417,7 @@ function AdresseVerein()
|
||||
if(bearbeiter!="",bearbeiter,a2.name) as bearbeiter,
|
||||
CONCAT(UCASE(LEFT(d.typ, 1)), SUBSTRING(d.typ, 2)) as art,
|
||||
CONCAT(IF(d.sent = 1, "JA", "NEIN"),"<a data-type=dokumente data-id=", d.id, "></a>") as gesendet,
|
||||
"" as pdf,
|
||||
concat("<a href=\"index.php?module=dateien&action=send&id=",(SELECT datei FROM datei_stichwoerter WHERE subjekt="anhang" AND objekt="dokument" AND parameter = d.id LIMIT 1),"\"><img src=./themes/' . $this->app->Conf->WFconf['defaulttheme'] . '/images/pdf.svg></a>") as pdf,
|
||||
concat("1","-",d.id) as did,
|
||||
d.content as suchtext,
|
||||
d.internebezeichnung
|
||||
|
@ -33,7 +33,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bearbeiter:</td>
|
||||
<td colspan="3"><input type="text" name="von" id="von" value="[SENDER]" style="width: 370px;"></td>
|
||||
<td colspan="3"><input type="text" name="von" id="von" value="[BEARBEITER]" style="width: 370px;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="100">{|Projekt|}:</td>
|
||||
|
@ -3,9 +3,7 @@
|
||||
<li><a href="#tabs-1">[TABTEXT1]</a></li>
|
||||
</ul>
|
||||
<div id="tabs-1">
|
||||
|
||||
<form method="post" action="#">
|
||||
|
||||
<form method="post" action="#">
|
||||
<div class="filter-box filter-usersave">
|
||||
<div class="filter-block filter-inline">
|
||||
<div class="filter-title">{|Filter|}</div>
|
||||
@ -33,9 +31,10 @@
|
||||
</li>
|
||||
</ul>
|
||||
<input type="submit" class="btnBlue" name="mahnstufe_berechnen" value="{|Mahnstufe berechnen|}" />
|
||||
<input type="submit" class="btnBlue" name="mahnen" value="{|Mahnung durchführen|}" title="Alle markierten mit neuer Mahnstufe mahnen" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form method="post" action="#">
|
||||
[MESSAGE]
|
||||
[TAB1]
|
||||
[TAB1NEXT]
|
||||
@ -47,13 +46,13 @@
|
||||
[ALSBEZAHLTMARKIEREN]
|
||||
<option value="offen">{|als offen markieren|}</option>
|
||||
<option value="mahnung_reset">{|Mahnstatus zurücksetzen|}</option>
|
||||
<!-- <option value="mahnen">{|Mahnung durchführen|}</option>
|
||||
<option value="email">{|Mahnung durchführen (nur E-Mail)|}</option>
|
||||
<option value="mahnen">{|Mahnung durchführen|}</option>
|
||||
<!-- <option value="email">{|Mahnung durchführen (nur E-Mail)|}</option>
|
||||
<option value="email">{|Mahnung durchführen (nur Drucken)|}</option> -->
|
||||
</select> {|Drucker|}: <select name="seldrucker">[SELDRUCKER]</select> <input type="submit" class="btnBlue" name="ausfuehren" value="{|ausführen|}" />
|
||||
</fieldset>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
@ -231,62 +231,7 @@ class Mahnwesen {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if($this->app->Secure->GetPOST('mahnen') && $this->app->erp->RechteVorhanden('rechnung', 'edit')) {
|
||||
|
||||
// Process multi action
|
||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||
$selectedIds = [];
|
||||
if(!empty($auswahl)) {
|
||||
foreach($auswahl as $selectedId) {
|
||||
$selectedId = (int)$selectedId;
|
||||
if($selectedId > 0) {
|
||||
$selectedIds[] = $selectedId;
|
||||
}
|
||||
}
|
||||
|
||||
$mails = 0;
|
||||
$drucke = 0;
|
||||
|
||||
foreach ($selectedIds as $rechnung_id) {
|
||||
|
||||
$mahnung = $this->MahnwesenMessage($rechnung_id);
|
||||
|
||||
if ($mahnung['druck']) {
|
||||
$drucker = $this->app->Secure->GetPOST('seldrucker');
|
||||
if($drucker > 0) {
|
||||
$this->app->erp->BriefpapierHintergrundDisable($drucker);
|
||||
} else {
|
||||
$msg .= "<div class=\"error\">Kein Drucker gewählt.</div>";
|
||||
break;
|
||||
}
|
||||
if(class_exists('RechnungPDFCustom')) {
|
||||
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
||||
}
|
||||
else {
|
||||
$Brief = new RechnungPDF($this->app,$projekt);
|
||||
}
|
||||
$Brief->GetRechnung($rechnung_id,$mahnung['betreff'],0,null,$mahnung['body']);
|
||||
$tmpfile = $Brief->displayTMP();
|
||||
$this->app->printer->Drucken($drucker,$tmpfile);
|
||||
unlink($tmpfile);
|
||||
$this->app->erp->RechnungProtokoll($rechnung_id,'Mahnung gedruckt');
|
||||
$drucke++;
|
||||
}
|
||||
|
||||
if ($mahnung['mail']) {
|
||||
$this->app->erp->RechnungProtokoll($rechnung_id,'Mahnung versendet');
|
||||
$mails++;
|
||||
}
|
||||
|
||||
$sql = "UPDATE rechnung set mahnwesen_datum = CURRENT_DATE, versendet_mahnwesen = 1";
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
}
|
||||
$msg .= "<div class=\"success\">$mails E-Mails versendet, $drucke Dokumente gedruckt.</div>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->app->Secure->GetPOST('sel_aktion') && $this->app->erp->RechteVorhanden('rechnung', 'edit'))
|
||||
{
|
||||
@ -317,6 +262,49 @@ class Mahnwesen {
|
||||
$sql = "UPDATE rechnung SET mahnwesen='', versendet_mahnwesen ='', mahnwesen_datum = '0000-00-00' WHERE id IN (".Implode(', ',$auswahl).')';
|
||||
$this->app->DB->Update($sql);
|
||||
break;
|
||||
case 'mahnen':
|
||||
|
||||
$mails = 0;
|
||||
$drucke = 0;
|
||||
foreach ($auswahl as $rechnung_id) {
|
||||
$mahnung = $this->MahnwesenMessage($rechnung_id);
|
||||
if (empty($mahnung)) {
|
||||
continue;
|
||||
}
|
||||
if ($mahnung['druck']) {
|
||||
$drucker = $this->app->Secure->GetPOST('seldrucker');
|
||||
if($drucker > 0) {
|
||||
$this->app->erp->BriefpapierHintergrundDisable($drucker);
|
||||
} else {
|
||||
$msg .= "<div class=\"error\">Kein Drucker gewählt.</div>";
|
||||
break;
|
||||
}
|
||||
if(class_exists('RechnungPDFCustom')) {
|
||||
$Brief = new RechnungPDFCustom($this->app,$projekt);
|
||||
}
|
||||
else {
|
||||
$Brief = new RechnungPDF($this->app,$projekt);
|
||||
}
|
||||
$Brief->GetRechnung($rechnung_id,$mahnung['betreff'],0,null,$mahnung['body']);
|
||||
$tmpfile = $Brief->displayTMP();
|
||||
$this->app->printer->Drucken($drucker,$tmpfile);
|
||||
$this->MahnungCRM($mahnung['rechnung'], $mahnung['betreff'], $mahnung['body'],$tmpfile,$Brief->filename);
|
||||
unlink($tmpfile);
|
||||
$this->app->erp->RechnungProtokoll($rechnung_id,'Mahnung gedruckt');
|
||||
$drucke++;
|
||||
}
|
||||
|
||||
if ($mahnung['mail']) {
|
||||
$this->app->erp->RechnungProtokoll($rechnung_id,'Mahnung versendet');
|
||||
$mails++;
|
||||
}
|
||||
|
||||
$sql = "UPDATE rechnung set mahnwesen_datum = CURRENT_DATE, versendet_mahnwesen = 1";
|
||||
$this->app->DB->Update($sql);
|
||||
|
||||
}
|
||||
$msg .= "<div class=\"success\">$mails E-Mails versendet, $drucke Dokumente gedruckt.</div>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
} // ende ausfuehren
|
||||
@ -472,7 +460,7 @@ class Mahnwesen {
|
||||
|
||||
/*
|
||||
* Constuct the Mahnwesen message according to GeschäftsbriefVorlage
|
||||
* Returns Array (string betreff, string body, boolean mail, boolean druck)
|
||||
* Returns Array (string betreff, string body, boolean mail, boolean druck, array rechnung)
|
||||
*/
|
||||
function MahnwesenMessage($rechnung_id) {
|
||||
|
||||
@ -654,9 +642,38 @@ class Mahnwesen {
|
||||
'body' => $body,
|
||||
'mail' => $rechnungarr['mahn_mail'] != 0,
|
||||
'druck' => $rechnungarr['mahn_druck'] != 0,
|
||||
'empfaenger' => $rechnungarr['email']
|
||||
'adresse' => $rechnungarr['adresse'],
|
||||
'empfaenger' => $rechnungarr['email'],
|
||||
'projekt' => $rechnungarr['projekt'],
|
||||
'rechnung' => $rechnungarr
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Create CRM entry for mahnung
|
||||
*/
|
||||
function MahnungCRM(array $rechnung, $betreff, $text, $file, $filename) {
|
||||
$data = array();
|
||||
$data['typ'] = 'brief';
|
||||
$data['projekt'] = $rechnung['projekt'];
|
||||
$data['datum'] = date('Y-m-d');
|
||||
$data['uhrzeit'] = date('Y-m-d H:i:s');
|
||||
$data['user'] = $rechnung['adresse'];
|
||||
$data['an'] = $rechnung['name'];
|
||||
$data['adresse'] = $rechnung['strasse'];
|
||||
$data['plz'] = $rechnung['plz'];
|
||||
$data['ort'] = $rechnung['ort'];
|
||||
$data['betreff'] = $betreff;
|
||||
$data['content'] = $text;
|
||||
$data['sent'] = 1;
|
||||
|
||||
|
||||
/* $data['email'] = $this->app->Secure->GetPOST('email');
|
||||
$data['printer'] = $this->app->Secure->GetPOST('printer');*/
|
||||
|
||||
$crm_id = $this->app->erp->DokumentCreate($data,$this->app->User->GetAdresse());
|
||||
$this->app->erp->CreateDateiWithStichwort($filename,$mahnung['betreff'],"","",$file,$this->app->User->GetName() ,'anhang','dokument',$crm_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user