From 5e0939904d84d4a114bcac7dc2e76a6c4f593ca2 Mon Sep 17 00:00:00 2001 From: Xenomporio <> Date: Tue, 24 May 2022 16:43:52 +0200 Subject: [PATCH] Bugfix api_account --- database/struktur.sql | 1 + phpwf/widgets/easytable.php | 1106 +++++++++++++++++------------------ 2 files changed, 554 insertions(+), 553 deletions(-) diff --git a/database/struktur.sql b/database/struktur.sql index 0dafbbd6..cebd2f50 100755 --- a/database/struktur.sql +++ b/database/struktur.sql @@ -1576,6 +1576,7 @@ CREATE TABLE IF NOT EXISTS `api_account` ( `projekt` int(11) NOT NULL DEFAULT '0', `permissions` text, `is_legacy` tinyint(1) NOT NULL DEFAULT '0', + `ishtmltransformation` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/phpwf/widgets/easytable.php b/phpwf/widgets/easytable.php index f1e7e8fb..7ba09b1f 100644 --- a/phpwf/widgets/easytable.php +++ b/phpwf/widgets/easytable.php @@ -1,556 +1,556 @@ -app = $app; - $this->sql =''; - $this->limit =''; - } - - - function AddRow($rows) - { - $this->datasets[] = $rows; - } - - /** - * @param string|array $sql - * @param string|int $limit - * @param string $newevent - */ - function Query($sql,$limit='',$newevent='') - { - if(!is_array($sql)) { - $this->sql = $sql; - $this->limit = $limit; - $this->headings = null; - - if($limit != 0){ - $page = $this->app->Secure->GetGET('page'); - if(!is_numeric($page)){ - $page = 1; - } - - $this->page = $page; - $this->start = ($page - 1) * $this->limit; - - $sql .= " LIMIT {$this->start},{$this->limit}"; - } - $this->searchrow = ''; - $jsarray = null; - if(!empty($this->app->stringcleaner)){ - $jsarray = $this->app->stringcleaner->CheckSQLHtml($sql); - } - $this->app->DB->DisableHTMLClearing(true); - $this->app->DB->DisableJSClearing(true); - $this->datasets = $this->app->DB->SelectArr($sql); - $this->app->DB->DisableHTMLClearing(false); - $this->app->DB->DisableJSClearing(false); - } - else { - $this->datasets = $sql; - } - - if($jsarray && $this->datasets) - { - foreach($this->datasets as $k => $arr) - { - $j = 0; - foreach($arr as $k2 => $v) - { - if(isset($jsarray[$j]) && !$jsarray[$j]) - { - $this->datasets[$k][$k2] = strip_tags($v); - }elseif(isset($jsarray[$j]) && 1 == $jsarray[$j]) - { - $this->datasets[$k][$k2] = $this->app->stringcleaner->xss_clean($v, false);//CleanString($v, 'nojs', $dummy); - } - $j++; - } - } - } - if(!empty($this->datasets) && count($this->datasets)>0){ - foreach($this->datasets[0] as $colkey=>$value) - { - $this->headings[]=ucfirst($colkey); - //$this->searchrow[0][$colkey]="
"; - } - } - //$this->searchrow[0][id]=""; - - //if(count($this->datasets)>=$limit) - // $this->datasets = $this->array_insert($this->datasets,0,$this->searchrow); - - $this->searchrow=''; - if($newevent!=='noAction') - { - $this->headings[!empty($this->headings)?(count($this->headings)-1):0] = 'Aktion'; - $this->width_headings[count($this->headings)-1] = '120px'; //TMP fuer Belegtabelle - } - - } - // Fügt $value in $array ein, an der Stelle $index - function array_insert($array, $index, $value) - { - return array_merge(array_slice($array, 0, $index), $value, array_slice($array, $index)); - } - - - function DisplayWithSort($parsetarget) - { - - $htmltable = new HTMLTable(0,"100%","",3,1); - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - } - } - $module = $this->app->Secure->GetGET("module"); - $htmltable->ReplaceCol(count($this->headings), - " -   -   -   -   - "); - - $this->app->Tpl->Set($parsetarget,$htmltable->Get()); - } - - function DisplayWithDelivery($parsetarget) - { - - $htmltable = new HTMLTable(0,"100%","",3,1); - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading(array($this->app->Tpl->pruefeuebersetzung('Suchen','table'),'','','')); - - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - $link=""; - $cols=0; - foreach($row as $key=>$field){ - if($cols<3){ - $htmltable->AddCol($field); - $cols++; - } - if($key!="id") - $link = $link."window.opener.document.getElementsByName('$key')[0].value='$field';"; - } - $htmltable->AddCol(" - "); - - } - } - $module = $this->app->Secure->GetGET("module"); - /* - $htmltable->ReplaceCol(4, - " - "); - */ - $this->app->Tpl->Set($parsetarget,$htmltable->Get()); - } - - - function DisplayOwn($parsetarget,$click,$limit=30,$idlabel="id",$tmpid="") - { - $newevent = null; - $pages = round(count($this->app->DB->SelectArr($this->sql)) / $this->limit); - if($pages==0)$pages=1; - - $module = $this->app->Secure->GetGET("module"); - $action = $this->app->Secure->GetGET("action"); - - if($tmpid>0) - $id = $tmpid; - else - $id = $this->app->Secure->GetGET($idlabel); - - - if($this->page ==0 || $this->page=="") $this->page = 1; - if($this->page <=1) $before = $this->page; else $before=$this->page-1; - if($this->page >=$pages) $next = $this->page; else $next=$this->page+1; - - $colmenu = ""; - - //for($i=0;($i<$pages && $i< 10);$i++) - //{ - /* - if($this->page==($i+1)) - { - $colmenu .= ""; - } else { - $colmenu .= ""; - } - */ - //} - $colmenu .= ""; - - $colmenu .= "
  - ". - ($i+1)."". - ($i+1)."Seite {$this->page} von $pages  -
"; - - $this->app->Tpl->Set($parsetarget,$colmenu); - - $htmltable = new HTMLTable(0,"100%","",3,1); - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - } - $module = $this->app->Secure->GetGET("module"); - if($newevent!="noAction"){ - $htmltable->ReplaceCol(count($this->headings),$click); - } - $this->app->Tpl->Add($parsetarget,$htmltable->Get()); - } - else { - if($newevent=="noAction") $newevent=""; - $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); - } -/* - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - } - - for($i=0;$i{$menu[$i]} "; - } - - $htmltable->ReplaceCol(count($this->headings),$menustring); - $this->app->Tpl->Add($parsetarget,$htmltable->Get()); - } - else { - $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden!"); - } -*/ - $this->app->Tpl->Add($parsetarget,$colmenu); - } - - - function DisplayWidthInlineEdit($parsetarget,$click="",$newevent="",$nomenu="false") - { - $htmltable = new HTMLTable(0,"100%","",3,1); - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - - $htmltable->NewRow(); - - $start = "
"; - foreach($row as $key=>$field){ - if($key!="id") - $htmltable->AddCol($start.""); - else - $htmltable->AddCol($field."
"); - - $start=""; - } - } - $module = $this->app->Secure->GetGET("module"); - if($newevent!="noAction"){ - $htmltable->ReplaceCol(count($this->headings),$click); - } - $this->app->Tpl->Add($parsetarget,$htmltable->Get(1)); - } - else { - $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent"); - } - } - - function DisplayEditable($parsetarget,$click="",$newevent="",$nomenu="false",$arrayEditable="",$editlastrow=false,$nowarp=true) - { - $module = $this->app->Secure->GetGET("module"); - $this->app->erp->RunHook('EasyTableDisplayEditableClick', 3, $module, $click, $newevent); - $htmltable = new HTMLTable(0,"100%","",3,1); - - if(!$nowarp)$htmltable->nowrap=""; - // Letzte Spalte aendern - if($newevent == "noAction") - $this->headings[count($this->headings)-1] = $click; - - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - $result = ''; - - $htmltable->nowrap = array(count($this->headings)-1); - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - } - - if($newevent!="noAction"){ - $htmltable->ReplaceCol(count($this->headings),$click); - } - if($parsetarget=="return") - $result .= $htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow); - else - { - if(is_array($arrayEditable)) - { - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow,2)); - } - else { - if($module=="lieferschein" || $module=="anfrage" || $module=="preisanfrage") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5),$editlastrow,1)); - else if($module==='retoure'){ - $this->app->Tpl->Add($parsetarget, $htmltable->GetSpecialCSSClasses(array(4, 5, 7, 8, 10), $editlastrow, 1)); - } - else if($module=="produktion") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4),$editlastrow,1)); - else if($module=="arbeitsnachweis") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2,3,4,5,6),$editlastrow,2)); - else if($module=="reisekosten") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,3),$editlastrow,2)); - else if($module=="kalkulation") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2),$editlastrow,2)); - else if($module=="inventur") - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,4,5),$editlastrow,2)); - else if($module=="auftrag" || $module=="rechnung" || $module=="gutschrift"|| $module=="bestellung" || $module=="angebot" || $module=="proformarechnung") - { - if($module=='bestellung') - { - $editcols = array(4,5,6,7); - }else{ - $einkaufspreiseerlaubt = false; - if($einkaufspreiseerlaubt) - { - $editcols =array(4,5,6,7,8,9); - //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8,9),$editlastrow,2)); - }else{ - $editcols = array(4,5,6,7,8); - //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8),$editlastrow,2)); - } - } - $clastRow = 2; - $this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow,$clastRow); - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow)); - } - else - { - $editcols = array(4,5,6); - $clastRow = 2; - $this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow, $clastRow); - $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow)); - } - //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6),$editlastrow,2)); - - } - } - } - else { - if($newevent=="noAction") $newevent=""; - - if($parsetarget=="return") - $result .= "
Keine Daten vorhanden! $newevent
"; - else - $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); - } - - if($parsetarget=="return") return $result; - } - - /** - * @param string $parsetarget - * @param string $click - * @param string $newevent - * @param string $nomenu - * @param int $columns - * @param int $rows - * @param bool $nowrap - * - * @return string|void - */ - function DisplayNew($parsetarget,$click='',$newevent='',$nomenu='false',$columns=0,$rows=0,$nowrap=true) - { - $result = ''; - $secondline = isset($this->secondline)?$this->secondline:false; - $htmltable = new HTMLTable(0,"99.9%","",3,1,"font-size: 90%; "); - - if(!$nowrap) $htmltable->nowrap=""; - if($secondline) { - unset($this->headings[count($this->headings)-1]); - } - // Letzte Spalte aendern - if($newevent === 'noAction'){ - $this->headings[count($this->headings) - 1] = $click; - } - - $htmltable->width_headings = isset($this->width_headings)?$this->width_headings:null; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - if(!empty($this->datasets) && count($this->datasets)>0){ - $rowcounter=0; - foreach($this->datasets as $row){ - $htmltable->NewRow(); - $aligncounter=0; - $c = 0; - $crow = count($row); - $_field = ''; - foreach($row as $field) - { - $c++; - if($c < $crow || !$secondline) { - if (isset($this->align[$aligncounter])) - $htmltable->AddCol($field, $this->align[$aligncounter]); - else - $htmltable->AddCol($field); - $aligncounter++; - }elseif($secondline)$_field = $field; - } - if($secondline) - { - $htmltable->NewRow(); - $htmltable->AddCol('','','',$crow-1); - $htmltable->NewRow(); - $field = $_field; - if (isset($this->align[$aligncounter])) - $htmltable->AddCol($field, $this->align[$aligncounter],'',$crow-1); - else - $htmltable->AddCol($field,'','',$crow-1); - } - $rowcounter++; - } - - if($rowcounter<=$rows){ - for($rowcounter;$rows > $rowcounter;$rowcounter++) - { - $htmltable->NewRow(); - for($i_c=0;$i_c<$columns;$i_c++) - $htmltable->AddCol(''); - } - } - - $module = $this->app->Secure->GetGET("module"); - if($newevent!="noAction"){ - $htmltable->ReplaceCol(count($this->headings),$click); - } - if($parsetarget=="return") - $result .= $htmltable->Get($secondline?3:false); - else - $this->app->Tpl->Add($parsetarget,$htmltable->Get($secondline?3:false)); - } - else { - if($newevent=="noAction") $newevent=""; - if($newevent=="Menü") $newevent=""; - - if($parsetarget=="return") - $result .= "
Keine Daten vorhanden! $newevent
"; - else - $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); - } - - if($parsetarget=="return") return $result; - } - - function Display($parsetarget,$clickmodule="",$clickaction="",$clicklabel="",$newevent="") - { - - $htmltable = new HTMLTable(0,"100%","",3,1); - $htmltable->width_headings = $this->width_headings; - $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); - - $htmltable->ChangingRowColors('#e0e0e0','#fff'); - - if(count($this->datasets)>0){ - foreach($this->datasets as $row){ - $htmltable->NewRow(); - foreach($row as $field) - $htmltable->AddCol($field); - } - $module = $this->app->Secure->GetGET("module"); - if($clickaction=="") { - $htmltable->ReplaceCol(count($this->headings), - " - -  "); - } else { - $htmltable->ReplaceCol(count($this->headings), - "$clicklabel"); - - } - $this->app->Tpl->Add($parsetarget,$htmltable->Get()); - } - else { - $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent"); - } - } - -} +app = $app; + $this->sql =''; + $this->limit =''; + } + + + function AddRow($rows) + { + $this->datasets[] = $rows; + } + + /** + * @param string|array $sql + * @param string|int $limit + * @param string $newevent + */ + function Query($sql,$limit='',$newevent='') + { + if(!is_array($sql)) { + $this->sql = $sql; + $this->limit = $limit; + $this->headings = null; + + if($limit != 0){ + $page = $this->app->Secure->GetGET('page'); + if(!is_numeric($page)){ + $page = 1; + } + + $this->page = $page; + $this->start = ((int)$page - 1) * ((int) $this->limit); + + $sql .= " LIMIT {$this->start},{$this->limit}"; + } + $this->searchrow = ''; + $jsarray = null; + if(!empty($this->app->stringcleaner)){ + $jsarray = $this->app->stringcleaner->CheckSQLHtml($sql); + } + $this->app->DB->DisableHTMLClearing(true); + $this->app->DB->DisableJSClearing(true); + $this->datasets = $this->app->DB->SelectArr($sql); + $this->app->DB->DisableHTMLClearing(false); + $this->app->DB->DisableJSClearing(false); + } + else { + $this->datasets = $sql; + } + + if($jsarray && $this->datasets) + { + foreach($this->datasets as $k => $arr) + { + $j = 0; + foreach($arr as $k2 => $v) + { + if(isset($jsarray[$j]) && !$jsarray[$j]) + { + $this->datasets[$k][$k2] = strip_tags($v); + }elseif(isset($jsarray[$j]) && 1 == $jsarray[$j]) + { + $this->datasets[$k][$k2] = $this->app->stringcleaner->xss_clean($v, false);//CleanString($v, 'nojs', $dummy); + } + $j++; + } + } + } + if(!empty($this->datasets) && count($this->datasets)>0){ + foreach($this->datasets[0] as $colkey=>$value) + { + $this->headings[]=ucfirst($colkey); + //$this->searchrow[0][$colkey]="
"; + } + } + //$this->searchrow[0][id]=""; + + //if(count($this->datasets)>=$limit) + // $this->datasets = $this->array_insert($this->datasets,0,$this->searchrow); + + $this->searchrow=''; + if($newevent!=='noAction') + { + $this->headings[!empty($this->headings)?(count($this->headings)-1):0] = 'Aktion'; + $this->width_headings[count($this->headings)-1] = '120px'; //TMP fuer Belegtabelle + } + + } + // Fügt $value in $array ein, an der Stelle $index + function array_insert($array, $index, $value) + { + return array_merge(array_slice($array, 0, $index), $value, array_slice($array, $index)); + } + + + function DisplayWithSort($parsetarget) + { + + $htmltable = new HTMLTable(0,"100%","",3,1); + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + } + } + $module = $this->app->Secure->GetGET("module"); + $htmltable->ReplaceCol(count($this->headings), + " +   +   +   +   + "); + + $this->app->Tpl->Set($parsetarget,$htmltable->Get()); + } + + function DisplayWithDelivery($parsetarget) + { + + $htmltable = new HTMLTable(0,"100%","",3,1); + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading(array($this->app->Tpl->pruefeuebersetzung('Suchen','table'),'','','')); + + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + $link=""; + $cols=0; + foreach($row as $key=>$field){ + if($cols<3){ + $htmltable->AddCol($field); + $cols++; + } + if($key!="id") + $link = $link."window.opener.document.getElementsByName('$key')[0].value='$field';"; + } + $htmltable->AddCol(" + "); + + } + } + $module = $this->app->Secure->GetGET("module"); + /* + $htmltable->ReplaceCol(4, + " + "); + */ + $this->app->Tpl->Set($parsetarget,$htmltable->Get()); + } + + + function DisplayOwn($parsetarget,$click,$limit=30,$idlabel="id",$tmpid="") + { + $newevent = null; + $pages = round(count($this->app->DB->SelectArr($this->sql)) / $this->limit); + if($pages==0)$pages=1; + + $module = $this->app->Secure->GetGET("module"); + $action = $this->app->Secure->GetGET("action"); + + if($tmpid>0) + $id = $tmpid; + else + $id = $this->app->Secure->GetGET($idlabel); + + + if($this->page ==0 || $this->page=="") $this->page = 1; + if($this->page <=1) $before = $this->page; else $before=$this->page-1; + if($this->page >=$pages) $next = $this->page; else $next=$this->page+1; + + $colmenu = ""; + + //for($i=0;($i<$pages && $i< 10);$i++) + //{ + /* + if($this->page==($i+1)) + { + $colmenu .= ""; + } else { + $colmenu .= ""; + } + */ + //} + $colmenu .= ""; + + $colmenu .= "
  + ". + ($i+1)."". + ($i+1)."Seite {$this->page} von $pages  +
"; + + $this->app->Tpl->Set($parsetarget,$colmenu); + + $htmltable = new HTMLTable(0,"100%","",3,1); + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + } + $module = $this->app->Secure->GetGET("module"); + if($newevent!="noAction"){ + $htmltable->ReplaceCol(count($this->headings),$click); + } + $this->app->Tpl->Add($parsetarget,$htmltable->Get()); + } + else { + if($newevent=="noAction") $newevent=""; + $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); + } +/* + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + } + + for($i=0;$i{$menu[$i]} "; + } + + $htmltable->ReplaceCol(count($this->headings),$menustring); + $this->app->Tpl->Add($parsetarget,$htmltable->Get()); + } + else { + $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden!"); + } +*/ + $this->app->Tpl->Add($parsetarget,$colmenu); + } + + + function DisplayWidthInlineEdit($parsetarget,$click="",$newevent="",$nomenu="false") + { + $htmltable = new HTMLTable(0,"100%","",3,1); + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + + $htmltable->NewRow(); + + $start = "
"; + foreach($row as $key=>$field){ + if($key!="id") + $htmltable->AddCol($start.""); + else + $htmltable->AddCol($field."
"); + + $start=""; + } + } + $module = $this->app->Secure->GetGET("module"); + if($newevent!="noAction"){ + $htmltable->ReplaceCol(count($this->headings),$click); + } + $this->app->Tpl->Add($parsetarget,$htmltable->Get(1)); + } + else { + $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent"); + } + } + + function DisplayEditable($parsetarget,$click="",$newevent="",$nomenu="false",$arrayEditable="",$editlastrow=false,$nowarp=true) + { + $module = $this->app->Secure->GetGET("module"); + $this->app->erp->RunHook('EasyTableDisplayEditableClick', 3, $module, $click, $newevent); + $htmltable = new HTMLTable(0,"100%","",3,1); + + if(!$nowarp)$htmltable->nowrap=""; + // Letzte Spalte aendern + if($newevent == "noAction") + $this->headings[count($this->headings)-1] = $click; + + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + $result = ''; + + $htmltable->nowrap = array(count($this->headings)-1); + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + } + + if($newevent!="noAction"){ + $htmltable->ReplaceCol(count($this->headings),$click); + } + if($parsetarget=="return") + $result .= $htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow); + else + { + if(is_array($arrayEditable)) + { + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($arrayEditable,$editlastrow,2)); + } + else { + if($module=="lieferschein" || $module=="anfrage" || $module=="preisanfrage") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5),$editlastrow,1)); + else if($module==='retoure'){ + $this->app->Tpl->Add($parsetarget, $htmltable->GetSpecialCSSClasses(array(4, 5, 7, 8, 10), $editlastrow, 1)); + } + else if($module=="produktion") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4),$editlastrow,1)); + else if($module=="arbeitsnachweis") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2,3,4,5,6),$editlastrow,2)); + else if($module=="reisekosten") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,3),$editlastrow,2)); + else if($module=="kalkulation") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(2),$editlastrow,2)); + else if($module=="inventur") + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(1,4,5),$editlastrow,2)); + else if($module=="auftrag" || $module=="rechnung" || $module=="gutschrift"|| $module=="bestellung" || $module=="angebot" || $module=="proformarechnung") + { + if($module=='bestellung') + { + $editcols = array(4,5,6,7); + }else{ + $einkaufspreiseerlaubt = false; + if($einkaufspreiseerlaubt) + { + $editcols =array(4,5,6,7,8,9); + //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8,9),$editlastrow,2)); + }else{ + $editcols = array(4,5,6,7,8); + //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6,7,8),$editlastrow,2)); + } + } + $clastRow = 2; + $this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow,$clastRow); + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow)); + } + else + { + $editcols = array(4,5,6); + $clastRow = 2; + $this->app->erp->RunHook('EasyTableDisplayEditable', 4, $module, $editcols, $editlastrow, $clastRow); + $this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses($editcols,$editlastrow,$clastRow)); + } + //$this->app->Tpl->Add($parsetarget,$htmltable->GetSpecialCSSClasses(array(4,5,6),$editlastrow,2)); + + } + } + } + else { + if($newevent=="noAction") $newevent=""; + + if($parsetarget=="return") + $result .= "
Keine Daten vorhanden! $newevent
"; + else + $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); + } + + if($parsetarget=="return") return $result; + } + + /** + * @param string $parsetarget + * @param string $click + * @param string $newevent + * @param string $nomenu + * @param int $columns + * @param int $rows + * @param bool $nowrap + * + * @return string|void + */ + function DisplayNew($parsetarget,$click='',$newevent='',$nomenu='false',$columns=0,$rows=0,$nowrap=true) + { + $result = ''; + $secondline = isset($this->secondline)?$this->secondline:false; + $htmltable = new HTMLTable(0,"99.9%","",3,1,"font-size: 90%; "); + + if(!$nowrap) $htmltable->nowrap=""; + if($secondline) { + unset($this->headings[count($this->headings)-1]); + } + // Letzte Spalte aendern + if($newevent === 'noAction'){ + $this->headings[count($this->headings) - 1] = $click; + } + + $htmltable->width_headings = isset($this->width_headings)?$this->width_headings:null; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + if(!empty($this->datasets) && count($this->datasets)>0){ + $rowcounter=0; + foreach($this->datasets as $row){ + $htmltable->NewRow(); + $aligncounter=0; + $c = 0; + $crow = count($row); + $_field = ''; + foreach($row as $field) + { + $c++; + if($c < $crow || !$secondline) { + if (isset($this->align[$aligncounter])) + $htmltable->AddCol($field, $this->align[$aligncounter]); + else + $htmltable->AddCol($field); + $aligncounter++; + }elseif($secondline)$_field = $field; + } + if($secondline) + { + $htmltable->NewRow(); + $htmltable->AddCol('','','',$crow-1); + $htmltable->NewRow(); + $field = $_field; + if (isset($this->align[$aligncounter])) + $htmltable->AddCol($field, $this->align[$aligncounter],'',$crow-1); + else + $htmltable->AddCol($field,'','',$crow-1); + } + $rowcounter++; + } + + if($rowcounter<=$rows){ + for($rowcounter;$rows > $rowcounter;$rowcounter++) + { + $htmltable->NewRow(); + for($i_c=0;$i_c<$columns;$i_c++) + $htmltable->AddCol(''); + } + } + + $module = $this->app->Secure->GetGET("module"); + if($newevent!="noAction"){ + $htmltable->ReplaceCol(count($this->headings),$click); + } + if($parsetarget=="return") + $result .= $htmltable->Get($secondline?3:false); + else + $this->app->Tpl->Add($parsetarget,$htmltable->Get($secondline?3:false)); + } + else { + if($newevent=="noAction") $newevent=""; + if($newevent=="Menü") $newevent=""; + + if($parsetarget=="return") + $result .= "
Keine Daten vorhanden! $newevent
"; + else + $this->app->Tpl->Set($parsetarget,"
Keine Daten vorhanden! $newevent
"); + } + + if($parsetarget=="return") return $result; + } + + function Display($parsetarget,$clickmodule="",$clickaction="",$clicklabel="",$newevent="") + { + + $htmltable = new HTMLTable(0,"100%","",3,1); + $htmltable->width_headings = $this->width_headings; + $htmltable->AddRowAsHeading($this->app->Tpl->pruefeuebersetzung($this->headings,'table')); + + $htmltable->ChangingRowColors('#e0e0e0','#fff'); + + if(count($this->datasets)>0){ + foreach($this->datasets as $row){ + $htmltable->NewRow(); + foreach($row as $field) + $htmltable->AddCol($field); + } + $module = $this->app->Secure->GetGET("module"); + if($clickaction=="") { + $htmltable->ReplaceCol(count($this->headings), + " + +  "); + } else { + $htmltable->ReplaceCol(count($this->headings), + "$clicklabel"); + + } + $this->app->Tpl->Add($parsetarget,$htmltable->Get()); + } + else { + $this->app->Tpl->Add($parsetarget,"Keine Daten vorhanden! $newevent"); + } + } + +}