Die Testmail wurde nicht versendet: '.$this->app->erp->mail_error.'
'
- );
- }
- $this->app->Location->execute("index.php?module=firmendaten&action=edit&msg=$msg#tabs-4");
- }
-
- public function FirmendatenLogoDownload()
- {
- $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
- if(!$id) {
- $id = $this->app->DB->Select("SELECT MAX(firma) FROM firmendaten LIMIT 1");
- }
- $logo = $this->app->DB->Select("SELECT logo FROM firmendaten WHERE firma='$id'");
- $logo_type = $this->app->erp->Firmendaten('logo_type');
- $endung = str_replace('image/','',$logo_type);
-
- header('Content-type: '.$logo_type);
- header('Content-Disposition: attachment; filename="logo.'.$endung.'"');
- echo base64_decode($logo);
- $this->app->ExitXentral();
- }
-
-
- public function FirmendatenBriefpapierDownload()
- {
- $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
- if(!$id) {
- $id = $this->app->DB->Select("SELECT MAX(firma) FROM firmendaten LIMIT 1");
- }
-
- $cmd = $this->app->Secure->GetGET('cmd');
- switch ($cmd) {
- case 'briefpapier2':
- $briefpapier = $this->app->DB->Select("SELECT briefpapier2 FROM firmendaten WHERE firma='$id'");
- $filename = 'breifpapier2.pdf';
- break;
-
- case 'briefpapier1':
- default:
- $briefpapier = $this->app->DB->Select("SELECT briefpapier FROM firmendaten WHERE firma='$id'");
- $filename = 'breifpapier1.pdf';
- break;
- }
-
- header('Content-type: application/pdf');
- header('Content-Disposition: attachment; filename="' . $filename . '"');
- echo base64_decode($briefpapier);
- $this->app->ExitXentral();
- }
-
- /**
- * @return array
- */
- protected function getPaymentMethods()
- {
- return [
- 'rechnung',
- 'vorkasse',
- 'nachnahme',
- 'lastschrift',
- 'bar',
- 'paypal',
- 'kreditkarte',
- 'amazon',
- 'amazon_bestellung',
- 'secupay',
- 'sofortueberweisung',
- 'ratenzahlung',
- 'eckarte',
- ];
- }
-
- /**
- * @return array
- */
- protected function getPaymentmethodsToHide()
- {
- return $this->app->DB->SelectFirstCols(
- sprintf(
- "SELECT DISTINCT type
- FROM zahlungsweisen
- WHERE aktiv = 1 AND projekt = 0 AND type IN ('%s')",
- implode("', '", $this->getPaymentMethods())
- )
- );
- }
-
- public function FirmendatenEdit()
- {
- if($this->app->Secure->GetPOST('installnewpayent')) {
- $this->checkPaymentModules(true);
- }
- $this->FirmendatenMenu();
- $this->app->erp->Headlines('Grundeinstellungen','Bearbeiten');
- $this->app->erp->MenuEintrag("index.php?module=einstellungen&action=list","Zurück zur Übersicht");
- $this->app->erp->MenuEintrag("index.php?module=firmendaten&action=edit","Übersicht");
-
- $this->app->YUI->CkEditor("signatur","all");
- $this->app->YUI->CkEditor("mailgrussformel","all");
-
- if($this->app->erp->Firmendaten("briefhtml")=="1")
- {
- $this->app->YUI->CkEditor("freitext1inhalt","belege");
- $this->app->YUI->CkEditor("freitext2inhalt","belege");
- }
-
- $this->app->YUI->HideFormular('zeiterfassung_schliessen',array('unchecked'=>'zeiterfassung_schliessen','checked'=>'dummy'));
-
- if($this->app->erp->Firmendaten("briefhtml")=="1")
- {
- $this->app->YUI->CkEditor("angebot_header","belege");
- $this->app->YUI->CkEditor("angebot_footer","belege");
-
- $this->app->YUI->CkEditor("auftrag_header","belege");
- $this->app->YUI->CkEditor("auftrag_footer","belege");
-
- $this->app->YUI->CkEditor("rechnung_header","belege");
- $this->app->YUI->CkEditor("rechnung_footer","belege");
-
- $this->app->YUI->CkEditor("lieferschein_header","belege");
- $this->app->YUI->CkEditor("lieferschein_footer","belege");
-
- $this->app->YUI->CkEditor("gutschrift_header","belege");
- $this->app->YUI->CkEditor("gutschrift_footer","belege");
-
- $this->app->YUI->CkEditor("bestellung_header","belege");
- $this->app->YUI->CkEditor("bestellung_footer","belege");
-
- $this->app->YUI->CkEditor("arbeitsnachweis_header","belege");
- $this->app->YUI->CkEditor("arbeitsnachweis_footer","belege");
-
- $this->app->YUI->CkEditor("provisionsgutschrift_header","belege");
- $this->app->YUI->CkEditor("provisionsgutschrift_footer","belege");
-
- $this->app->YUI->CkEditor("proformarechnung_header","belege");
- $this->app->YUI->CkEditor("proformarechnung_footer","belege");
-
- $this->app->YUI->CkEditor("eu_lieferung_vermerk","belege");
- $this->app->YUI->CkEditor("export_lieferung_vermerk","belege");
-
- $this->app->YUI->CkEditor("footer_reihenfolge_angebot","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_auftrag","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_rechnung","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_gutschrift","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_lieferschein","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_bestellung","belege");
- $this->app->YUI->CkEditor("footer_reihenfolge_proformarechnung","belege");
- }
-
- $this->app->Tpl->Set('MYSQLVERSION',$this->app->DB->Select('SELECT VERSION( ) AS mysql_version'));
-
- if($this->app->erp->Firmendaten("version")==''){
- $this->app->erp->FirmendatenSet("version", $this->app->erp->RevisionPlain());
- }
-
- $lizenz = $this->app->erp->Firmendaten("lizenz");
- $schluessel = $this->app->erp->Firmendaten("schluessel");
- if($lizenz=='' || $schluessel=='')
- {
- if(is_file('../wawision.inc.php'))
- {
- $WAWISION = [];
- include_once('../wawision.inc.php');
- $this->app->erp->FirmendatenSet('lizenz',$WAWISION['serial']);
- $this->app->erp->FirmendatenSet('schluessel',$WAWISION['authkey']);
- }
- }
-
- $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
- if(!$id){
- $id = $this->app->DB->Select('SELECT max(id) FROM firma LIMIT 1');
- }
-
- $this->app->YUI->AutoComplete("projekt","projektname",1);
- $this->app->YUI->AutoComplete("adresse_vorlage","adresse");
- $this->app->YUI->AutoComplete("angebot_pipewiedervorlage","wiedervorlage_stages");
- $this->app->YUI->AutoComplete("group_sales", "gruppekennziffer");
- $this->app->YUI->AutoComplete("group_employee", "gruppekennziffer");
-
- $this->app->Tpl->Set('NEXT_ANGEBOT_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM angebot WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_RECHNUNG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM rechnung WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_AUFTRAG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM auftrag WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_LIEFERSCHEIN_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM lieferschein WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_GUTSCHRIFT_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM gutschrift WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_BESTELLUNG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM bestellung WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
- $this->app->Tpl->Set('NEXT_ARBEITSNACHWEIS_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM arbeitsnachweis WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
-
- $this->app->Tpl->Set('NEXT_KUNDENNUMMER_MAX',$this->app->DB->Select("SELECT MAX(kundennummer) FROM adresse"));
- $this->app->Tpl->Set('NEXT_LIEFERANTENNUMMER_MAX',$this->app->DB->Select("SELECT MAX(lieferantennummer) FROM adresse"));
- $this->app->Tpl->Set('NEXT_MITARBEITERNUMMER_MAX',$this->app->DB->Select("SELECT MAX(mitarbeiternummer) FROM adresse"));
-
- $this->app->Tpl->Set('NEXT_WAREN_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='produkt' OR typ=''"));
- $this->app->Tpl->Set('NEXT_PRODUKTION_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='produktion'"));
- $this->app->Tpl->Set('NEXT_SONSTIGES_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='material' OR typ='fremdleistung' OR typ='gebuehr'"));
-
- $this->app->erp->checkActiveCronjob('cleaner', 'MESSAGECLEANER', false);
-
- // Hole Post-Daten
- $data = $this->getPostData();
-
- $testmail = $this->app->Secure->GetPOST("testmail");
- $submit = $this->app->Secure->GetPOST("submitFirmendaten");
-
- $submitfreifelder = $this->app->Secure->GetPOST("submitFirmendatenFreifelder");
-
- if($submitfreifelder != '') {
- $doubletes = [];
- $firmendaten_werte = $this->app->DB->SelectArr("SELECT * FROM firmendaten_werte");
- if($firmendaten_werte) {
- foreach($firmendaten_werte as $v) {
- $firmendaten_werte_spalten[$v['name']]['wert'] = $this->app->DB->real_escape_string($v['wert']);
- if(!empty($firmendaten_werte_spalten[$v['name']]['id'])) {
- $doubletes[$v['name']][] = $firmendaten_werte_spalten[$v['name']]['id'];
- }
- $firmendaten_werte_spalten[$v['name']]['id'] = $this->app->DB->real_escape_string($v['id']);
- }
- }
- for($i = 1; $i <= 20; $i++) {
- $n1 = 'adressefreifeld'.$i.'typ';
- $n2 = 'adressefreifeld'.$i.'spalte';
- $v1 = $this->app->Secure->GetPOST($n1);
- $v2 = $this->app->Secure->GetPOST($n2);
- $this->app->DB->Update("UPDATE firmendaten SET
- $n1 = '".$v1."', $n2 = '".$v2."'
- WHERE firma='$id' LIMIT 1");
-
- if(isset($firmendaten_werte_spalten)) {
- if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
- if(!empty($doubletes[$n1])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$n1]['id'], $this->app->DB->real_escape_string($n1),
- implode(', ', $doubletes[$n1])
- )
- );
- unset($doubletes[$n1]);
- }
- unset($firmendaten_werte_spalten[$n1]);
- }
- if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
- if(!empty($doubletes[$n2])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$n2]['id'], $this->app->DB->real_escape_string($n2),
- implode(', ', $doubletes[$n2])
- )
- );
- unset($doubletes[$n2]);
- }
- unset($firmendaten_werte_spalten[$n2]);
- }
- }
- }
- for($i = 1; $i <= 20; $i++) {
- $n1 = 'projektfreifeld'.$i.'typ';
- $n2 = 'projektfreifeld'.$i.'spalte';
- $v1 = $this->app->Secure->GetPOST($n1);
- $v2 = $this->app->Secure->GetPOST($n2);
- $this->app->DB->Update("UPDATE firmendaten SET
- $n1 = '".$v1."', $n2 = '".$v2."'
- WHERE firma='$id' LIMIT 1");
-
- if(isset($firmendaten_werte_spalten)) {
- if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n1]);
- if(!empty($doubletes[$n1])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$n1]['id'], $this->app->DB->real_escape_string($n1),
- implode(', ', $doubletes[$n1])
- )
- );
- unset($doubletes[$n1]);
- }
- }
- if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n2]);
- if(!empty($doubletes[$n2])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$n2]['id'], $this->app->DB->real_escape_string($n2),
- implode(', ', $doubletes[$n2])
- )
- );
- unset($doubletes[$n2]);
- }
- }
- }
- }
-
- $toupdate = null;
- for($in = 1; $in <= 40; $in++) {
- $toupdate[] = 'freifeld'.$in;
- }
- for($in = 1; $in <= 20; $in++) {
- $toupdate[] = 'projektfreifeld'.$in;
- }
- for($in = 1; $in <= 20; $in++) {
- $toupdate[] = 'adressefreifeld'.$in;
- }
-
- $sql2a = null;
- foreach($toupdate as $v) {
- $data[$v] = $this->app->Secure->GetPOST($v);
- $sql2a[] = $v ." = '".$data[$v]."' ";
- }
- $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
- unset($sql2a);
- $this->app->DB->Update($sql2);
- if($this->app->DB->error()) {
- foreach($toupdate as $v) {
- $data[$v] = $this->app->Secure->GetPOST($v);
- $this->app->DB->Update("UPDATE firmendaten SET ".$v." = '".($data[$v])."'"." WHERE firma = '$id' LIMIT 1");
- }
- }
- $toupdate[] = 'parameterundfreifelder';
- for($in = 1; $in <= 40; $in++) {
- $freifeldarr = array('typ','spalte','sort','an','ab','re','gs','ls','be','pr','pa','pd');
- foreach($freifeldarr as $v) {
- $toupdate[] = 'freifeld'.$in.$v;
- }
- }
-
- for($in = 1; $in <= 20; $in++) {
- $freifeldarr = array('typ','spalte','sort');
- foreach($freifeldarr as $v)
- {
- $toupdate[] = 'adressefreifeld'.$in.$v;
- }
- $toupdate[] = 'adressefreifeld'.$in;
- }
-
- for($in = 1; $in <= 20; $in++) {
- $freifeldarr = array('sort','tabelle','breite');
- foreach($freifeldarr as $v)
- {
- $toupdate[] = 'projektfreifeld'.$in.$v;
- }
- }
- if(isset($firmendaten_werte_spalten))
- {
- foreach($toupdate as $key)
- {
- $data[$key] = $this->app->Secure->GetPOST($key);
- if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$key]);
- if(!empty($doubletes[$key])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
- }
-
- }
-
- if($submit!='')
- {
- $versandmail_zwischenspeichern = $this->app->erp->Firmendaten('versandmail_zwischenspeichern','', true);
- $error = '';
- $logo_error = '';
- $briefpapier_error = '';
- $firmenlogo_error = '';
-
- // Seite 2
- if(!empty($_FILES['firmenlogo']['tmp_name']) && $_FILES['firmenlogo']['size']>0)
- {
- $firmenlogo_error = $this->app->erp->checkImage($_FILES['firmenlogo'],0,0,0,3);
- if($firmenlogo_error=='')
- {
- if(!($firmenlogo = $this->app->erp->uploadSettigsFile($_FILES['firmenlogo'],'firmenlogo'))){
- $firmenlogo = $this->app->erp->uploadFileIntoDB($_FILES['firmenlogo']);
- }
-
- $this->app->DB->Update("UPDATE firmendaten SET firmenlogo='{$firmenlogo['file']}' WHERE firma='$id'");
- }
- else{
- $error .= "$firmenlogo_error ";
- }
- }
-
- if(!empty($_FILES['logo']['tmp_name']) && $_FILES['logo']['size']>0) {
- $logo_error = $this->app->erp->checkImage($_FILES['logo']);
- if($logo_error=='') {
- if(!($logo = $this->app->erp->uploadSettigsImage($_FILES['logo'],'logo'))){
- $logo = $this->app->erp->uploadImageIntoDB($_FILES['logo']);
- }
- $data['hintergrund'] = 'logo';
- $data['briefpapier2vorhanden'] = 0;
- $this->app->erp->FirmendatenSet('logo_type',$logo['type']);
- $this->app->erp->FirmendatenSet('hintergrund','logo');
- $this->app->DB->Update("UPDATE firmendaten SET logo='{$logo['image']}' WHERE firma='$id' LIMIT 1");
- }
- else{
- $error .= "$logo_error ";
- }
- }
- if ($data['hintergrund'] === 'logo') {
- //pruefe ob logo vorhanden
- $logo = $this->app->erp->getSettingsFile('logo');
- if(strlen($logo)<10){
- $error .= 'Geben Sie bitte ein Logo zum Hochladen an. ';
- }
- }
-
- // Seite 2
- if(!empty($_FILES['briefpapier2']['tmp_name']) && $_FILES['briefpapier2']['size']>0) {
- $briefpapier2_error = $this->app->erp->checkFile($_FILES['briefpapier2'],'application/pdf');
- if($briefpapier2_error=='') {
- if(!($briefpapier2 = $this->app->erp->uploadSettigsFile($_FILES['briefpapier2'],'briefpapier2')))
- {
- $briefpapier2 = $this->app->erp->uploadFileIntoDB($_FILES['briefpapier2']);
- }
- $data['hintergrund'] = 'briefpapier';
- $data['briefpapier2vorhanden'] = 1;
- $this->app->erp->FirmendatenSet('hintergrund','briefpapier');
- $this->app->DB->Update("UPDATE firmendaten SET briefpapier2='{$briefpapier2['file']}' WHERE firma='$id'");
- }
- else{
- $error .= "$briefpapier2_error ";
- }
- }
-
- // Seite 1
- if(!empty($_FILES['briefpapier']['tmp_name']) && $_FILES['briefpapier']['size']>0) {
- $briefpapier_error = $this->app->erp->checkFile($_FILES['briefpapier'],'application/pdf');
- if($briefpapier_error=='') {
- if(!($briefpapier = $this->app->erp->uploadSettigsFile($_FILES['briefpapier'],'briefpapier2'))){
- $briefpapier = $this->app->erp->uploadFileIntoDB($_FILES['briefpapier']);
- }
- $data['hintergrund'] = 'briefpapier';
- $this->app->erp->FirmendatenSet('briefpapier_type',$briefpapier['type']);
- $this->app->erp->FirmendatenSet('hintergrund','briefpapier');
- $this->app->DB->Update("UPDATE firmendaten SET briefpapier='{$briefpapier['file']}' WHERE firma='$id'");
- }
- else{
- $error .= "$briefpapier_error ";
- }
- }
- else{
- $briefpapier = $this->app->erp->getSettingsFile('briefpapier');
- }
-
-
- if(isset($data['sprachebevorzugen'])){
- $this->savePreferredLanguage($data['sprachebevorzugen']);
- }
-
- // Schriftarten-Upload
- if(!empty($_FILES['schriftart_upload'])){
- $fontUploadSuccessful = null;
- $fontUploadName = $this->app->Secure->GetPOST('schriftart_upload_bezeichnung');
-
- $fontUploadSize =
- (int)$_FILES['schriftart_upload']['size']['normal'] +
- (int)$_FILES['schriftart_upload']['size']['kursiv'] +
- (int)$_FILES['schriftart_upload']['size']['fett'] +
- (int)$_FILES['schriftart_upload']['size']['fettkursiv'];
-
- // Es wurde mindestens eine Datei hochgeladen
- if ($fontUploadSize > 0) {
- try {
- // Wenn keine Exception geworfen wurde, dann ist alles hochgeladen.
- $this->HandleFontUpload($fontUploadName, $_FILES['schriftart_upload']);
- $data['schriftart'] = $fontUploadName;
- $fontUploadSuccessful = true;
- } catch (Exception $e) {
- $error .= $e->getMessage() . ' ';
- $fontUploadSuccessful = false;
- }
- }
- }
-
- if($error=='')
- {
- $vorhanden = $this->app->DB->Select("SELECT id FROM firmendaten WHERE firma='$id' LIMIT 1");
-
- if(!is_numeric($vorhanden)) {
- $this->app->DB->Insert("INSERT INTO firmendaten (firma) VALUES ('$id')");
- }
-
- // Update Bilder
-
- // suche max nummern
-
- //suche projekt ID von abkuerzung
-
- $data['projekt'] = $this->app->DB->Select("SELECT id FROM projekt WHERE abkuerzung='{$data['projekt']}' LIMIT 1");
-
- // wenn cloud hole data[lizenz] data[schluessel]
-
- if(!($this->app->Conf->WFcloud==true)) {
- $extendsql = "lizenz='{$data['lizenz']}',
- schluessel='{$data['schluessel']}'";
-
- $this->app->DB->Update("UPDATE firmendaten SET $extendsql WHERE firma='$id' LIMIT 1");
- }
-
-
- $firmendaten_werte = $this->app->DB->SelectArr("SELECT * FROM firmendaten_werte");
- if(!empty($firmendaten_werte)) {
- foreach($firmendaten_werte as $v) {
- $firmendaten_werte_spalten[$v['name']]['wert'] = $this->app->DB->real_escape_string($v['wert']);
- $firmendaten_werte_spalten[$v['name']]['id'] = $this->app->DB->real_escape_string($v['id']);
- }
- }
- $toupdate = array('absender','sichtbar','rechnung_gutschrift_ansprechpartner','knickfalz','standardaufloesung','standardversanddrucker','standardetikettendrucker','etikettendrucker_wareneingang','barcode','aufgaben_bondrucker'
- ,'schriftgroesse','betreffszeile','dokumententext','tabellenbeschriftung','tabelleninhalt','zeilenuntertext','freitext','infobox','brieftext','spaltenbreite','seite_von_sichtbar','seite_von_ausrichtung','footersichtbar','briefpapier2vorhanden'
- ,'hintergrund','benutzername','abstand_adresszeileoben','abstand_boxrechtsoben','abstand_boxrechtsoben_lr','abstand_betreffzeileoben','abstand_artikeltabelleoben','abstand_name_beschreibung','artikel_suche_kurztext'
- ,'adresse_freitext1_suche','artikel_freitext1_suche','artikel_suche_variante_von','artikel_artikelnummer_suche'
- ,'standard_datensaetze_datatables','waehrung','branch'
- ,'warnung_doppelte_nummern','wareneingang_zwischenlager','boxausrichtung'
- ,'footer_breite1','footer_breite2','footer_breite3','footer_breite4','steuersatz_normal','steuersatz_ermaessigt','angebot_ohnebriefpapier','auftrag_ohnebriefpapier','rechnung_ohnebriefpapier',
- 'lieferschein_ohnebriefpapier','gutschrift_ohnebriefpapier','bestellung_ohnebriefpapier','arbeitsnachweis_ohnebriefpapier','externereinkauf'
- ,'projektnummerimdokument','mailanstellesmtp','herstellernummerimdokument','artikeleinheit','artikeleinheit_standard','auftrag_bezeichnung_bearbeiter','auftrag_bezeichnung_bestellnummer','bezeichnungkundennummer'
- ,'auftrag_bezeichnung_vertrieb','standardmarge','schriftart'
- ,'zahlung_rechnung','zahlung_vorkasse','zahlung_nachnahme','zahlung_bar','zahlung_paypal','zahlung_amazon','zahlung_lastschrift','zahlung_kreditkarte','zahlung_ratenzahlung','zahlung_rechnung_sofort_de','zahlung_rechnung_de'
- ,'zahlung_vorkasse_de','zahlung_bar_de','zahlung_lastschrift_de','zahlung_nachnahme_de','zahlung_paypal_de','zahlung_amazon_de','zahlung_kreditkarte_de','zahlung_ratenzahlung_de','zahlungszieltage','zahlungszieltageskonto'
- ,'zahlungszielskonto','kleinunternehmer','schnellanlegen','bestellvorschlaggroessernull','immernettorechnungen','rechnung_header','rechnung_footer',
- 'lieferschein_header','lieferschein_footer','auftrag_header','auftrag_footer','angebot_header','angebot_footer','gutschrift_header','gutschrift_footer','bestellung_header','bestellung_footer',
- 'arbeitsnachweis_header','arbeitsnachweis_footer','provisionsgutschrift_header','provisionsgutschrift_footer','proformarechnung_header','proformarechnung_footer','eu_lieferung_vermerk','export_lieferung_vermerk'
- ,'wareneingang_kamera_waage','layout_iconbar','passwort','host','port','mailssl','signatur','email','absendername','bcc1','bcc2'
- ,'firmenfarbe','name','strasse','plz','ort','steuernummer','projekt','steuer_positionen_export','tabsnavigationfarbe','tabsnavigationfarbeschrift'
- );
-
- if(isset($sql2a)){
- unset($sql2a);
- }
- foreach($toupdate as $v) {
- $sql2a[] = $v ." = '".$data[$v]."' ";
- }
- $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
-
- unset($sql2a);
- $this->app->DB->Update($sql2);
- if($this->app->DB->error()) {
- foreach($toupdate as $v) {
- $this->app->DB->Update("UPDATE firmendaten SET ".$v." = '".($data[$v])."'"." WHERE firma = '$id' LIMIT 1");
- }
- }
-
- if(isset($firmendaten_werte_spalten)) {
- foreach($toupdate as $key) {
- if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$key]);
- if(!empty($doubletes[$key])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
- }
-
-
-
- for($i = 0; $i <= 3; $i++) {
- for($j = 0; $j <= 5; $j++) {
- $toupdate2['footer_'.$i.'_'.$j] = $data['footer'][$i][$j];
- }
- }
-
- foreach($toupdate2 as $k => $v) {
- $sql2a[] = $k ." = '".$v."' ";
- }
- $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
- unset($sql2a);
- $this->app->DB->Update($sql2);
- if($this->app->DB->error()) {
- foreach($toupdate2 as $k => $v) {
- $this->app->DB->Update("UPDATE firmendaten SET ".$k." = '".$v."'"." WHERE firma = '$id' LIMIT 1");
- }
- }
-
- if(isset($firmendaten_werte_spalten)) {
- foreach($toupdate2 as $key => $v) {
- if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $toupdate2[$key])
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$toupdate2[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$key]);
- if(!empty($doubletes[$key])) {
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
- }
-
- $checkDoublettes = [];
- for($i = 1; $i <= 5; $i++) {
- $n1 = 'artikeltabellezusatz'.$i;
- $n2 = 'adressetabellezusatz'.$i;
- $n3 = 'auftragtabellezusatz'.$i;
- $n4 = 'rechnungtabellezusatz'.$i;
- $n5 = 'lieferscheintabellezusatz'.$i;
- $n6 = 'produktiontabellezusatz'.$i;
- $n7 = 'bestellungtabellezusatz'.$i;
- $v1 = $this->app->Secure->GetPOST($n1);
- $v2 = $this->app->Secure->GetPOST($n2);
- $v3 = $this->app->Secure->GetPOST($n3);
- $v4 = $this->app->Secure->GetPOST($n4);
- $v5 = $this->app->Secure->GetPOST($n5);
- $v6 = $this->app->Secure->GetPOST($n6);
- $v7 = $this->app->Secure->GetPOST($n7);
- if(isset($firmendaten_werte_spalten)) {
- if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n1]);
- $checkDoublettes[] = $n1;
- }
- if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n2]);
- $checkDoublettes[] = $n2;
- }
- if(isset($firmendaten_werte_spalten[$n3]) && $firmendaten_werte_spalten[$n3]['wert'] != $v3)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v3' WHERE id = '".$firmendaten_werte_spalten[$n3]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n3]);
- $checkDoublettes[] = $n3;
- }
- if(isset($firmendaten_werte_spalten[$n4]) && $firmendaten_werte_spalten[$n4]['wert'] != $v4)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v4' WHERE id = '".$firmendaten_werte_spalten[$n4]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n4]);
- $checkDoublettes[] = $n4;
- }
- if(isset($firmendaten_werte_spalten[$n5]) && $firmendaten_werte_spalten[$n5]['wert'] != $v5)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v5' WHERE id = '".$firmendaten_werte_spalten[$n5]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n5]);
- $checkDoublettes[] = $n5;
- }
- if(isset($firmendaten_werte_spalten[$n6]) && $firmendaten_werte_spalten[$n6]['wert'] != $v6)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v6' WHERE id = '".$firmendaten_werte_spalten[$n6]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n6]);
- $checkDoublettes[] = $n6;
- }
- if(isset($firmendaten_werte_spalten[$n7]) && $firmendaten_werte_spalten[$n7]['wert'] != $v7)
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v7' WHERE id = '".$firmendaten_werte_spalten[$n7]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$n7]);
- $checkDoublettes[] = $n7;
- }
- }
- }
-
- if(!empty($checkDoublettes) && !empty($doubletes)) {
- foreach($checkDoublettes as $key) {
- if(!empty($doubletes[$key])){
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
-
- $fields = $this->app->erp->GetFirmaFields();
-
- $fields[] = 'produktionsverhalten';
- $fields[] = 'taxfromdoctypesettings';
-
- $sqla = null;
- foreach($fields as $key) {
- if(isset($firmendaten_werte_spalten)) {
- if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key])
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$key]);
- if(!empty($doubletes[$key])){
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
- $sqla[] = " $key='{$data[$key]}' ";
- }
- $sql = "UPDATE firmendaten SET ".implode(', ',$sqla)." WHERE firma='$id' LIMIT 1";
- $this->app->DB->Update($sql);
- if($this->app->DB->error()) {
- foreach($fields as $key) {
- $this->app->DB->Update("UPDATE firmendaten SET $key='{$data[$key]}' WHERE firma='$id' LIMIT 1");
- }
- }
- $fields_checkbox = $this->app->erp->GetFirmaFieldsCheckbox();
-
- if(isset($sqla)){
- unset($sqla);
- }
- foreach($fields_checkbox as $key) {
- $_data[$key] = $data[$key];
- if($_data[$key] === 'checked'){
- $_data[$key] = 1;
- }
- $_data[$key] = (int)$_data[$key];
- $sqla[] = " $key='{$_data[$key]}' ";
- if(isset($firmendaten_werte_spalten) && isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $_data[$key])
- {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$_data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- if(in_array($key,array('begrenzen_belege','begrenzen_artikeltabelle','begrenzen_adressetabelle')))
- {
- $this->app->erp->SetKonfigurationValue('firmendaten_'.$key.'_gesetzt', 1);
- }
- unset($firmendaten_werte_spalten[$key]);
- }
- }
- $sql = "UPDATE firmendaten SET ".implode(', ',$sqla)." WHERE firma='$id' LIMIT 1";
- $this->app->DB->Update($sql);
- if($this->app->DB->error()) {
- foreach($fields_checkbox as $key) {
- $_data[$key] = $data[$key];
- if($_data[$key] === 'checked'){
- $_data[$key] = 1;
- }
- $_data[$key] = (int)$_data[$key];
- $this->app->DB->Update("UPDATE firmendaten SET $key='{$_data[$key]}' WHERE firma='$id' LIMIT 1");
- }
- }
-
- $firmendaten = $this->app->DB->SelectArr("SELECT * FROM firmendaten WHERE firma='$id' LIMIT 1");
- if($firmendaten && isset($firmendaten_werte_spalten)) {
- foreach($firmendaten[0] as $key => $v) {
- if($key !== 'id' && isset($data[$key])) {
- if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
- $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
- unset($firmendaten_werte_spalten[$key]);
- if(!empty($doubletes[$key])){
- $this->app->DB->Delete(
- sprintf(
- "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
- $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
- implode(', ', $doubletes[$key])
- )
- );
- unset($doubletes[$key]);
- }
- }
- }
- }
- }
-
- $this->app->DB->Update("UPDATE firma SET name='{$data[name]}', standardprojekt='{$data[projekt]}' WHERE id='$id' LIMIT 1");
-
- $this->app->Tpl->Set('MESSAGE', "
Ihre Daten wurden erfolgreich gespeichert.
");
- $this->FillFormFromDB($id);
- }
- else {
- // Im Fehlerfall sollen das Formular mit den POST-Daten gefuellt werden
- $this->app->Tpl->Set('MESSAGE', "
$error
");
- $this->fillForm($data);
- }
- if(!$versandmail_zwischenspeichern && $this->app->erp->Firmendaten('versandmail_zwischenspeichern','',true) &&
- !$this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'versandmailsundrueckmeldung' AND aktiv = 1")){
- $this->app->DB->Update("UPDATE prozessstarter SET aktiv = 1 WHERE parameter = 'versandmailsundrueckmeldung' LIMIT 1");
- }
- }
- else{
- $this->FillFormFromDB($id);
- }
-
- if($this->app->erp->Firmendaten('versandmail_zwischenspeichern',"",true)){
- $this->app->erp->checkActiveCronjob('versandmailsundrueckmeldung', 'MESSAGEMAILS', false);
- }
-
- if (isset($fontUploadSuccessful) && $fontUploadSuccessful === true){
- $this->app->Tpl->Add('MESSAGE',
- sprintf('
Die Schriftart "%s" wurde erfolgreich hochgeladen und in den Einstellungen hinterlegt. Bitte Testen Sie die Einstellung durch Generierung eines Belegs.
Die Dateigröße von ca. ' . round($hintergrund_size / 1000) . ' KB vom ' . ucfirst($hintergrund) . ' ist zu groß. Das ' . ucfirst($hintergrund) . ' sollte unter 100 KB sein.
- Ab der Version 20.1 sind alle Zahlweisen in das Modul Zahlweisen verlagert worden.
- Sie sehen diese Meldung weil Sie vor der Version 20.1 mit Xentral gestartet hatten.
- Wenn Sie auf das neue Modul welchseln möchten
- (bitte nur nachdem Sie es in einem Testsystem geprüft hatten)
- können Sie das gerne hier mit dem Button durchführen.
-
-
-
-
Die Testmail wurde nicht versendet: '.$this->app->erp->mail_error.'
'
+ );
+ }
+ $this->app->Location->execute("index.php?module=firmendaten&action=edit&msg=$msg#tabs-4");
+ }
+
+ public function FirmendatenLogoDownload()
+ {
+ $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
+ if(!$id) {
+ $id = $this->app->DB->Select("SELECT MAX(firma) FROM firmendaten LIMIT 1");
+ }
+ $logo = $this->app->DB->Select("SELECT logo FROM firmendaten WHERE firma='$id'");
+ $logo_type = $this->app->erp->Firmendaten('logo_type');
+ $endung = str_replace('image/','',$logo_type);
+
+ header('Content-type: '.$logo_type);
+ header('Content-Disposition: attachment; filename="logo.'.$endung.'"');
+ echo base64_decode($logo);
+ $this->app->ExitXentral();
+ }
+
+
+ public function FirmendatenBriefpapierDownload()
+ {
+ $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
+ if(!$id) {
+ $id = $this->app->DB->Select("SELECT MAX(firma) FROM firmendaten LIMIT 1");
+ }
+
+ $cmd = $this->app->Secure->GetGET('cmd');
+ switch ($cmd) {
+ case 'briefpapier2':
+ $briefpapier = $this->app->DB->Select("SELECT briefpapier2 FROM firmendaten WHERE firma='$id'");
+ $filename = 'breifpapier2.pdf';
+ break;
+
+ case 'briefpapier1':
+ default:
+ $briefpapier = $this->app->DB->Select("SELECT briefpapier FROM firmendaten WHERE firma='$id'");
+ $filename = 'breifpapier1.pdf';
+ break;
+ }
+
+ header('Content-type: application/pdf');
+ header('Content-Disposition: attachment; filename="' . $filename . '"');
+ echo base64_decode($briefpapier);
+ $this->app->ExitXentral();
+ }
+
+ /**
+ * @return array
+ */
+ protected function getPaymentMethods()
+ {
+ return [
+ 'rechnung',
+ 'vorkasse',
+ 'nachnahme',
+ 'lastschrift',
+ 'bar',
+ 'paypal',
+ 'kreditkarte',
+ 'amazon',
+ 'amazon_bestellung',
+ 'secupay',
+ 'sofortueberweisung',
+ 'ratenzahlung',
+ 'eckarte',
+ ];
+ }
+
+ /**
+ * @return array
+ */
+ protected function getPaymentmethodsToHide()
+ {
+ return $this->app->DB->SelectFirstCols(
+ sprintf(
+ "SELECT DISTINCT type
+ FROM zahlungsweisen
+ WHERE aktiv = 1 AND projekt = 0 AND type IN ('%s')",
+ implode("', '", $this->getPaymentMethods())
+ )
+ );
+ }
+
+ public function FirmendatenEdit()
+ {
+ if($this->app->Secure->GetPOST('installnewpayent')) {
+ $this->checkPaymentModules(true);
+ }
+ $this->FirmendatenMenu();
+ $this->app->erp->Headlines('Grundeinstellungen','Bearbeiten');
+ $this->app->erp->MenuEintrag("index.php?module=einstellungen&action=list","Zurück zur Übersicht");
+ $this->app->erp->MenuEintrag("index.php?module=firmendaten&action=edit","Übersicht");
+
+ $this->app->YUI->CkEditor("signatur","all");
+ $this->app->YUI->CkEditor("mailgrussformel","all");
+
+ if($this->app->erp->Firmendaten("briefhtml")=="1")
+ {
+ $this->app->YUI->CkEditor("freitext1inhalt","belege");
+ $this->app->YUI->CkEditor("freitext2inhalt","belege");
+ }
+
+ $this->app->YUI->HideFormular('zeiterfassung_schliessen',array('unchecked'=>'zeiterfassung_schliessen','checked'=>'dummy'));
+
+ if($this->app->erp->Firmendaten("briefhtml")=="1")
+ {
+ $this->app->YUI->CkEditor("angebot_header","belege");
+ $this->app->YUI->CkEditor("angebot_footer","belege");
+
+ $this->app->YUI->CkEditor("auftrag_header","belege");
+ $this->app->YUI->CkEditor("auftrag_footer","belege");
+
+ $this->app->YUI->CkEditor("rechnung_header","belege");
+ $this->app->YUI->CkEditor("rechnung_footer","belege");
+
+ $this->app->YUI->CkEditor("lieferschein_header","belege");
+ $this->app->YUI->CkEditor("lieferschein_footer","belege");
+
+ $this->app->YUI->CkEditor("gutschrift_header","belege");
+ $this->app->YUI->CkEditor("gutschrift_footer","belege");
+
+ $this->app->YUI->CkEditor("bestellung_header","belege");
+ $this->app->YUI->CkEditor("bestellung_footer","belege");
+
+ $this->app->YUI->CkEditor("arbeitsnachweis_header","belege");
+ $this->app->YUI->CkEditor("arbeitsnachweis_footer","belege");
+
+ $this->app->YUI->CkEditor("provisionsgutschrift_header","belege");
+ $this->app->YUI->CkEditor("provisionsgutschrift_footer","belege");
+
+ $this->app->YUI->CkEditor("proformarechnung_header","belege");
+ $this->app->YUI->CkEditor("proformarechnung_footer","belege");
+
+ $this->app->YUI->CkEditor("eu_lieferung_vermerk","belege");
+ $this->app->YUI->CkEditor("export_lieferung_vermerk","belege");
+
+ $this->app->YUI->CkEditor("footer_reihenfolge_angebot","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_auftrag","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_rechnung","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_gutschrift","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_lieferschein","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_bestellung","belege");
+ $this->app->YUI->CkEditor("footer_reihenfolge_proformarechnung","belege");
+ }
+
+ $this->app->Tpl->Set('MYSQLVERSION',$this->app->DB->Select('SELECT VERSION( ) AS mysql_version'));
+
+ if($this->app->erp->Firmendaten("version")==''){
+ $this->app->erp->FirmendatenSet("version", $this->app->erp->RevisionPlain());
+ }
+
+ $lizenz = $this->app->erp->Firmendaten("lizenz");
+ $schluessel = $this->app->erp->Firmendaten("schluessel");
+ if($lizenz=='' || $schluessel=='')
+ {
+ if(is_file('../wawision.inc.php'))
+ {
+ $WAWISION = [];
+ include_once('../wawision.inc.php');
+ $this->app->erp->FirmendatenSet('lizenz',$WAWISION['serial']);
+ $this->app->erp->FirmendatenSet('schluessel',$WAWISION['authkey']);
+ }
+ }
+
+ $id = $this->app->DB->Select("SELECT MAX(f.id) FROM firma f INNER JOIN firmendaten fd ON f.id = fd.firma LIMIT 1");
+ if(!$id){
+ $id = $this->app->DB->Select('SELECT max(id) FROM firma LIMIT 1');
+ }
+
+ $this->app->YUI->AutoComplete("projekt","projektname",1);
+ $this->app->YUI->AutoComplete("adresse_vorlage","adresse");
+ $this->app->YUI->AutoComplete("angebot_pipewiedervorlage","wiedervorlage_stages");
+ $this->app->YUI->AutoComplete("group_sales", "gruppekennziffer");
+ $this->app->YUI->AutoComplete("group_employee", "gruppekennziffer");
+
+ $this->app->Tpl->Set('NEXT_ANGEBOT_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM angebot WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+ $this->app->Tpl->Set('NEXT_RECHNUNG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM rechnung WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+ $this->app->Tpl->Set('NEXT_AUFTRAG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM auftrag WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+ $this->app->Tpl->Set('NEXT_LIEFERSCHEIN_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM lieferschein WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+ $this->app->Tpl->Set('NEXT_GUTSCHRIFT_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM gutschrift WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+ $this->app->Tpl->Set('NEXT_BESTELLUNG_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM bestellung WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+// $this->app->Tpl->Set('NEXT_ARBEITSNACHWEIS_MAX',$this->app->DB->Select("SELECT MAX(belegnr) FROM arbeitsnachweis WHERE DATE_FORMAT(datum,'%Y')=DATE_FORMAT(NOW(),'%Y')"));
+
+ $this->app->Tpl->Set('NEXT_KUNDENNUMMER_MAX',$this->app->DB->Select("SELECT MAX(kundennummer) FROM adresse"));
+ $this->app->Tpl->Set('NEXT_LIEFERANTENNUMMER_MAX',$this->app->DB->Select("SELECT MAX(lieferantennummer) FROM adresse"));
+ $this->app->Tpl->Set('NEXT_MITARBEITERNUMMER_MAX',$this->app->DB->Select("SELECT MAX(mitarbeiternummer) FROM adresse"));
+
+ $this->app->Tpl->Set('NEXT_WAREN_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='produkt' OR typ=''"));
+ $this->app->Tpl->Set('NEXT_PRODUKTION_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='produktion'"));
+ $this->app->Tpl->Set('NEXT_SONSTIGES_MAX',$this->app->DB->Select("SELECT MAX(nummer) FROM artikel WHERE typ='material' OR typ='fremdleistung' OR typ='gebuehr'"));
+
+ $this->app->erp->checkActiveCronjob('cleaner', 'MESSAGECLEANER', false);
+
+ // Hole Post-Daten
+ $data = $this->getPostData();
+
+ $testmail = $this->app->Secure->GetPOST("testmail");
+ $submit = $this->app->Secure->GetPOST("submitFirmendaten");
+
+ $submitfreifelder = $this->app->Secure->GetPOST("submitFirmendatenFreifelder");
+
+ if($submitfreifelder != '') {
+ $doubletes = [];
+ $firmendaten_werte = $this->app->DB->SelectArr("SELECT * FROM firmendaten_werte");
+ if($firmendaten_werte) {
+ foreach($firmendaten_werte as $v) {
+ $firmendaten_werte_spalten[$v['name']]['wert'] = $this->app->DB->real_escape_string($v['wert']);
+ if(!empty($firmendaten_werte_spalten[$v['name']]['id'])) {
+ $doubletes[$v['name']][] = $firmendaten_werte_spalten[$v['name']]['id'];
+ }
+ $firmendaten_werte_spalten[$v['name']]['id'] = $this->app->DB->real_escape_string($v['id']);
+ }
+ }
+ for($i = 1; $i <= 20; $i++) {
+ $n1 = 'adressefreifeld'.$i.'typ';
+ $n2 = 'adressefreifeld'.$i.'spalte';
+ $v1 = $this->app->Secure->GetPOST($n1);
+ $v2 = $this->app->Secure->GetPOST($n2);
+ $this->app->DB->Update("UPDATE firmendaten SET
+ $n1 = '".$v1."', $n2 = '".$v2."'
+ WHERE firma='$id' LIMIT 1");
+
+ if(isset($firmendaten_werte_spalten)) {
+ if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
+ if(!empty($doubletes[$n1])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$n1]['id'], $this->app->DB->real_escape_string($n1),
+ implode(', ', $doubletes[$n1])
+ )
+ );
+ unset($doubletes[$n1]);
+ }
+ unset($firmendaten_werte_spalten[$n1]);
+ }
+ if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
+ if(!empty($doubletes[$n2])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$n2]['id'], $this->app->DB->real_escape_string($n2),
+ implode(', ', $doubletes[$n2])
+ )
+ );
+ unset($doubletes[$n2]);
+ }
+ unset($firmendaten_werte_spalten[$n2]);
+ }
+ }
+ }
+ for($i = 1; $i <= 20; $i++) {
+ $n1 = 'projektfreifeld'.$i.'typ';
+ $n2 = 'projektfreifeld'.$i.'spalte';
+ $v1 = $this->app->Secure->GetPOST($n1);
+ $v2 = $this->app->Secure->GetPOST($n2);
+ $this->app->DB->Update("UPDATE firmendaten SET
+ $n1 = '".$v1."', $n2 = '".$v2."'
+ WHERE firma='$id' LIMIT 1");
+
+ if(isset($firmendaten_werte_spalten)) {
+ if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n1]);
+ if(!empty($doubletes[$n1])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$n1]['id'], $this->app->DB->real_escape_string($n1),
+ implode(', ', $doubletes[$n1])
+ )
+ );
+ unset($doubletes[$n1]);
+ }
+ }
+ if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n2]);
+ if(!empty($doubletes[$n2])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$n2]['id'], $this->app->DB->real_escape_string($n2),
+ implode(', ', $doubletes[$n2])
+ )
+ );
+ unset($doubletes[$n2]);
+ }
+ }
+ }
+ }
+
+ $toupdate = null;
+ for($in = 1; $in <= 40; $in++) {
+ $toupdate[] = 'freifeld'.$in;
+ }
+ for($in = 1; $in <= 20; $in++) {
+ $toupdate[] = 'projektfreifeld'.$in;
+ }
+ for($in = 1; $in <= 20; $in++) {
+ $toupdate[] = 'adressefreifeld'.$in;
+ }
+
+ $sql2a = null;
+ foreach($toupdate as $v) {
+ $data[$v] = $this->app->Secure->GetPOST($v);
+ $sql2a[] = $v ." = '".$data[$v]."' ";
+ }
+ $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
+ unset($sql2a);
+ $this->app->DB->Update($sql2);
+ if($this->app->DB->error()) {
+ foreach($toupdate as $v) {
+ $data[$v] = $this->app->Secure->GetPOST($v);
+ $this->app->DB->Update("UPDATE firmendaten SET ".$v." = '".($data[$v])."'"." WHERE firma = '$id' LIMIT 1");
+ }
+ }
+ $toupdate[] = 'parameterundfreifelder';
+ for($in = 1; $in <= 40; $in++) {
+ $freifeldarr = array('typ','spalte','sort','an','ab','re','gs','ls','be','pr','pa','pd');
+ foreach($freifeldarr as $v) {
+ $toupdate[] = 'freifeld'.$in.$v;
+ }
+ }
+
+ for($in = 1; $in <= 20; $in++) {
+ $freifeldarr = array('typ','spalte','sort');
+ foreach($freifeldarr as $v)
+ {
+ $toupdate[] = 'adressefreifeld'.$in.$v;
+ }
+ $toupdate[] = 'adressefreifeld'.$in;
+ }
+
+ for($in = 1; $in <= 20; $in++) {
+ $freifeldarr = array('sort','tabelle','breite');
+ foreach($freifeldarr as $v)
+ {
+ $toupdate[] = 'projektfreifeld'.$in.$v;
+ }
+ }
+ if(isset($firmendaten_werte_spalten))
+ {
+ foreach($toupdate as $key)
+ {
+ $data[$key] = $this->app->Secure->GetPOST($key);
+ if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$key]);
+ if(!empty($doubletes[$key])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+ }
+
+ }
+
+ if($submit!='')
+ {
+ $versandmail_zwischenspeichern = $this->app->erp->Firmendaten('versandmail_zwischenspeichern','', true);
+ $error = '';
+ $logo_error = '';
+ $briefpapier_error = '';
+ $firmenlogo_error = '';
+
+ // Seite 2
+ if(!empty($_FILES['firmenlogo']['tmp_name']) && $_FILES['firmenlogo']['size']>0)
+ {
+ $firmenlogo_error = $this->app->erp->checkImage($_FILES['firmenlogo'],0,0,0,3);
+ if($firmenlogo_error=='')
+ {
+ if(!($firmenlogo = $this->app->erp->uploadSettigsFile($_FILES['firmenlogo'],'firmenlogo'))){
+ $firmenlogo = $this->app->erp->uploadFileIntoDB($_FILES['firmenlogo']);
+ }
+
+ $this->app->DB->Update("UPDATE firmendaten SET firmenlogo='{$firmenlogo['file']}' WHERE firma='$id'");
+ }
+ else{
+ $error .= "$firmenlogo_error ";
+ }
+ }
+
+ if(!empty($_FILES['logo']['tmp_name']) && $_FILES['logo']['size']>0) {
+ $logo_error = $this->app->erp->checkImage($_FILES['logo']);
+ if($logo_error=='') {
+ if(!($logo = $this->app->erp->uploadSettigsImage($_FILES['logo'],'logo'))){
+ $logo = $this->app->erp->uploadImageIntoDB($_FILES['logo']);
+ }
+ $data['hintergrund'] = 'logo';
+ $data['briefpapier2vorhanden'] = 0;
+ $this->app->erp->FirmendatenSet('logo_type',$logo['type']);
+ $this->app->erp->FirmendatenSet('hintergrund','logo');
+ $this->app->DB->Update("UPDATE firmendaten SET logo='{$logo['image']}' WHERE firma='$id' LIMIT 1");
+ }
+ else{
+ $error .= "$logo_error ";
+ }
+ }
+ if ($data['hintergrund'] === 'logo') {
+ //pruefe ob logo vorhanden
+ $logo = $this->app->erp->getSettingsFile('logo');
+ if(strlen($logo)<10){
+ $error .= 'Geben Sie bitte ein Logo zum Hochladen an. ';
+ }
+ }
+
+ // Seite 2
+ if(!empty($_FILES['briefpapier2']['tmp_name']) && $_FILES['briefpapier2']['size']>0) {
+ $briefpapier2_error = $this->app->erp->checkFile($_FILES['briefpapier2'],'application/pdf');
+ if($briefpapier2_error=='') {
+ if(!($briefpapier2 = $this->app->erp->uploadSettigsFile($_FILES['briefpapier2'],'briefpapier2')))
+ {
+ $briefpapier2 = $this->app->erp->uploadFileIntoDB($_FILES['briefpapier2']);
+ }
+ $data['hintergrund'] = 'briefpapier';
+ $data['briefpapier2vorhanden'] = 1;
+ $this->app->erp->FirmendatenSet('hintergrund','briefpapier');
+ $this->app->DB->Update("UPDATE firmendaten SET briefpapier2='{$briefpapier2['file']}' WHERE firma='$id'");
+ }
+ else{
+ $error .= "$briefpapier2_error ";
+ }
+ }
+
+ // Seite 1
+ if(!empty($_FILES['briefpapier']['tmp_name']) && $_FILES['briefpapier']['size']>0) {
+ $briefpapier_error = $this->app->erp->checkFile($_FILES['briefpapier'],'application/pdf');
+ if($briefpapier_error=='') {
+ if(!($briefpapier = $this->app->erp->uploadSettigsFile($_FILES['briefpapier'],'briefpapier2'))){
+ $briefpapier = $this->app->erp->uploadFileIntoDB($_FILES['briefpapier']);
+ }
+ $data['hintergrund'] = 'briefpapier';
+ $this->app->erp->FirmendatenSet('briefpapier_type',$briefpapier['type']);
+ $this->app->erp->FirmendatenSet('hintergrund','briefpapier');
+ $this->app->DB->Update("UPDATE firmendaten SET briefpapier='{$briefpapier['file']}' WHERE firma='$id'");
+ }
+ else{
+ $error .= "$briefpapier_error ";
+ }
+ }
+ else{
+ $briefpapier = $this->app->erp->getSettingsFile('briefpapier');
+ }
+
+
+ if(isset($data['sprachebevorzugen'])){
+ $this->savePreferredLanguage($data['sprachebevorzugen']);
+ }
+
+ // Schriftarten-Upload
+ if(!empty($_FILES['schriftart_upload'])){
+ $fontUploadSuccessful = null;
+ $fontUploadName = $this->app->Secure->GetPOST('schriftart_upload_bezeichnung');
+
+ $fontUploadSize =
+ (int)$_FILES['schriftart_upload']['size']['normal'] +
+ (int)$_FILES['schriftart_upload']['size']['kursiv'] +
+ (int)$_FILES['schriftart_upload']['size']['fett'] +
+ (int)$_FILES['schriftart_upload']['size']['fettkursiv'];
+
+ // Es wurde mindestens eine Datei hochgeladen
+ if ($fontUploadSize > 0) {
+ try {
+ // Wenn keine Exception geworfen wurde, dann ist alles hochgeladen.
+ $this->HandleFontUpload($fontUploadName, $_FILES['schriftart_upload']);
+ $data['schriftart'] = $fontUploadName;
+ $fontUploadSuccessful = true;
+ } catch (Exception $e) {
+ $error .= $e->getMessage() . ' ';
+ $fontUploadSuccessful = false;
+ }
+ }
+ }
+
+ if($error=='')
+ {
+ $vorhanden = $this->app->DB->Select("SELECT id FROM firmendaten WHERE firma='$id' LIMIT 1");
+
+ if(!is_numeric($vorhanden)) {
+ $this->app->DB->Insert("INSERT INTO firmendaten (firma) VALUES ('$id')");
+ }
+
+ // Update Bilder
+
+ // suche max nummern
+
+ //suche projekt ID von abkuerzung
+
+ $data['projekt'] = $this->app->DB->Select("SELECT id FROM projekt WHERE abkuerzung='{$data['projekt']}' LIMIT 1");
+
+ // wenn cloud hole data[lizenz] data[schluessel]
+
+ if(!($this->app->Conf->WFcloud==true)) {
+ $extendsql = "lizenz='{$data['lizenz']}',
+ schluessel='{$data['schluessel']}'";
+
+ $this->app->DB->Update("UPDATE firmendaten SET $extendsql WHERE firma='$id' LIMIT 1");
+ }
+
+
+ $firmendaten_werte = $this->app->DB->SelectArr("SELECT * FROM firmendaten_werte");
+ if(!empty($firmendaten_werte)) {
+ foreach($firmendaten_werte as $v) {
+ $firmendaten_werte_spalten[$v['name']]['wert'] = $this->app->DB->real_escape_string($v['wert']);
+ $firmendaten_werte_spalten[$v['name']]['id'] = $this->app->DB->real_escape_string($v['id']);
+ }
+ }
+ $toupdate = array('absender','sichtbar','rechnung_gutschrift_ansprechpartner','knickfalz','standardaufloesung','standardversanddrucker','standardetikettendrucker','etikettendrucker_wareneingang','barcode','aufgaben_bondrucker'
+ ,'schriftgroesse','betreffszeile','dokumententext','tabellenbeschriftung','tabelleninhalt','zeilenuntertext','freitext','infobox','brieftext','spaltenbreite','seite_von_sichtbar','seite_von_ausrichtung','footersichtbar','briefpapier2vorhanden'
+ ,'hintergrund','benutzername','abstand_adresszeileoben','abstand_boxrechtsoben','abstand_boxrechtsoben_lr','abstand_betreffzeileoben','abstand_artikeltabelleoben','abstand_name_beschreibung','artikel_suche_kurztext'
+ ,'adresse_freitext1_suche','artikel_freitext1_suche','artikel_suche_variante_von','artikel_artikelnummer_suche'
+ ,'standard_datensaetze_datatables','waehrung','branch'
+ ,'warnung_doppelte_nummern','wareneingang_zwischenlager','boxausrichtung'
+ ,'footer_breite1','footer_breite2','footer_breite3','footer_breite4','steuersatz_normal','steuersatz_ermaessigt','angebot_ohnebriefpapier','auftrag_ohnebriefpapier','rechnung_ohnebriefpapier',
+ 'lieferschein_ohnebriefpapier','gutschrift_ohnebriefpapier','bestellung_ohnebriefpapier','arbeitsnachweis_ohnebriefpapier','externereinkauf'
+ ,'projektnummerimdokument','mailanstellesmtp','herstellernummerimdokument','artikeleinheit','artikeleinheit_standard','auftrag_bezeichnung_bearbeiter','auftrag_bezeichnung_bestellnummer','bezeichnungkundennummer'
+ ,'auftrag_bezeichnung_vertrieb','standardmarge','schriftart'
+ ,'zahlung_rechnung','zahlung_vorkasse','zahlung_nachnahme','zahlung_bar','zahlung_paypal','zahlung_amazon','zahlung_lastschrift','zahlung_kreditkarte','zahlung_ratenzahlung','zahlung_rechnung_sofort_de','zahlung_rechnung_de'
+ ,'zahlung_vorkasse_de','zahlung_bar_de','zahlung_lastschrift_de','zahlung_nachnahme_de','zahlung_paypal_de','zahlung_amazon_de','zahlung_kreditkarte_de','zahlung_ratenzahlung_de','zahlungszieltage','zahlungszieltageskonto'
+ ,'zahlungszielskonto','kleinunternehmer','schnellanlegen','bestellvorschlaggroessernull','immernettorechnungen','rechnung_header','rechnung_footer',
+ 'lieferschein_header','lieferschein_footer','auftrag_header','auftrag_footer','angebot_header','angebot_footer','gutschrift_header','gutschrift_footer','bestellung_header','bestellung_footer',
+ 'arbeitsnachweis_header','arbeitsnachweis_footer','provisionsgutschrift_header','provisionsgutschrift_footer','proformarechnung_header','proformarechnung_footer','eu_lieferung_vermerk','export_lieferung_vermerk'
+ ,'wareneingang_kamera_waage','layout_iconbar','passwort','host','port','mailssl','signatur','email','absendername','bcc1','bcc2'
+ ,'firmenfarbe','name','strasse','plz','ort','steuernummer','projekt','steuer_positionen_export','tabsnavigationfarbe','tabsnavigationfarbeschrift'
+ );
+
+ if(isset($sql2a)){
+ unset($sql2a);
+ }
+ foreach($toupdate as $v) {
+ $sql2a[] = $v ." = '".$data[$v]."' ";
+ }
+ $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
+
+ unset($sql2a);
+ $this->app->DB->Update($sql2);
+ if($this->app->DB->error()) {
+ foreach($toupdate as $v) {
+ $this->app->DB->Update("UPDATE firmendaten SET ".$v." = '".($data[$v])."'"." WHERE firma = '$id' LIMIT 1");
+ }
+ }
+
+ if(isset($firmendaten_werte_spalten)) {
+ foreach($toupdate as $key) {
+ if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$key]);
+ if(!empty($doubletes[$key])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+ }
+
+
+
+ for($i = 0; $i <= 3; $i++) {
+ for($j = 0; $j <= 5; $j++) {
+ $toupdate2['footer_'.$i.'_'.$j] = $data['footer'][$i][$j];
+ }
+ }
+
+ foreach($toupdate2 as $k => $v) {
+ $sql2a[] = $k ." = '".$v."' ";
+ }
+ $sql2 = "UPDATE firmendaten SET ".implode(',',$sql2a)." WHERE firma = '$id' LIMIT 1";
+ unset($sql2a);
+ $this->app->DB->Update($sql2);
+ if($this->app->DB->error()) {
+ foreach($toupdate2 as $k => $v) {
+ $this->app->DB->Update("UPDATE firmendaten SET ".$k." = '".$v."'"." WHERE firma = '$id' LIMIT 1");
+ }
+ }
+
+ if(isset($firmendaten_werte_spalten)) {
+ foreach($toupdate2 as $key => $v) {
+ if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $toupdate2[$key])
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$toupdate2[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$key]);
+ if(!empty($doubletes[$key])) {
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+ }
+
+ $checkDoublettes = [];
+ for($i = 1; $i <= 5; $i++) {
+ $n1 = 'artikeltabellezusatz'.$i;
+ $n2 = 'adressetabellezusatz'.$i;
+ $n3 = 'auftragtabellezusatz'.$i;
+ $n4 = 'rechnungtabellezusatz'.$i;
+ $n5 = 'lieferscheintabellezusatz'.$i;
+ $n6 = 'produktiontabellezusatz'.$i;
+ $n7 = 'bestellungtabellezusatz'.$i;
+ $v1 = $this->app->Secure->GetPOST($n1);
+ $v2 = $this->app->Secure->GetPOST($n2);
+ $v3 = $this->app->Secure->GetPOST($n3);
+ $v4 = $this->app->Secure->GetPOST($n4);
+ $v5 = $this->app->Secure->GetPOST($n5);
+ $v6 = $this->app->Secure->GetPOST($n6);
+ $v7 = $this->app->Secure->GetPOST($n7);
+ if(isset($firmendaten_werte_spalten)) {
+ if(isset($firmendaten_werte_spalten[$n1]) && $firmendaten_werte_spalten[$n1]['wert'] != $v1) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v1' WHERE id = '".$firmendaten_werte_spalten[$n1]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n1]);
+ $checkDoublettes[] = $n1;
+ }
+ if(isset($firmendaten_werte_spalten[$n2]) && $firmendaten_werte_spalten[$n2]['wert'] != $v2)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v2' WHERE id = '".$firmendaten_werte_spalten[$n2]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n2]);
+ $checkDoublettes[] = $n2;
+ }
+ if(isset($firmendaten_werte_spalten[$n3]) && $firmendaten_werte_spalten[$n3]['wert'] != $v3)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v3' WHERE id = '".$firmendaten_werte_spalten[$n3]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n3]);
+ $checkDoublettes[] = $n3;
+ }
+ if(isset($firmendaten_werte_spalten[$n4]) && $firmendaten_werte_spalten[$n4]['wert'] != $v4)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v4' WHERE id = '".$firmendaten_werte_spalten[$n4]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n4]);
+ $checkDoublettes[] = $n4;
+ }
+ if(isset($firmendaten_werte_spalten[$n5]) && $firmendaten_werte_spalten[$n5]['wert'] != $v5)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v5' WHERE id = '".$firmendaten_werte_spalten[$n5]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n5]);
+ $checkDoublettes[] = $n5;
+ }
+ if(isset($firmendaten_werte_spalten[$n6]) && $firmendaten_werte_spalten[$n6]['wert'] != $v6)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v6' WHERE id = '".$firmendaten_werte_spalten[$n6]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n6]);
+ $checkDoublettes[] = $n6;
+ }
+ if(isset($firmendaten_werte_spalten[$n7]) && $firmendaten_werte_spalten[$n7]['wert'] != $v7)
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '$v7' WHERE id = '".$firmendaten_werte_spalten[$n7]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$n7]);
+ $checkDoublettes[] = $n7;
+ }
+ }
+ }
+
+ if(!empty($checkDoublettes) && !empty($doubletes)) {
+ foreach($checkDoublettes as $key) {
+ if(!empty($doubletes[$key])){
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+
+ $fields = $this->app->erp->GetFirmaFields();
+
+ $fields[] = 'produktionsverhalten';
+ $fields[] = 'taxfromdoctypesettings';
+
+ $sqla = null;
+ foreach($fields as $key) {
+ if(isset($firmendaten_werte_spalten)) {
+ if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key])
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$key]);
+ if(!empty($doubletes[$key])){
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+ $sqla[] = " $key='{$data[$key]}' ";
+ }
+ $sql = "UPDATE firmendaten SET ".implode(', ',$sqla)." WHERE firma='$id' LIMIT 1";
+ $this->app->DB->Update($sql);
+ if($this->app->DB->error()) {
+ foreach($fields as $key) {
+ $this->app->DB->Update("UPDATE firmendaten SET $key='{$data[$key]}' WHERE firma='$id' LIMIT 1");
+ }
+ }
+ $fields_checkbox = $this->app->erp->GetFirmaFieldsCheckbox();
+
+ if(isset($sqla)){
+ unset($sqla);
+ }
+ foreach($fields_checkbox as $key) {
+ $_data[$key] = $data[$key];
+ if($_data[$key] === 'checked'){
+ $_data[$key] = 1;
+ }
+ $_data[$key] = (int)$_data[$key];
+ $sqla[] = " $key='{$_data[$key]}' ";
+ if(isset($firmendaten_werte_spalten) && isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $_data[$key])
+ {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$_data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ if(in_array($key,array('begrenzen_belege','begrenzen_artikeltabelle','begrenzen_adressetabelle')))
+ {
+ $this->app->erp->SetKonfigurationValue('firmendaten_'.$key.'_gesetzt', 1);
+ }
+ unset($firmendaten_werte_spalten[$key]);
+ }
+ }
+ $sql = "UPDATE firmendaten SET ".implode(', ',$sqla)." WHERE firma='$id' LIMIT 1";
+ $this->app->DB->Update($sql);
+ if($this->app->DB->error()) {
+ foreach($fields_checkbox as $key) {
+ $_data[$key] = $data[$key];
+ if($_data[$key] === 'checked'){
+ $_data[$key] = 1;
+ }
+ $_data[$key] = (int)$_data[$key];
+ $this->app->DB->Update("UPDATE firmendaten SET $key='{$_data[$key]}' WHERE firma='$id' LIMIT 1");
+ }
+ }
+
+ $firmendaten = $this->app->DB->SelectArr("SELECT * FROM firmendaten WHERE firma='$id' LIMIT 1");
+ if($firmendaten && isset($firmendaten_werte_spalten)) {
+ foreach($firmendaten[0] as $key => $v) {
+ if($key !== 'id' && isset($data[$key])) {
+ if(isset($firmendaten_werte_spalten[$key]) && $firmendaten_werte_spalten[$key]['wert'] != $data[$key]) {
+ $this->app->DB->Update("UPDATE firmendaten_werte SET wert = '".$data[$key]."' WHERE id = '".$firmendaten_werte_spalten[$key]['id']."' LIMIT 1");
+ unset($firmendaten_werte_spalten[$key]);
+ if(!empty($doubletes[$key])){
+ $this->app->DB->Delete(
+ sprintf(
+ "DELETE FROM firmendaten_werte WHERE id <> %d AND name != '%s' AND id IN (%s)",
+ $firmendaten_werte_spalten[$key]['id'], $this->app->DB->real_escape_string($key),
+ implode(', ', $doubletes[$key])
+ )
+ );
+ unset($doubletes[$key]);
+ }
+ }
+ }
+ }
+ }
+
+ $this->app->DB->Update("UPDATE firma SET name='{$data[name]}', standardprojekt='{$data[projekt]}' WHERE id='$id' LIMIT 1");
+
+ $this->app->Tpl->Set('MESSAGE', "
Ihre Daten wurden erfolgreich gespeichert.
");
+ $this->FillFormFromDB($id);
+ }
+ else {
+ // Im Fehlerfall sollen das Formular mit den POST-Daten gefuellt werden
+ $this->app->Tpl->Set('MESSAGE', "
$error
");
+ $this->fillForm($data);
+ }
+ if(!$versandmail_zwischenspeichern && $this->app->erp->Firmendaten('versandmail_zwischenspeichern','',true) &&
+ !$this->app->DB->Select("SELECT id FROM prozessstarter WHERE parameter = 'versandmailsundrueckmeldung' AND aktiv = 1")){
+ $this->app->DB->Update("UPDATE prozessstarter SET aktiv = 1 WHERE parameter = 'versandmailsundrueckmeldung' LIMIT 1");
+ }
+ }
+ else{
+ $this->FillFormFromDB($id);
+ }
+
+ if($this->app->erp->Firmendaten('versandmail_zwischenspeichern',"",true)){
+ $this->app->erp->checkActiveCronjob('versandmailsundrueckmeldung', 'MESSAGEMAILS', false);
+ }
+
+ if (isset($fontUploadSuccessful) && $fontUploadSuccessful === true){
+ $this->app->Tpl->Add('MESSAGE',
+ sprintf('
Die Schriftart "%s" wurde erfolgreich hochgeladen und in den Einstellungen hinterlegt. Bitte Testen Sie die Einstellung durch Generierung eines Belegs.
Die Dateigröße von ca. ' . round($hintergrund_size / 1000) . ' KB vom ' . ucfirst($hintergrund) . ' ist zu groß. Das ' . ucfirst($hintergrund) . ' sollte unter 100 KB sein.
+ Ab der Version 20.1 sind alle Zahlweisen in das Modul Zahlweisen verlagert worden.
+ Sie sehen diese Meldung weil Sie vor der Version 20.1 mit Xentral gestartet hatten.
+ Wenn Sie auf das neue Modul welchseln möchten
+ (bitte nur nachdem Sie es in einem Testsystem geprüft hatten)
+ können Sie das gerne hier mit dem Button durchführen.
+
+
+
+