');
}
}
else{
foreach($ret as $v) {
$anz++;
$this->app->DB->Insert("INSERT INTO shopexport_getarticles (shop, nummer) VALUES ('$id', '".$this->app->DB->real_escape_string($v)."')");
}
if(!$this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE aktiv = 1 AND parameter = 'getarticles' LIMIT 1")) {
$this->app->DB->Update("UPDATE `prozessstarter` SET aktiv = 1 WHERE parameter = 'getarticles' LIMIT 1");
}
$this->app->DB->Update("UPDATE `prozessstarter` SET letzteausfuerhung = DATE_SUB(now(), INTERVAL periode MINUTE) WHERE aktiv = 1 AND parameter = 'getarticles' AND mutex = 0 LIMIT 1");
$this->app->Tpl->Add('MESSAGE', '
'.$anz.' {|Artikel gefunden. Diese werden im Hintergrund importiert.|}
');
}
}else{
foreach($ret as $v)
{
$anz++;
$this->app->DB->Insert("INSERT INTO shopexport_getarticles (shop, nummer) VALUES ('$id', '".$this->app->DB->real_escape_string($v)."')");
}
if(!$this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE aktiv = 1 AND parameter = 'getarticles' LIMIT 1"))$this->app->DB->Update("UPDATE `prozessstarter` SET aktiv = 1 WHERE parameter = 'getarticles' LIMIT 1");
$this->app->DB->Update("UPDATE `prozessstarter` SET letzteausfuerhung = DATE_SUB(now(), INTERVAL periode MINUTE) WHERE aktiv = 1 AND parameter = 'getarticles' AND mutex = 0 LIMIT 1");
$this->app->Tpl->Add('MESSAGE', '
'.$anz.' {|Artikel gefunden. Diese werden im Hintergrund importiert.|}
');
}
$this->app->erp->SetKonfigurationValue('artikelimportanzahl_'.$id, $anz);
unset($ret);
}
*/
}
if($this->app->Secure->GetGET('action') === 'create') {
$field = new HTMLInput("versandartenmapping","checkbox",1,'','','','','checked');
$this->form->NewField($field);
$field = new HTMLInput("zahlungsweisenmapping","checkbox",1,'','','','','checked');
$this->form->NewField($field);
$field = new HTMLInput("artikeltexteuebernehmen","checkbox",1,'','','','','checked');
$this->form->NewField($field);
$field = new HTMLInput("artikelimport","checkbox",1,'','','','','checked');
$this->form->NewField($field);
}else{
if($this->app->Secure->GetPOST('speichern'))
{
$this->app->erp->StartChangeLog('shopexport');
$altedaten = $this->app->DB->SelectArr("SELECT * FROM shopexport WHERE aktiv = 0 AND (shoptyp = 'intern' OR shoptyp = 'custom') AND modulename <> '' AND id = '$id' LIMIT 1");
$altedaten2 = $this->app->DB->SelectArr("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
if(true || $this->form->CallbackAndMandatorycheck(true))
{
$data = $this->app->DB->SelectArr("SELECT * FROM shopexport WHERE id = '$id' LIMIT 1");
if($data)$data = reset($data);
/*$bezeichnung = $this->app->Secure->GetPOST('frm_bezeichnung');
//$this->app->DB->Update("UPDATE shopexport SET bezeichnung = '$bezeichnung' WHERE id = '$id' LIMIT 1");
$projekt = (String)reset(explode(' ',$this->app->Secure->GetPOST('frm_projekt')));
if($projekt !== '')
{
$projekt = $this->app->DB->Select("SELECT id FROM projekt WHERE abkuerzung <> '' AND abkuerzung = '".$projekt."' ORDER BY geloescht LIMIT 1");
}
$this->app->DB->Update("UPDATE shopexport SET projekt = '$projekt' WHERE id = '$id' LIMIT 1");*/
if($this->app->Secure->GetPOST('modulename') != $altedaten2[0]['modulename'])
{
$modulename = $this->app->Secure->GetPOST('modulename');
if($modulename == '')
{
$this->app->DB->Update("UPDATE shopexport SET shoptyp = 'extern' WHERE id = '$id' LIMIT 1");
$data['shoptyp'] = 'extern';
}else
{
$found = false;
$obj = $this->app->erp->LoadModul('onlineshops');
$modulesel = array(''=>'Extern');
if($obj)
{
$module = $obj->getApps();
if(isset($module['installiert']))
{
foreach($module['installiert'] as $k => $v)
{
if(strpos($v['key'],'shopimporter_') !== 0)continue;
if($v['key'] == $modulename)
{
$this->app->DB->Update("UPDATE shopexport SET shoptyp = 'intern' WHERE id = '$id' LIMIT 1");
$data['shoptyp'] = 'intern';
$found = true;
break;
}
}
}
}
}
}
$einzelnabholen = $this->app->Secure->GetPOST('einzelnabholen');
$inwarteschlange = $this->app->Secure->GetPOST('inwarteschlange');
$modus = $this->app->Secure->GetPOST('modus');
$abholmodus = $this->app->Secure->GetPOST('abholmodus');
$vondatum = (String)$this->app->Secure->GetPOST('vondatum');
$vonzeit = (String)$this->app->Secure->GetPOST('vonzeit');
$this->form->HTMLList['datumvon']->htmlvalue = '0000-00-00 00:00:00';
$this->form->HTMLList['datumvon']->dbvalue = '0000-00-00 00:00:00';
if($vondatum !== '')
{
$this->form->HTMLList['datumvon']->htmlvalue = $this->app->String->Convert($vondatum, '%1.%2.%3', '%3-%2-%1');
if($vonzeit !== '')$this->form->HTMLList['datumvon']->htmlvalue = $this->form->HTMLList['datumvon']->htmlvalue.' '.$vonzeit.':00';
$this->form->HTMLList['datumvon']->dbvalue = $this->form->HTMLList['datumvon']->htmlvalue;
}
if($abholmodus !== 'zeitbereich' && $this->app->Secure->GetPOST('maxmanuell') == 1)
{
$this->form->HTMLList['einzelsync']->dbvalue = 1;
$this->form->HTMLList['einzelsync']->htmlvalue = 1;
}
/*switch($abholmodus)
{
case 'ab_nummer':
$this->app->DB->Update("UPDATE shopexport SET holealle = 1, anzgleichzeitig = 0 WHERE id = '$id' LIMIT 1");
break;
case 'zeitbereich':
$this->app->DB->Update("UPDATE shopexport SET anzgleichzeitig = 50 WHERE id = '$id' AND anzgleichzeitig < 2 LIMIT 1");
break;
default:
$this->app->DB->Update("UPDATE shopexport SET holealle = 0, anzgleichzeitig = 0 WHERE id = '$id' LIMIT 1");
break;
}*/
$aktivhaken = $this->app->Secure->GetPOST('aktivhaken');
$frmarr = array('ab_nummer','holeallestati','datumvon','datumbis','nummersyncstatusaendern');
//foreach($frmarr as $v)$this->app->DB->Update("UPDATE shopexport SET $v = '".$this->app->Secure->GetPOST($v)."' WHERE id = '$id' LIMIT 1");
switch($modus)
{
case 'demomodus':
//$this->app->DB->Update("UPDATE shopexport SET demomodus = 1 WHERE id = '$id' LIMIT 1");
//$this->app->DB->Update("UPDATE shopexport SET cronjobaktiv = 0 WHERE id = '$id' LIMIT 1");
break;
case 'manuell':
//$this->app->DB->Update("UPDATE shopexport SET demomodus = 0 WHERE id = '$id' LIMIT 1");
//$this->app->DB->Update("UPDATE shopexport SET cronjobaktiv = 0 WHERE id = '$id' LIMIT 1");
break;
case 'automatisch':
//$this->app->DB->Update("UPDATE shopexport SET demomodus = 0 WHERE id = '$id' LIMIT 1");
//$this->app->DB->Update("UPDATE shopexport SET cronjobaktiv = 1 WHERE id = '$id' LIMIT 1");
if(!$this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE parameter = 'shopimport' AND aktiv = 1"))
{
if($this->app->DB->Select("SELECT id FROM `prozessstarter` WHERE parameter = 'shopimport' AND aktiv = 0"))
{
$this->app->DB->Update("UPDATE `prozessstarter` SET aktiv = 1 WHERE parameter = 'shopimport' LIMIT 1");
}else{
$this->app->erp->CheckProzessstarter("Shopimporter","periodisch","15","2017-01-01 00:00:00","cronjob","shopimport",1);
}
}
break;
}
/*
if($einzelnabholen)
{
$this->app->DB->Update("UPDATE shopexport SET einzelsync = 1 WHERE id = '$id' LIMIT 1");
}else{
$this->app->DB->Update("UPDATE shopexport SET einzelsync = 0 WHERE id = '$id' LIMIT 1");
}
if($inwarteschlange)
{
$this->app->DB->Update("UPDATE shopexport SET direktimport = 0 WHERE id = '$id' LIMIT 1");
}else{
$this->app->DB->Update("UPDATE shopexport SET direktimport = 1 WHERE id = '$id' LIMIT 1");
}*/
if($data['shoptyp'] !== 'custom')
{
$this->app->DB->Update("UPDATE shopexport SET aktiv = '$aktivhaken' WHERE id = '$id' LIMIT 1");
}else{
$this->app->DB->Update("UPDATE shopexport SET aktiv = '0' WHERE id = '$id' LIMIT 1");
$data['modulename'] = trim($data['modulename'],'.');
if($data['modulename'] !== '')
{
$file = __DIR__ .'/../plugins/external/shopimporter/'.$data['modulename'];
if(is_file($file))
{
include_once($file);
$this->app->DB->Update("UPDATE shopexport SET aktiv = '$aktivhaken' WHERE id = '$id' LIMIT 1");
}
}
}
$err = null;
if($altedaten && $this->app->Secure->GetPOST('aktiv') && method_exists($this->app->erp, 'OnlineshopsLizenzFehler'))
{
if($err = $this->app->erp->OnlineshopsLizenzFehler($data['modulename']))
{
$this->app->DB->Update("UPDATE shopexport SET aktiv = '0' WHERE id = '$id' LIMIT 1");
$this->form->HTMLList['aktiv']->dbvalue = 0;
$this->form->HTMLList['aktiv']->htmlvalue = 0;
$this->app->User->SetParameter('shopexport_meldung', '
';
}
$html .= $hidden;
$this->app->Tpl->Parse('TAB9', 'shopexport_smarty.tpl');
if($target === 'return'){
return $html;
}
$this->app->Tpl->Add($target, $html);
$this->app->Tpl->Add($target2, $html2);
}
}
function ReplaceProjekt($db,$value,$fromform)
{
return $this->app->erp->ReplaceProjekt($db,$value,$fromform);
}
function ReplaceArtikel($db,$value,$fromform)
{
return $this->app->erp->ReplaceArtikel($db,$value,$fromform);
}
function ReplaceDecimal($db,$value,$fromform)
{
//value muss hier vom format ueberprueft werden
return str_replace(",",".",$value);
}
function ReplaceDatum($db,$value,$fromform)
{
//value muss hier vom format ueberprueft werden
$dbformat = 0;
if(strpos($value,'-') > 0) $dbformat = 1;
// wenn ziel datenbank
if($db)
{
if($dbformat) return $value;
else return $this->app->String->Convert($value,"%1.%2.%3","%3-%2-%1");
}
// wenn ziel formular
else
{
if($dbformat) return $this->app->String->Convert($value,"%1-%2-%3","%3.%2.%1");
else return $value;
}
}
/**
* @param int|bool $db
* @param int|string $value
* @param int|bool $fromform
*
* @return array|mixed|string|null
*/
public function ReplaceVertrieb($db,$value,$fromform)
{
if(!$fromform) {
$id = $value;
$abkuerzung = $this->app->DB->Select(sprintf("SELECT CONCAT(id, ' ', name) FROM adresse WHERE id=%d AND geloescht=0 LIMIT 1", $id));
}
else {
$abkuerzung = explode(' ', $value);
$id = reset($abkuerzung);
$id = $this->app->DB->Select(sprintf('SELECT id FROM adresse WHERE id = %d AND geloescht=0 LIMIT 1', $id));
}
// wenn ziel datenbank
if($db) {
return $id;
}
// wenn ziel formular
return $abkuerzung;
}
function ReplaceAdresse($db,$value,$fromform)
{
//value muss hier vom format ueberprueft werden
if(!$fromform) {
$id = $value;
$abkuerzung = $this->app->DB->Select("SELECT name FROM adresse WHERE id='$id' AND geloescht=0 LIMIT 1");
}
else {
$abkuerzung = $value;
$id = $this->app->DB->Select("SELECT id FROM adresse WHERE name='$value' AND name <> '' AND geloescht=0 LIMIT 1");
}
// wenn ziel datenbank
if($db) {
return $id;
}
// wenn ziel formular
return $abkuerzung;
}
public function Table()
{
$this->app->YUI->TableSearch('INHALT',"onlineshopslist");
$this->app->Tpl->Parse($this->parsetarget,"rahmen70.tpl");
}
public function Search()
{
//$this->app->Tpl->Set($this->parsetarget,"suchmaske");
//$this->app->Table(
//$table = new OrderTable("veranstalter");
//$table->Heading(array('Name','Homepage','Telefon'));
}
function ReplaceSteuersatz($db,$value,$fromform)
{
if($db)
{
if($value === "" || $value === null)return -1;
return str_replace(',','.', $value);
}else{
if($value < 0)return "";
return $value;
}
}
function ReplacePreisgruppe($db,$value,$fromform)
{
//value muss hier vom format ueberprueft werden
$dbformat = 0;
if(!$fromform) {
$dbformat = 1;
$id = $value;
$abkuerzung = $this->app->DB->Select("SELECT CONCAT(kennziffer,' ',name) as name FROM gruppen WHERE id='$id' LIMIT 1");
} else {
$dbformat = 0;
$abkuerzung = $value;
$id = $this->app->DB->Select("SELECT id FROM gruppen WHERE CONCAT(kennziffer,' ',name)='$value' OR (kennziffer='$value' AND kennziffer!='') AND art LIKE 'preisgruppe' LIMIT 1");
if($id <=0) $id=0;
}
// wenn ziel datenbank
if($db)
{
return $id;
}
// wenn ziel formular
else
{
return $abkuerzung;
}
}
/**
* @param int $shopId
* @param string $tab
*/
protected function showCategoryTree($shopId, $tab)
{
$this->app->Tpl->Set('SHOPID', $shopId);
$this->app->Tpl->Add('TAB'.$tab,$this->app->Tpl->OutputAsString('shopexport_tree.tpl'));
$this->app->Tpl->Add('HOOKLITABS','