app = $app;
$this->parsetarget = $parsetarget;
parent::__construct($app,$parsetarget);
$this->ExtendsForm();
}
function Create()
{
if($this->app->Secure->GetPOST('gueltig_bis'))
{
$gueltig_bis = $this->app->erp->ReplaceDatum(true,$this->app->Secure->GetPOST('gueltig_bis'),"");
if(!empty($gueltig_bis) && $gueltig_bis != '0000-00-00')
{
$check = $this->app->DB->Select("SELECT '$gueltig_bis' < date(now())");
if($check)
{
$artikel = (int)$this->app->Secure->GetGET("id");
$tagespreise = $this->app->DB->Select("SELECT tagespreise FROM artikel WHERE id = '$artikel' LIMIT 1");
if($tagespreise)
{
$this->app->Tpl->Set('MESSAGE',"
Das Anlegen von alten Tagespreisen ist nicht erlaubt!
");
$this->form->PrintForm();
return;
}
}
}
}
parent::Create();
}
function Edit()
{
if($this->app->Secure->GetPOST('gueltig_bis'))
{
$gueltig_bis = $this->app->erp->ReplaceDatum(true,$this->app->Secure->GetPOST('gueltig_bis'),"");
if(!empty($gueltig_bis) && $gueltig_bis != '0000-00-00')
{
$check = $this->app->DB->Select("SELECT '$gueltig_bis' < date(now())");
if($check)
{
$id = (int)$this->app->Secure->GetGET("id");
$artikel = $this->app->DB->Select("SELECT artikel FROM einkaufspreise WHERE id='$id' LIMIT 1");
$tagespreise = $this->app->DB->Select("SELECT tagespreise FROM artikel WHERE id = '$artikel' LIMIT 1");
if($tagespreise)
{
$this->app->Tpl->Set('MESSAGE',"Das ändern von alten Tagespreisen ist nicht erlaubt!
");
$this->form->PrintForm();
return;
}
}
}
}
if($this->app->Secure->GetPOST('submit'))
{
$id = (int)$this->app->Secure->GetGET("id");
$this->app->erp->ObjektProtokoll('einkaufspreise', $id, 'einkaufspreise_edit', 'Einkaufspreis editiert');
$this->app->DB->Update("UPDATE einkaufspreise SET logdatei = now() WHERE id = '$id' AND logdatei = '0000-00-00 00:00:00' LIMIT 1");
}
parent::Edit();
}
function ExtendsForm()
{
$this->form->ReplaceFunction("adresse",$this,"ReplaceLieferant");
$this->form->ReplaceFunction("vpe",$this,"ReplaceVPE");
$this->form->ReplaceFunction("ab_menge",$this,"ReplaceAb_menge");
$this->form->ReplaceFunction("projekt",$this,"ReplaceProjekt");
$this->form->ReplaceFunction("gueltig_bis",$this,"ReplaceDatum");
$this->form->ReplaceFunction("preis_anfrage_vom",$this,"ReplaceDatum");
$this->form->ReplaceFunction("rahmenvertrag_von",$this,"ReplaceDatum");
$this->form->ReplaceFunction("rahmenvertrag_bis",$this,"ReplaceDatum");
$this->form->ReplaceFunction("datum_lagerlieferant",$this,"ReplaceDatum");
$this->form->ReplaceFunction("preis",$this,"ReplaceBetrag");
$this->app->YUI->AutoComplete("projekt","projektname",1);
$this->app->YUI->AutoComplete("adresse","lieferant");
$this->app->YUI->DatePicker("preis_anfrage_vom");
$this->app->YUI->DatePicker("gueltig_bis");
$this->app->YUI->DatePicker("datum_lagerlieferant");
$this->app->YUI->DatePicker("rahmenvertrag_von");
$this->app->YUI->DatePicker("rahmenvertrag_bis");
$action = $this->app->Secure->GetGET("action");
if($action=="einkauf")
{
// liste zuweisen
$pid = $this->app->Secure->GetGET("id");
$this->app->Secure->POST["artikel"]=$pid;
$field = new HTMLInput("artikel","hidden",$pid);
$this->form->NewField($field);
}
$this->app->Secure->POST["firma"]=$this->app->User->GetFirma();
$field = new HTMLInput("firma","hidden",$this->app->User->GetFirma());
$this->form->NewField($field);
$field = new HTMLSelect("waehrung",0,"waehrung");
$field->AddOption('EUR','EUR');
$field->AddOption('USD','USD');
$field->AddOption('CAD','CAD');
$field->AddOption('CHF','CHF');
$field->AddOption('GBP','GBP');
$this->form->NewField($field);
$this->app->Tpl->Set('VPEPREIS',"= 1?1:0\">");
$this->app->Tpl->Set('PREISTABELLE','');
$_waehrungen = $this->app->erp->GetWaehrungUmrechnungskurseTabelle('EUR');
$waehrungen['EUR'] = 1;
foreach($_waehrungen as $waehrung => $kurs)$waehrungen[$waehrung] = $kurs;
if($_waehrungen)
{
foreach($waehrungen as $k => $v)$waehrung_felder[$k] = $k;
$field = new HTMLSelect("waehrung",1,"waehrung");
$field->AddOptionsAsocSimpleArray($waehrung_felder);
$this->form->NewField($field);
}
$htmltabelle = "
";
$this->app->Tpl->Set('PREISTABELLEPOPUP', $htmltabelle);
}
function ReplaceVPE($db,$value,$fromform)
{
$value = str_replace(',','.',$value);
if($fromform && $value<=0)
return 1;
else return $value;
}
function ReplaceProjekt($db,$value,$fromform)
{
return $this->app->erp->ReplaceProjekt($db,$value,$fromform);
}
function ReplaceDatum($db,$value,$fromform)
{
return $this->app->erp->ReplaceDatum($db,$value,$fromform);
}
function ReplaceBetrag($db,$value,$fromform)
{
return $this->app->erp->ReplaceBetrag($db,$value,$fromform);
}
function ReplaceLieferant($db,$value,$fromform)
{
return $this->app->erp->ReplaceLieferant($db,$value,$fromform);
}
function ReplaceAb_menge($db,$value,$fromform)
{
$value = str_replace(',','.', $value);
return $value >= 0?$value:0;
}
public function Table()
{
$table = new EasyTable($this->app);
$table->Query("SELECT nummer, name_de as name,barcode, id FROM einkaufspreise order by nummer");
$table->Display($this->parsetarget);
}
public function Search()
{
$this->app->Tpl->Set($this->parsetarget,"suchmaske");
//$this->app->Table(
//$table = new OrderTable("veranstalter");
//$table->Heading(array('Name','Homepage','Telefon'));
}
}
?>