mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
verbindlichkeit mass processing, prevent approval without positions, get conditions from address
This commit is contained in:
parent
e5393bb7de
commit
6a6aab4304
@ -1,7 +1,7 @@
|
|||||||
<div id="tabs">
|
<div id="tabs">
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="#tabs-1">Verbindlichkeit</a></li>
|
<li><a href="#tabs-1">Verbindlichkeit</a></li>
|
||||||
<li><a href="#tabs-2">Positionen</a></li>
|
<li [POSITIONENHIDDEN]><a href="#tabs-2">Positionen</a></li>
|
||||||
<li><a href="#tabs-3">Protokoll</a></li>
|
<li><a href="#tabs-3">Protokoll</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="tabs-1">
|
<div id="tabs-1">
|
||||||
|
@ -429,7 +429,7 @@ class Verbindlichkeit {
|
|||||||
if (!empty($submit)) {
|
if (!empty($submit)) {
|
||||||
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
$auswahl = $this->app->Secure->GetPOST('auswahl');
|
||||||
$aktion = $this->app->Secure->GetPOST('sel_aktion');
|
$aktion = $this->app->Secure->GetPOST('sel_aktion');
|
||||||
|
|
||||||
$selectedIds = [];
|
$selectedIds = [];
|
||||||
if(!empty($auswahl)) {
|
if(!empty($auswahl)) {
|
||||||
foreach($auswahl as $selectedId) {
|
foreach($auswahl as $selectedId) {
|
||||||
@ -442,21 +442,30 @@ class Verbindlichkeit {
|
|||||||
switch ($aktion) {
|
switch ($aktion) {
|
||||||
case 'freigabeeinkauf':
|
case 'freigabeeinkauf':
|
||||||
foreach ($selectedIds as $id) {
|
foreach ($selectedIds as $id) {
|
||||||
$this->verbindlichkeit_freigabeeinkauf($id);
|
$result = $this->verbindlichkeit_freigabeeinkauf($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'freigabebuchhaltung':
|
case 'freigabebuchhaltung':
|
||||||
foreach ($selectedIds as $id) {
|
foreach ($selectedIds as $id) {
|
||||||
$this->verbindlichkeit_freigabebuchhaltung($id);
|
$result = $this->verbindlichkeit_freigabebuchhaltung($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'bezahlt':
|
case 'bezahlt':
|
||||||
foreach ($selectedIds as $id) {
|
foreach ($selectedIds as $id) {
|
||||||
$this->verbindlichkeit_freigabebezahlt($id);
|
$result = $this->verbindlichkeit_freigabebezahlt($id);
|
||||||
|
if ($result !== true) {
|
||||||
|
$this->app->YUI->Message('warning',$result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht");
|
$this->app->erp->MenuEintrag("index.php?module=verbindlichkeit&action=list", "Übersicht");
|
||||||
@ -466,9 +475,6 @@ class Verbindlichkeit {
|
|||||||
|
|
||||||
$this->app->YUI->TableSearch('TAB1', 'verbindlichkeit_list', "show", "", "", basename(__FILE__), __CLASS__);
|
$this->app->YUI->TableSearch('TAB1', 'verbindlichkeit_list', "show", "", "", basename(__FILE__), __CLASS__);
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
Prepared for later use...
|
|
||||||
|
|
||||||
if($this->app->erp->RechteVorhanden('verbindlichkeit', 'freigabeeinkauf')){
|
if($this->app->erp->RechteVorhanden('verbindlichkeit', 'freigabeeinkauf')){
|
||||||
$this->app->Tpl->Set('MANUELLFREIGABEEINKAUF', '<option value="freigabeeinkauf">{|freigeben (Einkauf)|}</option>');
|
$this->app->Tpl->Set('MANUELLFREIGABEEINKAUF', '<option value="freigabeeinkauf">{|freigeben (Einkauf)|}</option>');
|
||||||
@ -481,7 +487,7 @@ class Verbindlichkeit {
|
|||||||
if($this->app->erp->RechteVorhanden('verbindlichkeit', 'freigabebezahlt')){
|
if($this->app->erp->RechteVorhanden('verbindlichkeit', 'freigabebezahlt')){
|
||||||
$this->app->Tpl->Set('ALSBEZAHLTMARKIEREN', '<option value="bezahlt">{|als bezahlt markieren|}</option>');
|
$this->app->Tpl->Set('ALSBEZAHLTMARKIEREN', '<option value="bezahlt">{|als bezahlt markieren|}</option>');
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
$this->app->User->SetParameter('table_verbindlichkeit_list_zahlbarbis', '');
|
$this->app->User->SetParameter('table_verbindlichkeit_list_zahlbarbis', '');
|
||||||
$this->app->User->SetParameter('table_verbindlichkeit_list_skontobis', '');
|
$this->app->User->SetParameter('table_verbindlichkeit_list_skontobis', '');
|
||||||
|
|
||||||
@ -564,15 +570,24 @@ class Verbindlichkeit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($input['adresse'])) {
|
if (!empty($input['adresse'])) {
|
||||||
$steuertyp = $this->app->DB->Select("SELECT ust_befreit FROM adresse WHERE id = ".$input['adresse']);
|
$adressdaten = $this->app->DB->SelectRow("
|
||||||
|
SELECT
|
||||||
|
zahlungszieltagelieferant,
|
||||||
|
zahlungszieltageskontolieferant,
|
||||||
|
zahlungszielskontolieferant,
|
||||||
|
ust_befreit
|
||||||
|
FROM adresse WHERE id = ".$input['adresse']
|
||||||
|
);
|
||||||
|
|
||||||
if ($steuertyp > 0) {
|
|
||||||
$input['steuersatz_normal'] = '0';
|
if ($input['zahlbarbis'] == '0000-00-00' && $input['rechnungsdatum'] != '0000-00-00' && !empty($adressdaten['zahlungszieltagelieferant'])) {
|
||||||
$input['steuersatz_ermaessigt'] = '0';
|
$input['zahlbarbis'] = date('Y-m-d',strtotime($input['rechnungsdatum']." + ".$adressdaten['zahlungszieltagelieferant']." days"));
|
||||||
} else {
|
|
||||||
$input['steuersatz_normal'] = $this->app->erp->Firmendaten("steuersatz_normal");
|
|
||||||
$input['steuersatz_ermaessigt'] = $this->app->erp->Firmendaten("steuersatz_ermaessigt");
|
|
||||||
}
|
}
|
||||||
|
if ($input['skontobis'] == '0000-00-00' && $input['rechnungsdatum'] != '0000-00-00' && !empty($adressdaten['zahlungszieltageskontolieferant'])) {
|
||||||
|
$input['skontobis'] = date('Y-m-d',strtotime($input['rechnungsdatum']." + ".$adressdaten['zahlungszieltageskontolieferant']." days"));
|
||||||
|
$input['skonto'] = $adressdaten['zahlungszielskontolieferant'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -882,10 +897,13 @@ class Verbindlichkeit {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (empty($verbindlichkeit_from_db['adresse'] || $verbindlichkeit_from_db['status'] == 'angelegt')) {
|
$this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden'); // prevent manual setting
|
||||||
$this->app->Tpl->Set('FREIGABEEINKAUFHIDDEN','hidden');
|
|
||||||
|
if (empty($verbindlichkeit_from_db['adresse']) || $verbindlichkeit_from_db['status'] == 'angelegt') {
|
||||||
$this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden');
|
$this->app->Tpl->Set('FREIGABEBUCHHALTUNGHIDDEN','hidden');
|
||||||
$this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden');
|
$this->app->Tpl->Set('FREIGABEBEZAHLTHIDDEN','hidden');
|
||||||
|
$this->app->Tpl->Set('POSITIONHINZUFUEGENHIDDEN','hidden');
|
||||||
|
$this->app->Tpl->Set('POSITIONENHIDDEN','hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($verbindlichkeit_from_db['freigabe']) {
|
if ($verbindlichkeit_from_db['freigabe']) {
|
||||||
@ -1081,6 +1099,7 @@ class Verbindlichkeit {
|
|||||||
$this->verbindlichkeit_edit();
|
$this->verbindlichkeit_edit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns true or error message
|
||||||
function verbindlichkeit_freigabeeinkauf($id = null, $text = null)
|
function verbindlichkeit_freigabeeinkauf($id = null, $text = null)
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
@ -1088,8 +1107,18 @@ class Verbindlichkeit {
|
|||||||
$gotoedit = true;
|
$gotoedit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check wareneingang status
|
$error = false;
|
||||||
|
|
||||||
|
if (!$this->verbindlichkeit_is_freigegeben($id)) {
|
||||||
|
if ($gotoedit) {
|
||||||
|
$this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
|
||||||
|
$error = true;
|
||||||
|
} else {
|
||||||
|
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check wareneingang status
|
||||||
$sql = "SELECT
|
$sql = "SELECT
|
||||||
pa.id
|
pa.id
|
||||||
FROM verbindlichkeit_position vp
|
FROM verbindlichkeit_position vp
|
||||||
@ -1098,23 +1127,26 @@ class Verbindlichkeit {
|
|||||||
WHERE
|
WHERE
|
||||||
verbindlichkeit='$id'
|
verbindlichkeit='$id'
|
||||||
AND
|
AND
|
||||||
pa.status != 'abgeschlossen'
|
pa.status = 'abgeschlossen'
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
$check = $this->app->DB->SelectArr($sql);
|
$check = $this->app->DB->SelectArr($sql);
|
||||||
|
|
||||||
if (!empty($check)) {
|
if (empty($check)) {
|
||||||
return(false);
|
if ($gotoedit) {
|
||||||
}
|
$this->app->YUI->Message('warning','Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen');
|
||||||
|
} else {
|
||||||
|
return('Waren-/Leistungsprüfung (Einkauf) nicht abgeschlossen '.$this->verbindlichkeit_get_belegnr($id));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sql = "UPDATE verbindlichkeit SET freigabe = 1 WHERE id=".$id;
|
||||||
|
$this->app->DB->Update($sql);
|
||||||
|
|
||||||
$sql = "UPDATE verbindlichkeit SET freigabe = 1 WHERE id=".$id;
|
if (!$text) {
|
||||||
$this->app->DB->Update($sql);
|
$text = "Verbindlichkeit freigegeben (Einkauf)";
|
||||||
|
}
|
||||||
if (!$text) {
|
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,$text);
|
||||||
$text = "Verbindlichkeit freigegeben (Einkauf)";
|
|
||||||
}
|
}
|
||||||
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,$text);
|
|
||||||
if ($gotoedit) {
|
if ($gotoedit) {
|
||||||
$this->verbindlichkeit_edit();
|
$this->verbindlichkeit_edit();
|
||||||
}
|
}
|
||||||
@ -1128,27 +1160,53 @@ class Verbindlichkeit {
|
|||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
$gotoedit = true;
|
$gotoedit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = false;
|
||||||
|
|
||||||
|
if (!$this->verbindlichkeit_is_freigegeben($id)) {
|
||||||
|
if ($gotoedit) {
|
||||||
|
$this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
|
||||||
|
$error = true;
|
||||||
|
} else {
|
||||||
|
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check accounting
|
if (!$error) {
|
||||||
$sql = "
|
// Check accounting
|
||||||
SELECT
|
$sql = "
|
||||||
vp.id
|
SELECT
|
||||||
FROM verbindlichkeit_position vp
|
vp.id,
|
||||||
INNER JOIN artikel art ON art.id = vp.artikel
|
v.belegnr,
|
||||||
LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit
|
skv.id skv_id,
|
||||||
LEFT JOIN adresse adr ON adr.id = v.adresse
|
skart.id skart_id,
|
||||||
LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen
|
skadr.id skadr_id
|
||||||
LEFT JOIN kontorahmen skart ON skart.id = art.kontorahmen
|
FROM verbindlichkeit_position vp
|
||||||
LEFT JOIN kontorahmen skadr ON skadr.id = adr.kontorahmen
|
INNER JOIN artikel art ON art.id = vp.artikel
|
||||||
WHERE verbindlichkeit='$id'
|
LEFT JOIN verbindlichkeit v ON v.id = vp.verbindlichkeit
|
||||||
AND COALESCE(skv.id,0) = 0 AND COALESCE(skart.id,0) = 0 AND COALESCE(skadr.id,0) = 0
|
LEFT JOIN adresse adr ON adr.id = v.adresse
|
||||||
";
|
LEFT JOIN kontorahmen skv ON skv.id = vp.kontorahmen
|
||||||
$check = $this->app->DB->SelectArr($sql);
|
LEFT JOIN kontorahmen skart ON skart.id = art.kontorahmen
|
||||||
|
LEFT JOIN kontorahmen skadr ON skadr.id = adr.kontorahmen
|
||||||
if (!empty($check)) {
|
WHERE
|
||||||
$this->app->YUI->Message('error','Kontierung unvollständig');
|
verbindlichkeit='$id'
|
||||||
} else {
|
AND
|
||||||
|
(
|
||||||
|
COALESCE(skv.id,0) = 0 OR COALESCE(skart.id,0) = 0 OR COALESCE(skadr.id,0) = 0
|
||||||
|
)
|
||||||
|
";
|
||||||
|
if (empty($check)) {
|
||||||
|
if ($gotoedit) {
|
||||||
|
$this->app->YUI->Message('warning','Kontierung unvollständig');
|
||||||
|
$error = true;
|
||||||
|
} else {
|
||||||
|
return('Kontierung unvollständig '.$this->verbindlichkeit_get_belegnr($id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
$sql = "UPDATE verbindlichkeit SET rechnungsfreigabe = 1 WHERE freigabe = 1 AND id=".$id;
|
$sql = "UPDATE verbindlichkeit SET rechnungsfreigabe = 1 WHERE freigabe = 1 AND id=".$id;
|
||||||
$this->app->DB->Update($sql);
|
$this->app->DB->Update($sql);
|
||||||
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)");
|
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit freigegeben (Buchhaltung)");
|
||||||
@ -1156,6 +1214,8 @@ class Verbindlichkeit {
|
|||||||
|
|
||||||
if ($gotoedit) {
|
if ($gotoedit) {
|
||||||
$this->verbindlichkeit_edit();
|
$this->verbindlichkeit_edit();
|
||||||
|
} else {
|
||||||
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1165,12 +1225,24 @@ class Verbindlichkeit {
|
|||||||
$id = $this->app->Secure->GetGET('id');
|
$id = $this->app->Secure->GetGET('id');
|
||||||
$gotoedit = true;
|
$gotoedit = true;
|
||||||
}
|
}
|
||||||
$sql = "UPDATE verbindlichkeit SET bezahlt = 1 WHERE id=".$id;
|
|
||||||
$this->app->DB->Update($sql);
|
if (!$this->verbindlichkeit_is_freigegeben($id)) {
|
||||||
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit als bezahlt markiert");
|
if ($gotoedit) {
|
||||||
if ($gotoedit) {
|
$this->app->YUI->Message('warning','Verbindlichkeit nicht freigebeben');
|
||||||
$this->verbindlichkeit_edit();
|
$error = true;
|
||||||
}
|
} else {
|
||||||
|
return('Verbindlichkeit nicht freigebeben '.$this->verbindlichkeit_get_belegnr($id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
$sql = "UPDATE verbindlichkeit SET bezahlt = 1 WHERE id=".$id;
|
||||||
|
$this->app->DB->Update($sql);
|
||||||
|
$this->app->erp->BelegProtokoll("verbindlichkeit",$id,"Verbindlichkeit als bezahlt markiert");
|
||||||
|
if ($gotoedit) {
|
||||||
|
$this->verbindlichkeit_edit();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function verbindlichkeit_ruecksetzeneinkauf($id = null)
|
function verbindlichkeit_ruecksetzeneinkauf($id = null)
|
||||||
@ -1394,4 +1466,28 @@ class Verbindlichkeit {
|
|||||||
$this->app->Tpl->Parse($parsetarget,'verbindlichkeit_minidetail.tpl');
|
$this->app->Tpl->Parse($parsetarget,'verbindlichkeit_minidetail.tpl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function verbindlichkeit_is_freigegeben($id) {
|
||||||
|
$sql = "SELECT
|
||||||
|
belegnr
|
||||||
|
FROM
|
||||||
|
verbindlichkeit
|
||||||
|
WHERE
|
||||||
|
id='$id'
|
||||||
|
AND
|
||||||
|
status IN ('freigegeben')
|
||||||
|
";
|
||||||
|
|
||||||
|
$check = $this->app->DB->SelectArr($sql);
|
||||||
|
if (empty($check)) {
|
||||||
|
return(false);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function verbindlichkeit_get_belegnr($id) {
|
||||||
|
return($this->app->DB->Select("SELECT belegnr FROM verbindlichkeit WHERE id =".$id));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user