function singleselect($string) { list($s_id, $singleselect) = explode(chr(9), $string, 2); $webservice = '1'; # include("../includes/select.php"); include "../includes/connect.php"; include "../includes/online.php"; $fp = fopen("../temp/soap.log", "a"); fwrite($fp, "A: " . $singleselect . "\n"); $linje = NULL; $singleselect = "select " . $singleselect; fwrite($fp, "B: " . $singleselect . "\n"); $r = 0; $q = db_select("{$singleselect}", __FILE__ . " linje " . __LINE__); while ($r < db_num_fields($q)) { $fieldName = db_field_name($q, $r); $fieldType = db_field_type($q, $r); $linje ? $linje .= chr(9) . $fieldName . "(" . $fieldType . ")" : ($linje = $fieldName . "(" . $fieldType . ")"); $r++; } $linje = NULL; $arraysize = $r; $fp = fopen("../temp/soap.log", "a"); fwrite($fp, "C: " . $singleselect . "\n"); $q = db_select("{$singleselect}", __FILE__ . " linje " . __LINE__); if ($r = db_fetch_array($q)) { $linje = NULL; for ($x = 0; $x < $arraysize; $x++) { $linje ? $linje .= chr(9) . $r[$x] : ($linje = $r[$x]); } } fwrite($fp, $linje . "\n"); fclose($fp); return '0' . chr(9) . $linje; }
function multiselect($string) { list($s_id, $multiselect) = explode(chr(9), $string); $webservice = '1'; # include("../includes/select.php"); include "../includes/connect.php"; include "../includes/online.php"; $linje = NULL; $filnavn = "../temp/{$db}/{$bruger_id}.csv"; if (!file_exists("../temp/{$db}")) { mkdir("../temp/{$db}"); } $fp = fopen($filnavn, "w"); $multiselect = "select " . $multiselect; $r = 0; $q = db_select("{$multiselect}", __FILE__ . " linje " . __LINE__); while ($r < db_num_fields($q)) { $fieldName = db_field_name($q, $r); $fieldType = db_field_type($q, $r); $linje ? $linje .= chr(9) . $fieldName . "(" . $fieldType . ")" : ($linje = $fieldName . "(" . $fieldType . ")"); $r++; } if (!$linje) { return '1' . chr(9) . 'fejl i query (' . $multiselect . ')'; } if ($fp) { fwrite($fp, "{$linje}\n"); } $q = db_select("{$multiselect}", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $linje = NULL; $arraysize = count($r); for ($x = 0; $x < $arraysize; $x++) { if (isset($r[$x])) { $r[$x] = str_replace(chr(9), "<TAB>", $r[$x]); $r[$x] = str_replace(chr(10), "<LF>", $r[$x]); $r[$x] = str_replace(chr(13), "<CR>", $r[$x]); $linje ? $linje .= chr(9) . $r[$x] : ($linje = $r[$x]); } } if ($fp) { fwrite($fp, "{$linje}\n"); } } fclose($fp); return "0" . chr(9) . "{$filnavn}"; /* #return ("$selectquery"); $q=db_select("$selectquery"); while ($r < db_num_fields($q)) { $fieldName = db_field_name($q, $r); { $svar.=$fieldName .chr(9); $r++; } } return ("$svar"); */ }
/** Get the content of $table as a series of INSERT statements. */ function get_table_content($table, $crlf) { $result = db_query("SELECT * FROM {$table}"); //prefix if required to table name before exporting. if (strlen(get_opendb_config_var('db_server', 'table_prefix')) > 0) { $table = get_opendb_config_var('db_server', 'table_prefix') . $table; } $i = 0; while ($row = db_fetch_row($result)) { $table_list = ""; for ($j = 0; $j < db_num_fields($result); $j++) { if (strlen($table_list) > 0) { $table_list .= ", "; } $table_list .= db_field_name($result, $j); } $table_list = "(" . $table_list . ")"; $schema_insert = ""; for ($j = 0; $j < db_num_fields($result); $j++) { if (strlen($schema_insert) > 0) { $schema_insert .= ", "; } if (!isset($row[$j])) { $schema_insert .= "NULL"; } else { if ($row[$j] != "") { $row[$j] = replace_newlines($row[$j]); // Escape normal addslashes: \', \", \\, \0 add to that \n $row[$j] = addcslashes($row[$j], "\\'\"\\\n"); $schema_insert .= "'" . $row[$j] . "'"; } else { $schema_insert .= "''"; } } } $schema_insert = "INSERT INTO {$table} {$table_list} VALUES (" . $schema_insert . ")"; // Get rid of newlines. $schema_insert = str_replace("\n", "", $schema_insert); $schema_insert = str_replace("\r", "", $schema_insert); echo trim($schema_insert) . ";" . $crlf; $i++; } return TRUE; }
function db_delete($table, $keys = null) { $names = db_field_name($table); $binds = array(); $where = array(); if (!empty($keys)) { foreach ($keys as $key => $val) { if (in_array($key, $names)) { $where[] = "{$key} = ?"; $binds[] = $val; } } } $sql = "DELETE FROM {$table} WHERE 1 = 1"; if (!empty($where)) { $sql .= " AND " . implode(" AND ", $where); } return db_query($sql, $binds); }
function Render() { // get post and get variables global $Translation; $adminConfig = config('adminConfig'); $FiltersPerGroup = 4; $buttonWholeWidth = 136; $current_view = ''; /* TV, DV, TVDV, TVP, DVP, Filters */ $Embedded = intval($_REQUEST['Embedded']); if ($_SERVER['REQUEST_METHOD'] == 'GET') { $SortField = $_GET["SortField"]; $SortDirection = $_GET["SortDirection"]; $FirstRecord = $_GET["FirstRecord"]; $ScrollUp_y = $_GET["ScrollUp_y"]; $ScrollDn_y = $_GET["ScrollDn_y"]; $Previous_x = $_GET["Previous_x"]; $Next_x = $_GET["Next_x"]; $Filter_x = $_GET["Filter_x"]; $SaveFilter_x = $_GET["SaveFilter_x"]; $NoFilter_x = $_GET["NoFilter_x"]; $CancelFilter = $_GET["CancelFilter"]; $ApplyFilter = $_GET["ApplyFilter"]; $Search_x = $_GET["Search_x"]; $SearchString = get_magic_quotes_gpc() ? stripslashes($_GET['SearchString']) : $_GET['SearchString']; $CSV_x = $_GET["CSV_x"]; $FilterAnd = $_GET["FilterAnd"]; $FilterField = $_GET["FilterField"]; $FilterOperator = $_GET["FilterOperator"]; if (is_array($_GET['FilterValue'])) { foreach ($_GET['FilterValue'] as $fvi => $fv) { $FilterValue[$fvi] = get_magic_quotes_gpc() ? stripslashes($fv) : $fv; } } $Print_x = $_GET['Print_x']; $PrintTV = $_GET['PrintTV']; $PrintDV = $_GET['PrintDV']; $SelectedID = get_magic_quotes_gpc() ? stripslashes($_GET['SelectedID']) : $_GET['SelectedID']; $insert_x = $_GET['insert_x']; $update_x = $_GET['update_x']; $delete_x = $_GET['delete_x']; $SkipChecks = $_GET['confirmed']; $deselect_x = $_GET['deselect_x']; $addNew_x = $_GET['addNew_x']; $dvprint_x = $_GET['dvprint_x']; $DisplayRecords = in_array($_GET['DisplayRecords'], array('user', 'group')) ? $_GET['DisplayRecords'] : 'all'; } else { $SortField = $_POST['SortField']; $SortDirection = $_POST['SortDirection']; $FirstRecord = $_POST['FirstRecord']; $ScrollUp_y = $_POST['ScrollUp_y']; $ScrollDn_y = $_POST['ScrollDn_y']; $Previous_x = $_POST['Previous_x']; $Next_x = $_POST['Next_x']; $Filter_x = $_POST['Filter_x']; $SaveFilter_x = $_POST['SaveFilter_x']; $NoFilter_x = $_POST['NoFilter_x']; $CancelFilter = $_POST['CancelFilter']; $ApplyFilter = $_POST['ApplyFilter']; $Search_x = $_POST['Search_x']; $SearchString = get_magic_quotes_gpc() ? stripslashes($_POST['SearchString']) : $_POST['SearchString']; $CSV_x = $_POST['CSV_x']; $FilterAnd = $_POST['FilterAnd']; $FilterField = $_POST['FilterField']; $FilterOperator = $_POST['FilterOperator']; if (is_array($_POST['FilterValue'])) { foreach ($_POST['FilterValue'] as $fvi => $fv) { $FilterValue[$fvi] = get_magic_quotes_gpc() ? stripslashes($fv) : $fv; } } $Print_x = $_POST['Print_x']; $PrintTV = $_POST['PrintTV']; $PrintDV = $_POST['PrintDV']; $SelectedID = get_magic_quotes_gpc() ? stripslashes($_POST['SelectedID']) : $_POST['SelectedID']; $insert_x = $_POST['insert_x']; $update_x = $_POST['update_x']; $delete_x = $_POST['delete_x']; $SkipChecks = $_POST['confirmed']; $deselect_x = $_POST['deselect_x']; $addNew_x = $_POST['addNew_x']; $dvprint_x = $_POST['dvprint_x']; $DisplayRecords = in_array($_POST['DisplayRecords'], array('user', 'group')) ? $_POST['DisplayRecords'] : 'all'; } $mi = getMemberInfo(); // insure authenticity of user inputs: if (is_array($FilterAnd)) { foreach ($FilterAnd as $i => $f) { if ($f && !preg_match('/^(and|or)$/i', trim($f))) { $FilterAnd[$i] = 'and'; } } } if (is_array($FilterOperator)) { foreach ($FilterOperator as $i => $f) { if ($f && !in_array(trim($f), array_keys($GLOBALS['filter_operators']))) { $FilterOperator[$i] = ''; } } } if (!preg_match('/^\\s*[1-9][0-9]*\\s*(asc|desc)?(\\s*,\\s*[1-9][0-9]*\\s*(asc|desc)?)*$/i', $SortField)) { $SortField = ''; } if (!preg_match('/^(asc|desc)$/i', $SortDirection)) { $SortDirection = ''; } if (!$this->AllowDelete) { $delete_x = ''; } if (!$this->AllowDeleteOfParents) { $SkipChecks = ''; } if (!$this->AllowInsert) { $insert_x = ''; $addNew_x = ''; } if (!$this->AllowUpdate) { $update_x = ''; } if (!$this->AllowFilters) { $Filter_x = ''; } if (!$this->AllowPrinting) { $Print_x = ''; $PrintTV = ''; } if (!$this->QuickSearch) { $SearchString = ''; } if (!$this->AllowCSV) { $CSV_x = ''; } // enforce record selection if user has edit/delete permissions on the current table $AllowPrintDV = 1; $this->Permissions = getTablePermissions($this->TableName); if ($this->Permissions[3] || $this->Permissions[4]) { // current user can edit or delete? $this->AllowSelection = 1; } elseif (!$this->AllowSelection) { $SelectedID = ''; $AllowPrintDV = 0; $PrintDV = ''; } if (!$this->AllowSelection || !$SelectedID) { $dvprint_x = ''; } $this->QueryFieldsIndexed = reIndex($this->QueryFieldsFilters); // determine type of current view: TV, DV, TVDV, TVP, DVP or Filters? if ($this->SeparateDV) { $current_view = 'TV'; if ($Print_x != '' || $PrintTV != '') { $current_view = 'TVP'; } elseif ($dvprint_x != '' || $PrintDV != '') { $current_view = 'DVP'; } elseif ($Filter_x != '') { $current_view = 'Filters'; } elseif ($SelectedID && !$deselect_x && !$delete_x || $addNew_x != '') { $current_view = 'DV'; } } else { $current_view = 'TVDV'; if ($Print_x != '' || $PrintTV != '') { $current_view = 'TVP'; } elseif ($dvprint_x != '' || $PrintDV != '') { $current_view = 'DVP'; } elseif ($Filter_x != '') { $current_view = 'Filters'; } } $this->HTML .= '<div class="row"><div class="col-xs-11 col-md-12">'; $this->HTML .= '<form ' . (datalist_image_uploads_exist ? 'enctype="multipart/form-data" ' : '') . 'method="post" name="myform" action="' . $this->ScriptFileName . '">'; if ($Embedded) { $this->HTML .= '<input name="Embedded" value="1" type="hidden" />'; } $this->HTML .= '<script>'; $this->HTML .= 'function enterAction(){'; $this->HTML .= ' if($$("input[name=SearchString]:focus")[0] != undefined){ $("Search").click(); }'; $this->HTML .= ' return false;'; $this->HTML .= '}'; $this->HTML .= '</script>'; $this->HTML .= '<input id="EnterAction" type="submit" style="position: absolute; left: 0px; top: -250px;" onclick="return enterAction();">'; $this->ContentType = 'tableview'; // default content type if ($PrintTV != '') { $Print_x = 1; $_POST['Print_x'] = 1; } // handle user commands ... if ($deselect_x != '') { $SelectedID = ''; $this->showTV(); } elseif ($insert_x != '') { $SelectedID = call_user_func($this->TableName . '_insert'); // redirect to a safe url to avoid refreshing and thus // insertion of duplicate records. $url = $this->RedirectAfterInsert; $insert_status = 'record-added-ok=' . rand(); if (!$SelectedID) { $insert_status = 'record-added-error=' . rand(); } // compose filters and sorting foreach ($this->filterers as $filterer => $caption) { if ($_REQUEST['filterer_' . $filterer] != '') { $filtersGET .= '&filterer_' . $filterer . '=' . urlencode($_REQUEST['filterer_' . $filterer]); } } for ($i = 1; $i <= 20 * $FiltersPerGroup; $i++) { // Number of filters allowed if ($FilterField[$i] != '' && $FilterOperator[$i] != '' && ($FilterValue[$i] != '' || strpos($FilterOperator[$i], 'empty'))) { $filtersGET .= "&FilterAnd[{$i}]={$FilterAnd[$i]}&FilterField[{$i}]={$FilterField[$i]}&FilterOperator[{$i}]={$FilterOperator[$i]}&FilterValue[{$i}]=" . urlencode($FilterValue[$i]); } } if ($Embedded) { $filtersGET .= '&Embedded=1&SelectedID=' . urlencode($SelectedID); } $filtersGET .= "&SortField={$SortField}&SortDirection={$SortDirection}&FirstRecord={$FirstRecord}"; $filtersGET .= "&DisplayRecords={$DisplayRecords}"; $filtersGET .= '&SearchString=' . urlencode($SearchString); $filtersGET = substr($filtersGET, 1); // remove initial & if ($url) { /* if designer specified a redirect-after-insert url */ $url .= (strpos($url, '?') !== false ? '&' : '?') . $insert_status; $url .= strpos($url, $this->ScriptFileName) !== false ? "&{$filtersGET}" : ''; $url = str_replace("#ID#", urlencode($SelectedID), $url); } else { /* if no redirect-after-insert url, use default */ $url = "{$this->ScriptFileName}?{$insert_status}&{$filtersGET}"; /* if DV and TV in same page, select new record */ if (!$this->SeparateDV) { $url .= '&SelectedID=' . urlencode($SelectedID); } } @header('Location: ' . $url); $this->HTML .= "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;url=" . $url . "\">"; return; } elseif ($delete_x != '') { $d = call_user_func($this->TableName . '_delete', $SelectedID, $this->AllowDeleteOfParents, $SkipChecks); // handle ajax delete requests if (is_ajax()) { die($d ? $d : 'OK'); } if ($d) { //$_REQUEST['record-deleted-error'] = 1; $this->HTML .= error_message($d); } else { $_REQUEST['record-deleted-ok'] = 1; $SelectedID = ''; $this->showTV(); } } elseif ($update_x != '') { $updated = call_user_func($this->TableName . '_update', $SelectedID); $update_status = 'record-updated-ok=' . rand(); if ($updated === false) { $update_status = 'record-updated-error=' . rand(); } // compose filters and sorting foreach ($this->filterers as $filterer => $caption) { if ($_REQUEST['filterer_' . $filterer] != '') { $filtersGET .= '&filterer_' . $filterer . '=' . urlencode($_REQUEST['filterer_' . $filterer]); } } for ($i = 1; $i <= 20 * $FiltersPerGroup; $i++) { // Number of filters allowed if ($FilterField[$i] != '' && $FilterOperator[$i] != '' && ($FilterValue[$i] != '' || strpos($FilterOperator[$i], 'empty'))) { $filtersGET .= "&FilterAnd[{$i}]={$FilterAnd[$i]}&FilterField[{$i}]={$FilterField[$i]}&FilterOperator[{$i}]={$FilterOperator[$i]}&FilterValue[{$i}]=" . urlencode($FilterValue[$i]); } } $filtersGET .= "&SortField={$SortField}&SortDirection={$SortDirection}&FirstRecord={$FirstRecord}&Embedded={$Embedded}"; $filtersGET .= "&DisplayRecords={$DisplayRecords}"; $filtersGET .= '&SearchString=' . urlencode($SearchString); $filtersGET = substr($filtersGET, 1); // remove initial & $redirectUrl = $this->ScriptFileName . '?SelectedID=' . urlencode($SelectedID) . '&' . $filtersGET . '&' . $update_status; @header("Location: {$redirectUrl}"); $this->HTML .= '<META HTTP-EQUIV="Refresh" CONTENT="0;url=' . $redirectUrl . '">'; return; } elseif ($addNew_x != '') { $SelectedID = ''; $this->hideTV(); } elseif ($Print_x != '') { // print code here .... $this->AllowNavigation = 0; $this->AllowSelection = 0; } elseif ($SaveFilter_x != '' && $this->AllowSavingFilters) { $filter_link = $_SERVER['HTTP_REFERER'] . '?SortField=' . urlencode($SortField) . '&SortDirection=' . $SortDirection . '&'; for ($i = 1; $i <= 20 * $FiltersPerGroup; $i++) { // Number of filters allowed if (($FilterField[$i] != '' || $i == 1) && $FilterOperator[$i] != '' && ($FilterValue[$i] != '' || strpos($FilterOperator[$i], 'empty'))) { $filter_link .= urlencode("FilterAnd[{$i}]") . '=' . urlencode($FilterAnd[$i]) . '&'; $filter_link .= urlencode("FilterField[{$i}]") . '=' . urlencode($FilterField[$i]) . '&'; $filter_link .= urlencode("FilterOperator[{$i}]") . '=' . urlencode($FilterOperator[$i]) . '&'; $filter_link .= urlencode("FilterValue[{$i}]") . '=' . urlencode($FilterValue[$i]) . '&'; } } $filter_link = substr($filter_link, 0, -1); /* trim last '&' */ $this->HTML .= '<div id="saved_filter_source_code" class="row"><div class="col-md-6 col-md-offset-3">'; $this->HTML .= '<div class="panel panel-info">'; $this->HTML .= '<div class="panel-heading"><h3 class="panel-title">' . $Translation["saved filters title"] . "</h3></div>"; $this->HTML .= '<div class="panel-body">'; $this->HTML .= $Translation["saved filters instructions"]; $this->HTML .= '<textarea rows="4" class="form-control vspacer-lg" style="width: 100%;" onfocus="$j(this).select();">' . "<a href=\"{$filter_link}\">Saved filter link<a>" . '</textarea>'; $this->HTML .= "<div><a href=\"{$filter_link}\" title=\"" . htmlspecialchars($filter_link) . "\">{$Translation['permalink']}</a></div>"; $this->HTML .= '<button type="button" class="btn btn-default btn-block vspacer-lg" onclick="$j(\'#saved_filter_source_code\').remove();"><i class="glyphicon glyphicon-remove"></i> ' . $Translation['hide code'] . '</button>'; $this->HTML .= '</div>'; $this->HTML .= '</div>'; $this->HTML .= '</div></div>'; } elseif ($Filter_x != '') { $orderBy = array(); if ($SortField) { $sortFields = explode(',', $SortField); $i = 0; foreach ($sortFields as $sf) { $tob = preg_split('/\\s+/', $sf, 2); $orderBy[] = array(trim($tob[0]) => strtolower(trim($tob[1])) == 'desc' ? 'desc' : 'asc'); $i++; } $orderBy[$i - 1][$tob[0]] = strtolower(trim($SortDirection)) == 'desc' ? 'desc' : 'asc'; } $currDir = dirname(__FILE__) . '/hooks'; // path to hooks folder $uff = "{$currDir}/{$this->TableName}.filters.{$mi['username']}.php"; // user-specific filter file $gff = "{$currDir}/{$this->TableName}.filters.{$mi['group']}.php"; // group-specific filter file $tff = "{$currDir}/{$this->TableName}.filters.php"; // table-specific filter file /* if no explicit filter file exists, look for filter files in the hooks folder in this order: 1. tablename.filters.username.php ($uff) 2. tablename.filters.groupname.php ($gff) 3. tablename.filters.php ($tff) */ if (!is_file($this->FilterPage)) { $this->FilterPage = 'defaultFilters.php'; if (is_file($uff)) { $this->FilterPage = $uff; } elseif (is_file($gff)) { $this->FilterPage = $gff; } elseif (is_file($tff)) { $this->FilterPage = $tff; } } if ($this->FilterPage != '') { ob_start(); @(include $this->FilterPage); $out = ob_get_contents(); ob_end_clean(); $this->HTML .= $out; } // hidden variables .... $this->HTML .= '<input name="SortField" value="' . $SortField . '" type="hidden" />'; $this->HTML .= '<input name="SortDirection" type="hidden" value="' . $SortDirection . '" />'; $this->HTML .= '<input name="FirstRecord" type="hidden" value="1" />'; $this->ContentType = 'filters'; return; } elseif ($NoFilter_x != '') { // clear all filters ... for ($i = 1; $i <= datalist_filters_count * $FiltersPerGroup; $i++) { // Number of filters allowed $FilterField[$i] = ''; $FilterOperator[$i] = ''; $FilterValue[$i] = ''; } $DisplayRecords = 'all'; $SearchString = ''; $FirstRecord = 1; // clear filterers foreach ($this->filterers as $filterer => $caption) { $_REQUEST['filterer_' . $filterer] = ''; } } elseif ($SelectedID) { $this->hideTV(); } // apply lookup filterers to the query foreach ($this->filterers as $filterer => $caption) { if ($_REQUEST['filterer_' . $filterer] != '') { if ($this->QueryWhere == '') { $this->QueryWhere = "where "; } else { $this->QueryWhere .= " and "; } $this->QueryWhere .= "`{$this->TableName}`.`{$filterer}`='" . makeSafe($_REQUEST['filterer_' . $filterer]) . "' "; break; // currently, only one filterer can be applied at a time } } // apply quick search to the query if ($SearchString != '') { if ($Search_x != '') { $FirstRecord = 1; } if ($this->QueryWhere == '') { $this->QueryWhere = "where "; } else { $this->QueryWhere .= " and "; } foreach ($this->QueryFieldsQS as $fName => $fCaption) { if (strpos($fName, '<img') === False) { $this->QuerySearchableFields[$fName] = $fCaption; } } $this->QueryWhere .= '(' . implode(" LIKE '%" . makeSafe($SearchString) . "%' or ", array_keys($this->QuerySearchableFields)) . " LIKE '%" . makeSafe($SearchString) . "%')"; } // set query filters $QueryHasWhere = 0; if (strpos($this->QueryWhere, 'where ') !== FALSE) { $QueryHasWhere = 1; } $WhereNeedsClosing = 0; for ($i = 1; $i <= datalist_filters_count * $FiltersPerGroup; $i += $FiltersPerGroup) { // Number of filters allowed // test current filter group $GroupHasFilters = 0; for ($j = 0; $j < $FiltersPerGroup; $j++) { if ($FilterField[$i + $j] != '' && $this->QueryFieldsIndexed[$FilterField[$i + $j]] != '' && $FilterOperator[$i + $j] != '' && ($FilterValue[$i + $j] != '' || strpos($FilterOperator[$i + $j], 'empty'))) { $GroupHasFilters = 1; break; } } if ($GroupHasFilters) { if (!stristr($this->QueryWhere, "where ")) { $this->QueryWhere = "where ("; } elseif ($QueryHasWhere) { $this->QueryWhere .= " and ("; $QueryHasWhere = 0; } $this->QueryWhere .= " <FilterGroup> " . $FilterAnd[$i] . " ("; for ($j = 0; $j < $FiltersPerGroup; $j++) { if ($FilterField[$i + $j] != '' && $this->QueryFieldsIndexed[$FilterField[$i + $j]] != '' && $FilterOperator[$i + $j] != '' && ($FilterValue[$i + $j] != '' || strpos($FilterOperator[$i + $j], 'empty'))) { if ($FilterAnd[$i + $j] == '') { $FilterAnd[$i + $j] = 'and'; } // test for date/time fields $tries = 0; $isDateTime = FALSE; $isDate = FALSE; $fieldName = str_replace('`', '', $this->QueryFieldsIndexed[$FilterField[$i + $j]]); list($tn, $fn) = explode('.', $fieldName); while (!($res = sql("show columns from `{$tn}` like '{$fn}'", $eo)) && $tries < 2) { $tn = substr($tn, 0, -1); $tries++; } if ($row = @db_fetch_array($res)) { if ($row['Type'] == 'date' || $row['Type'] == 'time') { $isDateTime = TRUE; if ($row['Type'] == 'date') { $isDate = True; } } } // end of test if ($FilterOperator[$i + $j] == 'is-empty' && !$isDateTime) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " (" . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . "='' or " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " is NULL) </FilterItem>"; } elseif ($FilterOperator[$i + $j] == 'is-not-empty' && !$isDateTime) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . "!='' </FilterItem>"; } elseif ($FilterOperator[$i + $j] == 'is-empty' && $isDateTime) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " (" . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . "=0 or " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " is NULL) </FilterItem>"; } elseif ($FilterOperator[$i + $j] == 'is-not-empty' && $isDateTime) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . "!=0 </FilterItem>"; } elseif ($FilterOperator[$i + $j] == 'like' && !strstr($FilterValue[$i + $j], "%") && !strstr($FilterValue[$i + $j], "_")) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " like '%" . makeSafe($FilterValue[$i + $j]) . "%' </FilterItem>"; } elseif ($FilterOperator[$i + $j] == 'not-like' && !strstr($FilterValue[$i + $j], "%") && !strstr($FilterValue[$i + $j], "_")) { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " not like '%" . makeSafe($FilterValue[$i + $j]) . "%' </FilterItem>"; } elseif ($isDate) { $dateValue = toMySQLDate($FilterValue[$i + $j]); $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " " . $GLOBALS['filter_operators'][$FilterOperator[$i + $j]] . " '{$dateValue}' </FilterItem>"; } else { $this->QueryWhere .= " <FilterItem> " . $FilterAnd[$i + $j] . " " . $this->QueryFieldsIndexed[$FilterField[$i + $j]] . " " . $GLOBALS['filter_operators'][$FilterOperator[$i + $j]] . " '" . makeSafe($FilterValue[$i + $j]) . "' </FilterItem>"; } } } $this->QueryWhere .= ") </FilterGroup>"; $WhereNeedsClosing = 1; } } if ($WhereNeedsClosing) { $this->QueryWhere .= ")"; } // set query sort if (!stristr($this->QueryOrder, "order by ") && $SortField != '' && $this->AllowSorting) { $actualSortField = $SortField; foreach ($this->SortFields as $fieldNum => $fieldSort) { $actualSortField = str_replace(" {$fieldNum} ", " {$fieldSort} ", " {$actualSortField} "); $actualSortField = str_replace(",{$fieldNum} ", ",{$fieldSort} ", " {$actualSortField} "); } $this->QueryOrder = "order by {$actualSortField} {$SortDirection}"; } // clean up query $this->QueryWhere = str_replace('( <FilterGroup> and ', '( ', $this->QueryWhere); $this->QueryWhere = str_replace('( <FilterGroup> or ', '( ', $this->QueryWhere); $this->QueryWhere = str_replace('( <FilterItem> and ', '( ', $this->QueryWhere); $this->QueryWhere = str_replace('( <FilterItem> or ', '( ', $this->QueryWhere); $this->QueryWhere = str_replace('<FilterGroup>', '', $this->QueryWhere); $this->QueryWhere = str_replace('</FilterGroup>', '', $this->QueryWhere); $this->QueryWhere = str_replace('<FilterItem>', '', $this->QueryWhere); $this->QueryWhere = str_replace('</FilterItem>', '', $this->QueryWhere); // if no 'order by' clause found, apply default sorting if specified if ($this->DefaultSortField != '' && $this->QueryOrder == '') { $this->QueryOrder = "order by " . $this->DefaultSortField . " " . $this->DefaultSortDirection; } // get count of matching records ... $TempQuery = 'SELECT count(1) from ' . $this->QueryFrom . ' ' . $this->QueryWhere; $RecordCount = sqlValue($TempQuery); $FieldCountTV = count($this->QueryFieldsTV); $FieldCountCSV = count($this->QueryFieldsCSV); $FieldCountFilters = count($this->QueryFieldsFilters); if (!$RecordCount) { $FirstRecord = 1; } // Output CSV on request if ($CSV_x != '') { $this->HTML = ''; if (datalist_db_encoding == 'UTF-8') { $this->HTML = ""; } // BOM characters for UTF-8 output // execute query for CSV output $fieldList = ''; foreach ($this->QueryFieldsCSV as $fn => $fc) { $fieldList .= "{$fn} as `{$fc}`, "; } $fieldList = substr($fieldList, 0, -2); $csvQuery = 'SELECT ' . $fieldList . ' from ' . $this->QueryFrom . ' ' . $this->QueryWhere . ' ' . $this->QueryOrder; // hook: table_csv if (function_exists($this->TableName . '_csv')) { $args = array(); $mq = call_user_func_array($this->TableName . '_csv', array($csvQuery, $mi, &$args)); $csvQuery = $mq ? $mq : $csvQuery; } $result = sql($csvQuery, $eo); // output CSV field names for ($i = 0; $i < $FieldCountCSV; $i++) { $this->HTML .= "\"" . db_field_name($result, $i) . "\"" . $this->CSVSeparator; } $this->HTML .= "\n\n"; // output CSV data while ($row = db_fetch_row($result)) { for ($i = 0; $i < $FieldCountCSV; $i++) { $this->HTML .= "\"" . str_replace(array("\r\n", "\r", "\n", '"'), array(' ', ' ', ' ', '""'), strip_tags($row[$i])) . "\"" . $this->CSVSeparator; } $this->HTML .= "\n\n"; } $this->HTML = str_replace($this->CSVSeparator . "\n\n", "\n", $this->HTML); $this->HTML = substr($this->HTML, 0, -1); // clean any output buffers while (@ob_end_clean()) { } // output CSV HTTP headers ... header('HTTP/1.1 200 OK'); header('Date: ' . @date("D M j G:i:s T Y")); header('Last-Modified: ' . @date("D M j G:i:s T Y")); header("Content-Type: application/force-download"); header("Content-Length: " . (string) strlen($this->HTML)); header("Content-Transfer-Encoding: Binary"); header("Content-Disposition: attachment; filename={$this->TableName}.csv"); // send output and quit script echo $this->HTML; exit; } $t = time(); // just a random number for any purpose ... // should SelectedID be reset on clicking TV buttons? $resetSelection = $this->SeparateDV ? "document.myform.SelectedID.value = '';" : "document.myform.writeAttribute('novalidate', 'novalidate');"; if ($current_view == 'DV' && !$Embedded) { $this->HTML .= '<div class="page-header">'; $this->HTML .= '<h1>'; $this->HTML .= '<a style="text-decoration: none; color: inherit;" href="' . $this->TableName . '_view.php"><img src="' . $this->TableIcon . '"> ' . $this->TableTitle . '</a>'; $this->HTML .= '</h1>'; $this->HTML .= '</div>'; } // quick search and TV action buttons if (!$this->HideTableView && !($dvprint_x && $this->AllowSelection && $SelectedID) && !$PrintDV) { $buttons_all = $quick_search_html = ''; if ($Print_x == '') { // display 'Add New' icon if ($this->Permissions[1] && $this->SeparateDV) { $buttons_all .= '<button type="submit" id="addNew" name="addNew_x" value="1" class="btn btn-success"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Add New'] . '</button>'; $buttonsCount++; } // display Print icon if ($this->AllowPrinting) { $buttons_all .= '<button onClick="document.myform.NoDV.value=1; ' . $resetSelection . ' return true;" type="submit" name="Print_x" id="Print" value="1" class="btn btn-default"><i class="glyphicon glyphicon-print"></i> ' . $Translation['Print Preview'] . '</button>'; $buttonsCount++; } // display CSV icon if ($this->AllowCSV) { $buttons_all .= '<button onClick="document.myform.NoDV.value=1; ' . $resetSelection . ' return true;" type="submit" name="CSV_x" id="CSV" value="1" class="btn btn-default"><i class="glyphicon glyphicon-download-alt"></i> ' . $Translation['CSV'] . '</button>'; $buttonsCount++; } // display Filter icon if ($this->AllowFilters) { $buttons_all .= '<button onClick="document.myform.NoDV.value=1; ' . $resetSelection . ' return true;" type="submit" name="Filter_x" id="Filter" value="1" class="btn btn-default"><i class="glyphicon glyphicon-filter"></i> ' . $Translation['filter'] . '</button>'; $buttonsCount++; } // display Show All icon if ($this->AllowFilters) { $buttons_all .= '<button onClick="document.myform.NoDV.value=1; ' . $resetSelection . ' return true;" type="submit" name="NoFilter_x" id="NoFilter" value="1" class="btn btn-default"><i class="glyphicon glyphicon-remove-circle"></i> ' . $Translation['Reset Filters'] . '</button>'; $buttonsCount++; } $quick_search_html .= '<div class="input-group" id="quick-search">'; $quick_search_html .= '<input type="text" name="SearchString" value="' . htmlspecialchars($SearchString, ENT_QUOTES, 'iso-8859-1') . '" class="form-control" placeholder="' . htmlspecialchars($this->QuickSearchText) . '">'; $quick_search_html .= '<span class="input-group-btn">'; $quick_search_html .= '<button name="Search_x" value="1" id="Search" type="submit" onClick="' . $resetSelection . ' document.myform.NoDV.value=1; return true;" class="btn btn-default" title="' . htmlspecialchars($this->QuickSearchText) . '"><i class="glyphicon glyphicon-search"></i></button>'; $quick_search_html .= '<button name="NoFilter_x" value="1" id="NoFilter_x" type="submit" onClick="' . $resetSelection . ' document.myform.NoDV.value=1; return true;" class="btn btn-default" title="' . htmlspecialchars($Translation['Reset Filters']) . '"><i class="glyphicon glyphicon-remove-circle"></i></button>'; $quick_search_html .= '</span>'; $quick_search_html .= '</div>'; } else { $buttons_all .= '<button class="btn btn-primary" type="button" id="sendToPrinter" onClick="window.print();"><i class="glyphicon glyphicon-print"></i> ' . $Translation['Print'] . '</button>'; $buttons_all .= '<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-remove-circle"></i> ' . $Translation['Cancel Printing'] . '</button>'; } /* if user can print DV, add action to 'More' menu */ $selected_records_more = array(); if ($AllowPrintDV) { $selected_records_more[] = array('function' => $this->SeparateDV ? 'print_multiple_dv_sdv' : 'print_multiple_dv_tvdv', 'title' => $Translation['Print Preview Detail View'], 'icon' => 'print'); } /* if user can mass-delete selected records, add action to 'More' menu */ if ($this->AllowMassDelete && $this->AllowDelete) { $selected_records_more[] = array('function' => 'mass_delete', 'title' => $Translation['Delete'], 'icon' => 'trash', 'class' => 'text-danger'); } /* if user is admin, add 'Change owner' action to 'More' menu */ /* also, add help link for adding more actions */ if ($mi['admin']) { $selected_records_more[] = array('function' => 'mass_change_owner', 'title' => $Translation['Change owner'], 'icon' => 'user'); $selected_records_more[] = array('function' => 'add_more_actions_link', 'title' => $Translation['Add more actions'], 'icon' => 'question-sign', 'class' => 'text-info'); } /* user-defined actions ... should be set in the {tablename}_batch_actions() function in hooks/{tablename}.php */ $user_actions = array(); if (function_exists($this->TableName . '_batch_actions')) { $args = array(); $user_actions = call_user_func_array($this->TableName . '_batch_actions', array(&$args)); if (is_array($user_actions) && count($user_actions)) { $selected_records_more = array_merge($selected_records_more, $user_actions); } } $actual_more_count = 0; $more_menu = $more_menu_js = ''; if (count($selected_records_more)) { $more_menu .= '<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" id="selected_records_more"><i class="glyphicon glyphicon-check"></i> ' . $Translation['More'] . ' <span class="caret"></span></button>'; $more_menu .= '<ul class="dropdown-menu" role="menu">'; foreach ($selected_records_more as $action) { if (!$action['function'] || !$action['title']) { continue; } $action['class'] = !isset($action['class']) ? '' : $action['class']; $action['icon'] = !isset($action['icon']) ? '' : $action['icon']; $actual_more_count++; $more_menu .= '<li>' . '<a href="#" id="selected_records_' . $action['function'] . '">' . '<span class="' . $action['class'] . '">' . ($action['icon'] ? '<i class="glyphicon glyphicon-' . $action['icon'] . '"></i> ' : '') . $action['title'] . '</span>' . '</a>' . '</li>'; // on clicking an action, call its js handler function, passing the current table name and an array of selected IDs to it $more_menu_js .= "jQuery('[id=selected_records_{$action['function']}]').click(function(){ {$action['function']}('{$this->TableName}', get_selected_records_ids()); return false; });"; } $more_menu .= '</ul>'; } if ($Embedded) { $this->HTML .= '<script>$j(function(){ $j(\'[id^=notification-]\').parent().css({\'margin-top\': \'15px\', \'margin-bottom\': \'0\'}); })</script>'; } else { $this->HTML .= '<div class="page-header">'; $this->HTML .= '<h1>'; $this->HTML .= '<div class="row">'; $this->HTML .= '<div class="col-sm-8">'; $this->HTML .= '<a style="text-decoration: none; color: inherit;" href="' . $this->TableName . '_view.php"><img src="' . $this->TableIcon . '"> ' . $this->TableTitle . '</a>'; $this->HTML .= '</div>'; if ($this->QuickSearch) { $this->HTML .= '<div class="col-sm-4">'; $this->HTML .= $quick_search_html; $this->HTML .= '</div>'; } $this->HTML .= '</div>'; $this->HTML .= '</h1>'; $this->HTML .= '</div>'; $this->HTML .= '<div id="top_buttons" class="hidden-print">'; /* .all_records: container for buttons that don't need a selection */ /* .selected_records: container for buttons that need a selection */ $this->HTML .= '<div class="btn-group btn-group-lg visible-md visible-lg all_records pull-left">' . $buttons_all . '</div>'; $this->HTML .= '<div class="btn-group btn-group-lg visible-md visible-lg selected_records hidden pull-left hspacer-lg">' . $buttons_selected . ($actual_more_count ? $more_menu : '') . '</div>'; $this->HTML .= '<div class="btn-group-vertical btn-group-lg visible-xs visible-sm all_records">' . $buttons_all . '</div>'; $this->HTML .= '<div class="btn-group-vertical btn-group-lg visible-xs visible-sm selected_records hidden vspacer-lg">' . $buttons_selected . ($actual_more_count ? $more_menu : '') . '</div>'; $this->HTML .= '<div class="clearfix"></div><p></p>'; $this->HTML .= '</div>'; } if ($Print_x != '') { /* fix top margin for print-preview */ $this->HTML .= '<style>body{ padding-top: 0 !important; }</style>'; /* disable links inside table body to prevent printing their href */ $this->HTML .= '<script>jQuery(function(){ jQuery("tbody a").removeAttr("href").removeAttr("rel"); });</script>'; } // script for focusing into the search box on loading the page // and for declaring record action handlers $this->HTML .= '<script>jQuery(function(){ jQuery("input[name=SearchString]").focus(); ' . $more_menu_js . ' });</script>'; } // begin table and display table title if (!$this->HideTableView && !($dvprint_x && $this->AllowSelection && $SelectedID) && !$PrintDV && !$Embedded) { $this->HTML .= '<div class="table-responsive"><table class="table table-striped table-bordered table-hover">'; $this->HTML .= '<thead><tr>'; if (!$Print_x) { $this->HTML .= '<th style="width: 18px;" class="text-center"><input class="hidden-print" type="checkbox" title="' . htmlspecialchars($Translation['Select all records']) . '" id="select_all_records"></th>'; } // Templates if ($this->Template != '') { $rowTemplate = @implode('', @file('./' . $this->Template)); if (!$rowTemplate) { $rowTemplate = ''; $selrowTemplate = ''; } else { if ($this->SelectedTemplate != '') { $selrowTemplate = @implode('', @file('./' . $this->SelectedTemplate)); if (!$selrowTemplate) { $selrowTemplate = ''; } } else { $selrowTemplate = ''; } } } else { $rowTemplate = ''; $selrowTemplate = ''; } // process translations if ($rowTemplate) { foreach ($Translation as $symbol => $trans) { $rowTemplate = str_replace("<%%TRANSLATION({$symbol})%%>", $trans, $rowTemplate); } } if ($selrowTemplate) { foreach ($Translation as $symbol => $trans) { $selrowTemplate = str_replace("<%%TRANSLATION({$symbol})%%>", $trans, $selrowTemplate); } } // End of templates // $this->ccffv: map $FilterField values to field captions as stored in ColCaption $this->ccffv = array(); foreach ($this->ColCaption as $captionIndex => $caption) { $ffv = 1; foreach ($this->QueryFieldsFilters as $uselessKey => $filterCaption) { if ($caption == $filterCaption) { $this->ccffv[$captionIndex] = $ffv; } $ffv++; } } // display table headers $totalColWidth = array_sum($this->ColWidth); $forceHeaderWidth = false; if ($rowTemplate == '' || $this->ShowTableHeader) { for ($i = 0; $i < count($this->ColCaption); $i++) { /* Sorting icon and link */ $sort1 = $sort2 = $filterHint = ''; if ($this->AllowSorting == 1) { if ($current_view != 'TVP') { $sort1 = "<a href=\"{$this->ScriptFileName}?SortDirection=asc&SortField=" . $this->ColNumber[$i] . "\" onClick=\"{$resetSelection} document.myform.NoDV.value=1; document.myform.SortDirection.value='asc'; document.myform.SortField.value = '" . $this->ColNumber[$i] . "'; document.myform.submit(); return false;\" class=\"TableHeader\">"; $sort2 = "</a>"; } if ($this->ColNumber[$i] == $SortField) { $SortDirection = $SortDirection == "asc" ? "desc" : "asc"; if ($current_view != 'TVP') { $sort1 = "<a href=\"{$this->ScriptFileName}?SortDirection={$SortDirection}&SortField=" . $this->ColNumber[$i] . "\" onClick=\"{$resetSelection} document.myform.NoDV.value=1; document.myform.SortDirection.value='{$SortDirection}'; document.myform.SortField.value = " . $this->ColNumber[$i] . "; document.myform.submit(); return false;\" class=\"TableHeader\">"; } $sort2 = " <i class=\"text-warning glyphicon glyphicon-sort-by-attributes" . ($SortDirection == 'desc' ? '' : '-alt') . "\"></i>{$sort2}"; $SortDirection = $SortDirection == "asc" ? "desc" : "asc"; } } else { $sort1 = ''; $sort2 = ''; } /* Filtering icon and hint */ if ($this->AllowFilters && is_array($FilterField)) { // check to see if there is any filter applied on the current field if (isset($this->ccffv[$i]) && in_array($this->ccffv[$i], $FilterField)) { // render filter icon $filterHint = ' <button type="submit" class="btn btn-default btn-xs' . ($current_view == 'TVP' ? ' disabled' : '') . '" name="Filter_x" value="1" title="' . htmlspecialchars($Translation['filtered field']) . '"><i class="glyphicon glyphicon-filter"></i></button>'; } } $this->HTML .= "\t<th class=\"{$this->TableName}-{$this->ColFieldName[$i]}\" " . ($forceHeaderWidth ? ' style="width: ' . ($this->ColWidth[$i] ? $this->ColWidth[$i] : 100) . 'px;"' : '') . ">{$sort1}{$this->ColCaption[$i]}{$sort2}{$filterHint}</th>\n"; } } else { // Display a Sort by drop down $this->HTML .= "\t<th><td colspan=" . (count($this->ColCaption) + 1) . ">"; if ($this->AllowSorting == 1) { $sortCombo = new Combo(); for ($i = 0; $i < count($this->ColCaption); $i++) { $sortCombo->ListItem[] = $this->ColCaption[$i]; $sortCombo->ListData[] = $this->ColNumber[$i]; } $sortCombo->SelectName = "FieldsList"; $sortCombo->SelectedData = $SortField; $sortCombo->Class = 'TableBody'; $sortCombo->SelectedClass = 'TableBodySelected'; $sortCombo->Render(); $d = $sortCombo->HTML; $d = str_replace('<select ', "<select onChange=\"document.myform.SortDirection.value='{$SortDirection}'; document.myform.SortField.value=document.myform.FieldsList.value; document.myform.NoDV.value=1; document.myform.submit();\" ", $d); if ($SortField) { $SortDirection = $SortDirection == "desc" ? "asc" : "desc"; $sort = "<a href=\"javascript: document.myform.NoDV.value=1; document.myform.SortDirection.value='{$SortDirection}'; document.myform.SortField.value='{$SortField}'; document.myform.submit();\" class=TableHeader><img src={$SortDirection}.gif border=0 width=11 height=11 hspace=3></a>"; $SortDirection = $SortDirection == "desc" ? "asc" : "desc"; } else { $sort = ''; } $this->HTML .= $Translation['order by'] . " {$d} {$sort}"; } $this->HTML .= "</td></th>\n"; } // table view navigation code ... if ($RecordCount && $this->AllowNavigation && $RecordCount > $this->RecordsPerPage) { while ($FirstRecord > $RecordCount) { $FirstRecord -= $this->RecordsPerPage; } if ($FirstRecord == '' || $FirstRecord < 1) { $FirstRecord = 1; } if ($Previous_x != '') { $FirstRecord -= $this->RecordsPerPage; if ($FirstRecord <= 0) { $FirstRecord = 1; } } elseif ($Next_x != '') { $FirstRecord += $this->RecordsPerPage; if ($FirstRecord > $RecordCount) { $FirstRecord = $RecordCount - $RecordCount % $this->RecordsPerPage + 1; } if ($FirstRecord > $RecordCount) { $FirstRecord = $RecordCount - $this->RecordsPerPage + 1; } if ($FirstRecord <= 0) { $FirstRecord = 1; } } } elseif ($RecordCount) { $FirstRecord = 1; $this->RecordsPerPage = 2000; // a limit on max records in print preview to avoid performance drops } // end of table view navigation code $this->HTML .= "\n\t</tr>\n\n</thead>\n\n<tbody><!-- tv data below -->\n"; $i = 0; $hc = new CI_Input(); $hc->charset = datalist_db_encoding; if ($RecordCount) { $i = $FirstRecord; // execute query for table view $fieldList = ''; foreach ($this->QueryFieldsTV as $fn => $fc) { $fieldList .= "{$fn} as `{$fc}`, "; } $fieldList = substr($fieldList, 0, -2); if ($this->PrimaryKey) { $fieldList .= ", {$this->PrimaryKey} as '" . str_replace('`', '', $this->PrimaryKey) . "'"; } $tvQuery = 'SELECT ' . $fieldList . ' from ' . $this->QueryFrom . ' ' . $this->QueryWhere . ' ' . $this->QueryOrder; $result = sql($tvQuery . " limit " . ($i - 1) . ",{$this->RecordsPerPage}", $eo); while (($row = db_fetch_array($result)) && $i < $FirstRecord + $this->RecordsPerPage) { $attr_id = htmlspecialchars($row[$FieldCountTV], ENT_QUOTES, 'iso-8859-1'); /* pk value suitable for inserting into html tag attributes */ $js_id = addslashes($row[$FieldCountTV]); /* pk value suitable for inserting into js strings */ $alt = ($i - $FirstRecord) % 2; if (($PrintTV || $Print_x) && count($_POST['record_selector']) && !in_array($row[$FieldCountTV], $_POST['record_selector'])) { continue; } $class = "TableBody" . ($alt ? 'Selected' : '') . ($fNumeric ? 'Numeric' : ''); if ($Print_x != '') { $this->HTML .= '<tr>'; } if (!$Print_x) { $this->HTML .= $SelectedID == $row[$FieldCountTV] ? '<tr class="active">' : '<tr>'; $checked = is_array($_POST['record_selector']) && in_array($row[$FieldCountTV], $_POST['record_selector']) ? ' checked' : ''; $this->HTML .= "<td class=\"text-center\"><input class=\"hidden-print record_selector\" type=\"checkbox\" id=\"record_selector_{$attr_id}\" name=\"record_selector[]\" value=\"{$attr_id}\"{$checked}></td>"; } // templates if ($rowTemplate != '') { if ($this->AllowSelection == 1 && $SelectedID == $row[$FieldCountTV] && $selrowTemplate != '') { $rowTemp = $selrowTemplate; } else { $rowTemp = $rowTemplate; } if ($this->AllowSelection == 1 && $SelectedID != $row[$FieldCountTV]) { $rowTemp = str_replace('<%%SELECT%%>', "<a onclick=\"document.myform.SelectedField.value=this.parentNode.cellIndex; document.myform.SelectedID.value='" . addslashes($row[$FieldCountTV]) . "'; document.myform.submit(); return false;\" href=\"{$this->ScriptFileName}?SelectedID=" . htmlspecialchars($row[$FieldCountTV], ENT_QUOTES) . "\" class=\"{$class}\" style=\"display: block; padding:0px;\">", $rowTemp); $rowTemp = str_replace('<%%ENDSELECT%%>', '</a>', $rowTemp); } else { $rowTemp = str_replace('<%%SELECT%%>', '', $rowTemp); $rowTemp = str_replace('<%%ENDSELECT%%>', '', $rowTemp); } for ($j = 0; $j < $FieldCountTV; $j++) { $fieldTVCaption = current(array_slice($this->QueryFieldsTV, $j, 1)); $fd = $hc->xss_clean(nl2br($row[$j])); /* Sanitize output against XSS attacks */ /* the TV template could contain field placeholders in the format <%%FIELD_n%%> or <%%VALUE(Field name)%%> */ $rowTemp = str_replace("<%%FIELD_{$j}%%>", thisOr($fd), $rowTemp); $rowTemp = str_replace("<%%VALUE({$fieldTVCaption})%%>", thisOr($fd), $rowTemp); if (strpos($rowTemp, "<%%YOUTUBETHUMB({$fieldTVCaption})%%>") !== false) { $rowTemp = str_replace("<%%YOUTUBETHUMB({$fieldTVCaption})%%>", thisOr(get_embed('youtube', $fd, '', '', 'thumbnail_url'), 'blank.gif'), $rowTemp); } if (strpos($rowTemp, "<%%GOOGLEMAPTHUMB({$fieldTVCaption})%%>") !== false) { $rowTemp = str_replace("<%%GOOGLEMAPTHUMB({$fieldTVCaption})%%>", thisOr(get_embed('googlemap', $fd, '', '', 'thumbnail_url'), 'blank.gif'), $rowTemp); } if (thisOr($fd) == ' ' && preg_match('/<a href=".*? .*?<\\/a>/i', $rowTemp, $m)) { $rowTemp = str_replace($m[0], '', $rowTemp); } } if ($alt && $SelectedID != $row[$FieldCountTV]) { $rowTemp = str_replace("TableBody", "TableBodySelected", $rowTemp); $rowTemp = str_replace("TableBodyNumeric", "TableBodySelectedNumeric", $rowTemp); $rowTemp = str_replace("SelectedSelected", "Selected", $rowTemp); } if ($SearchString != '') { $rowTemp = highlight($SearchString, $rowTemp); } $this->HTML .= $rowTemp; $rowTemp = ''; } else { // end of templates for ($j = 0; $j < $FieldCountTV; $j++) { $fType = db_field_type($result, $j); $fNumeric = stristr($fType, 'int') || stristr($fType, 'float') || stristr($fType, 'decimal') || stristr($fType, 'numeric') || stristr($fType, 'real') || stristr($fType, 'double') ? true : false; if ($this->AllowSelection == 1) { $sel1 = "<a href=\"{$this->ScriptFileName}?SelectedID=" . htmlspecialchars($row[$FieldCountTV], ENT_QUOTES) . "\" onclick=\"document.myform.SelectedID.value='" . addslashes($row[$FieldCountTV]) . "'; document.myform.submit(); return false;\" class=\"{$class}\" style=\"padding:0px;\">"; $sel2 = "</a>"; } else { $sel1 = ''; $sel2 = ''; } $this->HTML .= "<td valign=top class={$class}><div class={$class}> {$sel1}" . $row[$j] . "{$sel2} </div></td>"; } } $this->HTML .= "</tr>\n"; $i++; } $i--; } $this->HTML = preg_replace("/<a href=\"(mailto:)? [^\n]*title=\" \"><\\/a>/", ' ', $this->HTML); $this->HTML = preg_replace("/<a [^>]*>( )*<\\/a>/", ' ', $this->HTML); $this->HTML = preg_replace("/<%%.*%%>/U", ' ', $this->HTML); // end of data $this->HTML .= '<!-- tv data above -->'; $this->HTML .= "\n</tbody>"; if ($Print_x == '') { // TV $pagesMenu = ''; if ($RecordCount > $this->RecordsPerPage) { $pagesMenuId = "{$this->TableName}_pagesMenu"; $pagesMenu = $Translation['go to page'] . ' <select class="input-sm" id="' . $pagesMenuId . '" onChange="document.myform.writeAttribute(\'novalidate\', \'novalidate\'); document.myform.NoDV.value=1; document.myform.FirstRecord.value=(this.value * ' . $this->RecordsPerPage . '+1); document.myform.submit();">'; $pagesMenu .= '</select>'; $pagesMenu .= '<script>'; $pagesMenu .= 'var lastPage = ' . (ceil($RecordCount / $this->RecordsPerPage) - 1) . ';'; $pagesMenu .= 'var currentPage = ' . ($FirstRecord - 1) / $this->RecordsPerPage . ';'; $pagesMenu .= 'var pagesMenu = document.getElementById("' . $pagesMenuId . '");'; $pagesMenu .= 'var lump = ' . datalist_max_page_lump . ';'; $pagesMenu .= 'if(lastPage <= lump * 3){'; $pagesMenu .= ' addPageNumbers(0, lastPage);'; $pagesMenu .= '}else{'; $pagesMenu .= ' addPageNumbers(0, lump - 1);'; $pagesMenu .= ' if(currentPage < lump) addPageNumbers(lump, currentPage + lump / 2);'; $pagesMenu .= ' if(currentPage >= lump && currentPage < (lastPage - lump)){'; $pagesMenu .= ' addPageNumbers('; $pagesMenu .= ' Math.max(currentPage - lump / 2, lump),'; $pagesMenu .= ' Math.min(currentPage + lump / 2, lastPage - lump - 1)'; $pagesMenu .= ' );'; $pagesMenu .= ' }'; $pagesMenu .= ' if(currentPage >= (lastPage - lump)) addPageNumbers(currentPage - lump / 2, lastPage - lump - 1);'; $pagesMenu .= ' addPageNumbers(lastPage - lump, lastPage);'; $pagesMenu .= '}'; $pagesMenu .= 'function addPageNumbers(fromPage, toPage){'; $pagesMenu .= ' var ellipsesIndex = 0;'; $pagesMenu .= ' if(fromPage > toPage) return;'; $pagesMenu .= ' if(fromPage > 0){'; $pagesMenu .= ' if(pagesMenu.options[pagesMenu.options.length - 1].text != fromPage){'; $pagesMenu .= ' ellipsesIndex = pagesMenu.options.length;'; $pagesMenu .= ' fromPage--;'; $pagesMenu .= ' }'; $pagesMenu .= ' }'; $pagesMenu .= ' for(i = fromPage; i <= toPage; i++){'; $pagesMenu .= ' var option = document.createElement("option");'; $pagesMenu .= ' option.text = (i + 1);'; $pagesMenu .= ' option.value = i;'; $pagesMenu .= ' if(i == currentPage){ option.selected = "selected"; }'; $pagesMenu .= ' try{'; $pagesMenu .= ' /* for IE earlier than version 8 */'; $pagesMenu .= ' pagesMenu.add(option, pagesMenu.options[null]);'; $pagesMenu .= ' }catch(e){'; $pagesMenu .= ' pagesMenu.add(option, null);'; $pagesMenu .= ' }'; $pagesMenu .= ' }'; $pagesMenu .= ' if(ellipsesIndex > 0){'; $pagesMenu .= ' pagesMenu.options[ellipsesIndex].text = " ... ";'; $pagesMenu .= ' }'; $pagesMenu .= '}'; $pagesMenu .= '</script>'; } $this->HTML .= "\n\t"; if ($i) { // 1 or more records found $this->HTML .= "<tfoot><tr><td colspan=" . (count($this->ColCaption) + 1) . '>'; $this->HTML .= $Translation['records x to y of z']; $this->HTML .= '</td></tr></tfoot>'; } if (!$i) { // no records found $this->HTML .= "<tfoot><tr><td colspan=" . (count($this->ColCaption) + 1) . '>'; $this->HTML .= '<div class="alert alert-warning">'; $this->HTML .= '<i class="glyphicon glyphicon-warning-sign"></i> '; $this->HTML .= $Translation['No matches found!']; $this->HTML .= '</div>'; $this->HTML .= '</td></tr></tfoot>'; } } else { // TVP if ($i) { $this->HTML .= "\n\t<tfoot><tr><td colspan=" . (count($this->ColCaption) + 1) . '>' . $Translation['records x to y of z'] . '</td></tr></tfoot>'; } if (!$i) { $this->HTML .= "\n\t<tfoot><tr><td colspan=" . (count($this->ColCaption) + 1) . '>' . $Translation['No matches found!'] . '</td></tr></tfoot>'; } } $this->HTML = str_replace("<FirstRecord>", number_format($FirstRecord), $this->HTML); $this->HTML = str_replace("<LastRecord>", number_format($i), $this->HTML); $this->HTML = str_replace("<RecordCount>", number_format($RecordCount), $this->HTML); $tvShown = true; $this->HTML .= "</table></div>\n"; if ($Print_x == '' && $i) { // TV $this->HTML .= '<div class="row">'; $this->HTML .= '<div class="col-sm-4 col-md-3 col-lg-2 vspacer-lg">'; $this->HTML .= '<button onClick="' . $resetSelection . ' document.myform.NoDV.value = 1; return true;" type="submit" name="Previous_x" id="Previous" value="1" class="btn btn-default btn-block"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Previous'] . '</button>'; $this->HTML .= '</div>'; $this->HTML .= '<div class="col-sm-4 col-md-4 col-lg-2 col-md-offset-1 col-lg-offset-3 text-center vspacer-lg">'; $this->HTML .= $pagesMenu; $this->HTML .= '</div>'; $this->HTML .= '<div class="col-sm-4 col-md-3 col-lg-2 col-md-offset-1 col-lg-offset-3 text-right vspacer-lg">'; $this->HTML .= '<button onClick="' . $resetSelection . ' document.myform.NoDV.value=1; return true;" type="submit" name="Next_x" id="Next" value="1" class="btn btn-default btn-block">' . $Translation['Next'] . ' <i class="glyphicon glyphicon-chevron-right"></i></button>'; $this->HTML .= '</div>'; $this->HTML .= '</div>'; } } /* that marks the end of the TV table */ // hidden variables .... foreach ($this->filterers as $filterer => $caption) { if ($_REQUEST['filterer_' . $filterer] != '') { $this->HTML .= "<input name=\"filterer_{$filterer}\" value=\"" . htmlspecialchars($_REQUEST['filterer_' . $filterer], ENT_QUOTES, 'iso-8859-1') . "\" type=\"hidden\" />"; break; // currently, only one filterer can be applied at a time } } $this->HTML .= '<input name="SortField" value="' . $SortField . '" type="hidden">'; $this->HTML .= '<input name="SelectedID" value="' . htmlspecialchars($SelectedID, ENT_QUOTES, 'iso-8859-1') . '" type="hidden">'; $this->HTML .= '<input name="SelectedField" value="" type="hidden">'; $this->HTML .= '<input name="SortDirection" type="hidden" value="' . $SortDirection . '">'; $this->HTML .= '<input name="FirstRecord" type="hidden" value="' . $FirstRecord . '">'; $this->HTML .= '<input name="NoDV" type="hidden" value="">'; $this->HTML .= '<input name="PrintDV" type="hidden" value="">'; if ($this->QuickSearch && !strpos($this->HTML, 'SearchString')) { $this->HTML .= '<input name="SearchString" type="hidden" value="' . htmlspecialchars($SearchString, ENT_QUOTES, 'iso-8859-1') . '">'; } // hidden variables: filters ... $FiltersCode = ''; for ($i = 1; $i <= datalist_filters_count * $FiltersPerGroup; $i++) { // Number of filters allowed if ($i % $FiltersPerGroup == 1 && $i != 1 && $FilterAnd[$i] != '') { $FiltersCode .= "<input name=\"FilterAnd[{$i}]\" value=\"{$FilterAnd[$i]}\" type=\"hidden\">\n"; } if ($FilterField[$i] != '' && $FilterOperator[$i] != '' && ($FilterValue[$i] != '' || strpos($FilterOperator[$i], 'empty'))) { if (!strstr($FiltersCode, "<input name=\"FilterAnd[{$i}]\" value=")) { $FiltersCode .= "<input name=\"FilterAnd[{$i}]\" value=\"{$FilterAnd[$i]}\" type=\"hidden\">\n"; } $FiltersCode .= "<input name=\"FilterField[{$i}]\" value=\"{$FilterField[$i]}\" type=\"hidden\">\n"; $FiltersCode .= "<input name=\"FilterOperator[{$i}]\" value=\"{$FilterOperator[$i]}\" type=\"hidden\">\n"; $FiltersCode .= "<input name=\"FilterValue[{$i}]\" value=\"" . htmlspecialchars($FilterValue[$i], ENT_QUOTES, 'iso-8859-1') . "\" type=\"hidden\">\n"; } } $FiltersCode .= "<input name=\"DisplayRecords\" value=\"{$DisplayRecords}\" type=\"hidden\" />"; $this->HTML .= $FiltersCode; // display details form ... if (($this->AllowSelection || $this->AllowInsert || $this->AllowUpdate || $this->AllowDelete) && $Print_x == '' && !$PrintDV) { if ($this->SeparateDV && $this->HideTableView || !$this->SeparateDV) { $dvCode = call_user_func("{$this->TableName}_form", $SelectedID, $this->AllowUpdate, $this->HideTableView && $SelectedID ? 0 : $this->AllowInsert, $this->AllowDelete, $this->SeparateDV); $this->HTML .= "\n\t<div class=\"panel panel-default detail_view\">{$dvCode}</div>"; $this->HTML .= $this->SeparateDV ? '<input name="SearchString" value="' . htmlspecialchars($SearchString, ENT_QUOTES, 'iso-8859-1') . '" type="hidden">' : ''; if ($dvCode) { $this->ContentType = 'detailview'; $dvShown = true; } } } // display multiple printable detail views if ($PrintDV) { $dvCode = ''; $_POST['dvprint_x'] = $_GET['dvprint_x'] = $_REQUEST['dvprint_x'] = 1; // hidden vars foreach ($this->filterers as $filterer => $caption) { if ($_REQUEST['filterer_' . $filterer] != '') { $this->HTML .= "<input name=\"filterer_{$filterer}\" value=\"" . htmlspecialchars($_REQUEST['filterer_' . $filterer], ENT_QUOTES, 'iso-8859-1') . "\" type=\"hidden\" />"; break; // currently, only one filterer can be applied at a time } } // count selected records $selectedRecords = 0; if (is_array($_POST['record_selector'])) { foreach ($_POST['record_selector'] as $id) { $selectedRecords++; $this->HTML .= '<input type="hidden" name="record_selector[]" value="' . htmlspecialchars($id, ENT_QUOTES, 'iso-8859-1') . '">' . "\n"; } } if ($selectedRecords && $selectedRecords <= datalist_max_records_dv_print) { // if records selected > {datalist_max_records_dv_print} don't show DV preview to avoid db performance issues. foreach ($_POST['record_selector'] as $id) { $dvCode .= call_user_func($this->TableName . '_form', $id, 0, 0, 0, 1); } if ($dvCode != '') { $dvCode = preg_replace('/<input .*?type="?image"?.*?>/', '', $dvCode); $this->HTML .= $dvCode; } } else { $this->HTML .= error_message($Translation['Maximum records allowed to enable this feature is'] . ' ' . datalist_max_records_dv_print); $this->HTML .= '<input type="submit" class="print-button" value="' . $Translation['Print Preview Table View'] . '">'; } } $this->HTML .= "</form>"; $this->HTML .= '</div><div class="col-xs-1 md-hidden lg-hidden"></div></div>'; // $this->HTML .= '<font face="garamond">'.htmlspecialchars($tvQuery).'</font>'; // uncomment this line for debugging the table view query if ($dvShown && $tvShown) { $this->ContentType = 'tableview+detailview'; } if ($dvprint_x != '') { $this->ContentType = 'print-detailview'; } if ($Print_x != '') { $this->ContentType = 'print-tableview'; } if ($PrintDV != '') { $this->ContentType = 'print-detailview'; } // call detail view javascript hook file if found $dvJSHooksFile = dirname(__FILE__) . '/hooks/' . $this->TableName . '-dv.js'; if (is_file($dvJSHooksFile) && ($this->ContentType == 'detailview' || $this->ContentType == 'tableview+detailview')) { $this->HTML .= "\n<script src=\"hooks/{$this->TableName}-dv.js\"></script>\n"; } }
function opdat_3_4($under_nr, $lap_nr) { $title = "opdat"; global $version; global $db; global $db_id; global $regnskab; global $regnaar; global $db_type; $s_id = session_id(); $nextver = '3.4.1'; if ($lap_nr < "1") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); db_modify("ALTER TABLE ansatte ADD password text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ansatte ADD overtid numeric(1,0)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.2'; if ($lap_nr < "2") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); $q = db_select("select * from ansatte", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('gruppe', $feltnavne)) { db_modify("ALTER TABLE ansatte ADD gruppe numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("update ansatte set gruppe = '0'", __FILE__ . " linje " . __LINE__); } $q = db_select("select * from varer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('indhold', $feltnavne)) { db_modify("ALTER TABLE varer ADD indhold numeric(15,3)", __FILE__ . " linje " . __LINE__); } db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.3'; if ($lap_nr < "3") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { $q = db_select("select * from regnskab", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('gruppe', $feltnavne)) { db_modify("ALTER TABLE regnskab ADD bilag numeric(1,0)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE regnskab set bilag='0'", __FILE__ . " linje " . __LINE__); } echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("UPDATE grupper set beskrivelse='Bilag og dokumenter',art='bilag' where art = 'FTP'", __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select box6 from grupper where art='bilag'", __FILE__ . " linje " . __LINE__)); if ($r['box6']) { $bilag = 1; } else { $bilag = 0; } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } else { $bilag = 0; } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}',bilag='{$bilag}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.4'; if ($lap_nr < "4") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { $q = db_select("select * from ordrelinjer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('omvbet', $feltnavne)) { db_modify("ALTER TABLE ordrer ADD omvbet varchar(2)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE ordrer set omvbet=''", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ordrelinjer ADD omvbet varchar(2)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE ordrelinjer set omvbet=''", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.5'; if ($lap_nr < "5") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { $r = db_fetch_array(db_select("select email from adresser where art = 'S'", __FILE__ . " linje " . __LINE__)); $email = $r['email']; include "../includes/ordrefunc.php"; include "../includes/std_func.php"; $q = db_select("select ordrelinjer.id ,ordrelinjer.vare_id, ordrelinjer.kostpris, ordrer.valutakurs from ordrelinjer,ordrer where ordrelinjer.ordre_id=ordrer.id and ordrer.status>='3' and ordrer.art = 'DO' and ordrer.fakturadate >= '2014-01-01' and ordrelinjer.vare_id != '0'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { list($koordpr, $koordnr, $koordant, $koordid, $koordart) = explode(chr(9), find_kostpris($r['vare_id'], $r['id'])); $kobs_ordre_pris = explode(",", $koordpr); $ko_ant = count($kobs_ordre_pris); $kostpris = 0; for ($y = 0; $y < $ko_ant; $y++) { if ($r['valutakurs'] && $r['valutakurs'] != 100) { $kobs_ordre_pris[$y] *= 100 / $r['valutakurs']; } $kostpris += $kobs_ordre_pris[$y]; } $kostpris /= $ko_ant; $kostpris = afrund($kostpris, 3); if ($kostpris != $r['kostpris']) { db_modify("update ordrelinjer set kostpris='{$kostpris}' where id = '{$r['id']}'", __FILE__ . " linje " . __LINE__); } } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}',email='{$email}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.6'; if ($lap_nr < "6") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS pos_betalinger (id serial NOT NULL,ordre_id integer,betalingstype text,amount numeric(15,3),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='pos_betalinger'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE pos_betalinger (id serial NOT NULL,ordre_id integer,betalingstype text,amount numeric(15,3),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } } $q = db_select("select id,felt_1,felt_2,felt_3,felt_4 from ordrer where art='PO' and status>='3'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if (is_numeric($r['felt_2']) && $r['felt_2']) { db_modify("insert into pos_betalinger(ordre_id,betalingstype,amount) values ('{$r['id']}','{$r['felt_1']}','{$r['felt_2']}')", __FILE__ . " linje " . __LINE__); } if (is_numeric($r['felt_4']) && $r['felt_4']) { db_modify("insert into pos_betalinger(ordre_id,betalingstype,amount) values ('{$r['id']}','{$r['felt_3']}','{$r['felt_4']}')", __FILE__ . " linje " . __LINE__); } } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.7'; if ($lap_nr < "7") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("CREATE INDEX batch_kob_kobsdate_idx ON batch_kob (kobsdate)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX batch_kob_antal_idx ON batch_kob (antal)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX batch_kob_vare_id_idx ON batch_kob (vare_id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX batch_salg_salgsdate_idx ON batch_salg (salgsdate)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX batch_salg_antal_idx ON batch_salg (antal)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX batch_salg_vare_id_idx ON batch_salg (vare_id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX transaktioner_transdate_idx ON transaktioner (transdate)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX transaktioner_kontonr_idx ON transaktioner (kontonr)", __FILE__ . " linje " . __LINE__); transaktion('begin'); if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS mappe (id serial NOT NULL,beskrivelse text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS mappebilag (id serial NOT NULL,navn text,beskrivelse text,datotid text,hvem text,assign_to text,assign_id int4,filtype text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='mappe'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE mappe (id serial NOT NULL,beskrivelse text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='mappebilag'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE mappebilag (id serial NOT NULL,navn text,beskrivelse text,datotid text,hvem text,assign_to text,assign_id int4,filtype text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.8'; if ($lap_nr < "8") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); db_modify("ALTER TABLE batch_salg ADD lager integer", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE lagerstatus ADD lok1 text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE lagerstatus ADD lok2 text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE lagerstatus ADD lok3 text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE lagerstatus ADD lok4 text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE lagerstatus ADD lok5 text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.4.9'; if ($lap_nr < "9") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); db_modify("ALTER TABLE ordrelinjer ADD saet integer", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.0'; include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version='{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { transaktion('begin'); if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS ansatmappe (id serial NOT NULL,beskrivelse text,ans_id int4,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS ansatmappebilag (id serial NOT NULL,navn text,beskrivelse text,datotid text,hvem text,assign_to text,assign_id int4,filtype text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS kostpriser (id serial NOT NULL,vare_id integer,transdate date,kostpris numeric(15,3),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='ansatmappe'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE ansatmappe (id serial NOT NULL,beskrivelse text,ans_id int4,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='ansatmappebilag'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE ansatmappebilag (id serial NOT NULL,navn text,beskrivelse text,datotid text,hvem text,assign_to text,assign_id int4,filtype text,sort numeric(15,0),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='kostpriser'", __FILE__ . " linje " . __LINE__))) { db_modify("CREATE TABLE kostpriser (id serial NOT NULL,vare_id integer,transdate date,kostpris numeric(15,3),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } } db_modify("update batch_kob set kobsdate = fakturadate where kobsdate is NULL and fakturadate > '2014-01-01'", __FILE__ . " linje " . __LINE__); $q = db_select("select linje_id from batch_salg,ordrelinjer where ordrelinjer.antal < 0 and batch_salg.antal > 0 and batch_salg.linje_id = ordrelinjer.id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { db_modify("update batch_salg set antal=antal*-1 where linje_id='{$r['linje_id']}'", __FILE__ . " linje " . __LINE__); } $lgrp = array(); $x = 0; $q = db_select("select kodenr from grupper where art='VG' and box8='on'", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { $lgrp[$x] = $r['kodenr'] * 1; $x++; } $x = 0; $kostpris = array(); db_modify("delete from kostpriser", __FILE__ . " linje " . __LINE__); $q = db_select("select id,kostpris,gruppe from varer where lukket != 'on' order by id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if (in_array($r['gruppe'], $lgrp)) { $kostpris = $r['kostpris'] * 1; db_modify("insert into kostpriser(vare_id,kostpris,transdate)values('{$r['id']}','{$kostpris}','2015-01-01')", __FILE__ . " linje " . __LINE__); } } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version='{$nextver}' where db='{$db}'", __FILE__ . " linje " . __LINE__); }
// End switch $content .= "<br />"; $content .= "<input type=submit value='" . lang("Show list", "listing") . "'>"; $content .= "</form>"; } elseif ($action == "viewlist" && isset($list)) { $SQL = $listingtype[$list]['SQL']; if ($listingtype[$list]['displaymode'] == 'CSV') { $hide_smarty = 1; $format = "CSV"; } $content .= "<table>"; $qListing = db_query($SQL); $column_count = db_num_fields($qListing); $content .= "<tr>"; for ($column_num = 0; $column_num < $column_count; $column_num++) { $field_name = db_field_name($qListing, $column_num); $content .= "<th>" . lang($field_name, "listing") . "</th>"; } $content .= "</tr>"; while ($rListing = db_fetch_assoc($qListing)) { $content .= "<tr>"; foreach ($rListing as $name => $value) { $content .= "<td>" . $value . "</td>"; } // End for $content .= "</tr>"; # print_r($rListing); } // End while $content .= "</table>"; if ($hide_smarty == 1) {
$mailtext .= "I dag den {$dd} kl. {$tp} er der blevet rekvireret en midlertidig adgangskode til"; if ($brugernavn) { $mailtext .= " brugeren {$brugernavn} i"; } $mailtext .= " regnskabet {$regnskab} <br><br>"; $tidspunkt += 3600; $dd = date("d-m-Y", $tidspunkt); $tp = date("H:i", $tidspunkt); $mailtext .= "Indtil den {$dd} kl. {$tp} kan anvendes adgangskoden: {$tmp_kode}<br><br>"; $mailtext .= "Efter login kan adgangskoden ændres under \"Indstillinger -> Brugere\"<br><br>"; $tmp_kode = $tidspunkt . "|" . $tmp_kode; $i = 0; $feltnavne = array(); $q = db_select("select * from brugere", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('tmp_kode', $feltnavne)) { db_modify("ALTER TABLE brugere ADD tmp_kode text", __FILE__ . " linje " . __LINE__); } db_modify("update brugere set tmp_kode='{$tmp_kode}' where id='{$bruger_id}'"); } elseif (!$ansat_id && !$regnskaber && $db) { $subjekt = "Brugerliste til regnskabet {$regnskab}"; $mailtext .= "I dag den {$dd} kl. {$tp} er der blevet rekvireret en brugerliste til regnskabet {$regnskab} <br><br>Brugerne er: {$brugere}.\t<br><br>"; } elseif ($regnskaber) { $subjekt = "Saldi regnskab"; $mailtext .= "I dag den {$dd} kl. {$tp} er der blevet rekvireret en liste over regnskaber tilknyttet {$firmamail}<br><br>{$firmamail} et tilknyttet : {$regnskaber}.\t<br><br>"; } $mailtext .= "God fornøjelse fra dit Saldi team<br>"; # fclose ($fp);
function InitPOReq($req,$Base="",$DirEcho=true,$TypEdit="",$limit=1,$co_user="",$othparams = array("hashwnmtb"=>false)) { global $debug, $DBName,$sepNmTableNmChp; if(!defined("sepNmTableNmChp")) { define("sepNmTableNmChp","#"); // sécurité } if ($Base=="") $Base=$DBName; if($limit!="no") $req = addwherefORlimit($req,$limit); // ajoute proprement la clause limit, meme avec Oracle (belle merde) $resreq = db_query($req); if ($limit==1) { $tbValChp = db_fetch_array($resreq); // tableau des valeurs de l'enregistrement // if (db_num_rows($resreq)== 0 && !($_SESSION['db_type'] == "oracle")) return (false); // le oci_num_rows ne fonctionne pas avec Oracle !! } $CIL['db_num_rows'] = db_num_rows($resreq); $CIL['db_resreq'] = $resreq; // print_r($tbValChp); for ($i=0;$i<db_num_fields($resreq);$i++) { $NmChamp=db_field_name($resreq,$i); //echo "Chp traité : $NmChamp "; // la fonction db_field_table est tres aproximative avec Oracle et Pgsql // on peut préciser le nom de la table en faisant select toto as latable#toto dans la req cust if (strstr($NmChamp,sepNmTableNmChp)) { $tb = explode(sepNmTableNmChp,$NmChamp); $NmChp4hash = $NmChamp; $NTBL = $tb[0]; $NmChamp = $tb[1]; } else { $NTBL = db_field_table($resreq,$i); $NmChp4hash = $othparams['hashwnmtb'] ? $NTBL.sepNmTableNmChp.$NmChamp : $NmChamp; } $CIL[$NmChp4hash]=new PYAobj(); // nouvel objet $CIL[$NmChp4hash]->NmBase=$Base; $CIL[$NmChp4hash]->NmTable=$NTBL; $CIL[$NmChp4hash]->NmChamp=$NmChamp; $CIL[$NmChp4hash]->TypEdit=$TypEdit; $CIL[$NmChp4hash]->DirEcho=$DirEcho; // requetes custom : initialise pas le PO si mot clé ou nom de champ est un entier //echo $CIL[$NmChp4hash]->NmChamp.":".preg_match("/^[0-9]+$/",$CIL[$NmChp4hash]->NmChamp)."<br/>"; /// TODO TODO faut améliorer ce test if (!(preg_match("/sum\(|count\(|min\(|max\(|avg\(/i",$NmChamp) || preg_match("/^[0-9]+$/",$NmChamp))) { $err = $CIL[$NmChp4hash]->InitPO(); if ($err) $CIL[$NmChp4hash]->Libelle = '<i>'.$NmChp4hash.'</i>'; // si champ pas trouvé (table non définie) on garde son libellé } else { $CIL[$NmChp4hash]->Libelle = $NmChp4hash; } if ($TypEdit!="N" && $TypEdit!="" && $limit==1) { $CIL[$NmChp4hash]->ValChp=$tbValChp[$NmChamp]; //echo $NmChamp."->".$tbValChp[$NmChamp]; } if ($co_user!="" && $TypEdit!="C") $CIL[$NmChp4hash]->InitAvMaj($co_user); $strdbgIPOR.=$NmChp4hash.", "; } // fin boucle sur les champs du r�ultat if ($debug) echo("Champs traites par la fct InitPOReq :".$strdbgIPOR."<br/>\n"); return($CIL); }
$leftbutton = "<a title=\"Klik her for at komme tilbage til ordrelisten\" href=\"../debitor/ordreliste.php\" accesskey=\"L\">LUK</a>"; $vejledning = NULL; include "../includes/topmenu.php"; print "<div id=\"topmenu\" style=\"position:absolute;top:6px;right:0px\">"; } elseif ($menu == 'S') { include "../includes/sidemenu.php"; } else { print "<tr><td height = \"25\" align=\"center\" valign=\"top\">\n\t\t<table width=\"100%\" align=\"center\" border=\"0\" cellspacing=\"4\" cellpadding=\"0\"><tbody>\n\t\t\t<td width=\"10%\" align=center><div class=\"top_bund\"><a href=ordreliste.php?valg={$valg}&sort={$sort} accesskey=L>Luk</a></div></td>\n\t\t\t<td width=\"80%\" align=center><div class=\"top_bund\">{$title}</a></div></td>\n\t\t\t<td width=\"10%\" align=center><div class=\"top_bund\"><br></div></td>\n\t\t\t </tr>\n\t\t\t</tbody></table>\n\t</td></tr>"; } print "<tr><td valign=\"top\" align=\"center\">\n<table cellpadding=\"1\" cellspacing=\"1\" border=\"0\" valign = \"top\">\n<tbody>"; print "<form name=ordrevisning action=ordrevisning.php?sort={$sort}&valg={$valg} method=post>"; # $felter=array("konto_id","firmanavn","addr1","addr2","postnr","bynavn","land","kontakt","kundeordnr","lev_navn","lev_addr1","lev_addr2","lev_postnr","lev_bynavn","lev_kontakt","ean","institution","betalingsbet","betalingsdage","kontonr","cvrnr","art","ordredate","levdate","fakturadate","notes","sum","momssats","status","ref","fakturanr","modtagelse","kred_ord_id","lev_adr","kostpris","moms","hvem","tidspkt","nextfakt","betalt","projekt","valuta","valutakurs","sprog","email","mail_fakt","pbs","mail","mail_cc","mail_bcc","mail_subj","mail_text","felt_1","felt_2","felt_3","felt_4","felt_5","vis_lev_addr","udskriv_til","restordre"); $i = 0; $q = db_select("select * from ordrer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $felter[$i] = db_field_name($q, $i); $i++; } $felter[$i] = 'sum_m_moms'; sort($felter); #$feltantal=count($felter); print "<tr><td colspan=\"6\">Vælg hvilke felter der skal være synlige på oversigten</td></tr>"; print "<tr><td colspan=\"6\">Ordrenr kan ikke fravælges</td></tr>"; print "<tr><td colspan=\"6\"><hr></td></tr>"; $r = db_fetch_array(db_select("select box3,box4,box5,box6,box7 from grupper where art = 'OLV' and kode ='{$valg}' and kodenr = '{$bruger_id}'", __FILE__ . " linje " . __LINE__)); $vis_felt = explode(",", $r['box3']); $feltbredde = explode(",", $r['box4']); $justering = explode(",", $r['box5']); $feltnavn = explode(",", $r['box6']); $vis_linjeantal = $r['box7']; $vis_feltantal = count($feltbredde) - 1;
function copy_row($table, $id) { if (!$table || !$id) { return '0'; } $r = 0; $x = 0; $fieldstring = NULL; $q_string = "select * from {$table} where pris != '0' and m_rabat != '0' and rabat = '0' and id='{$id}'"; $q = db_select("{$q_string}", __FILE__ . " linje " . __LINE__); while ($r < db_num_fields($q)) { if (db_field_name($q, $r) != 'id') { $x++; $fieldName[$x] = db_field_name($q, $r); $fieldType[$x] = db_field_type($q, $r); $fieldstring ? $fieldstring .= "," . $fieldName[$x] : ($fieldstring = $fieldName[$x]); } $r++; } $feltantal = $x; $ordre_id = NULL; $posnr = NULL; $x = 0; $q = db_select("{$q_string}"); if ($r = db_fetch_array($q)) { $fieldvalues = NULL; $selectstring = NULL; for ($y = 1; $y <= $feltantal; $y++) { $linjerabat = afrund($r['pris'] / $r['m_rabat'], 2); $feltnavn = $fieldName[$y]; $felt[$y] = $r[$feltnavn]; if ($fieldType[$y] == 'varchar' || $fieldType[$y] == 'text') { $felt[$y] = addslashes($felt[$y]); } if (substr($fieldType[$y], 0, 3) == 'int' || $fieldType[$y] == 'numeric') { $felt[$y] *= 1; } if ($fieldName[$y] == 'posnr') { $felt[$y]++; $posnr = $felt[$y]; } if ($fieldName[$y] == 'ordre_id') { $ordre_id = $felt[$y]; } $fieldvalues ? $fieldvalues .= ",'" . $felt[$y] . "'" : ($fieldvalues = "'" . $felt[$y] . "'"); $selectstring ? $selectstring .= " and " . $fieldName[$y] . "='" . $felt[$y] . "'" : ($selectstring = $fieldName[$y] . "='" . $felt[$y] . "'"); } } if ($posnr && $ordre_id) { db_modify("update {$table} set posnr=posnr+1 where ordre_id = '{$ordre_id}' and posnr >= '{$posnr}'", __FILE__ . " linje " . __LINE__); } db_modify("insert into ordrelinjer ({$fieldstring}) values ({$fieldvalues})", __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select id from {$table} where {$selectstring}", __FILE__ . " linje " . __LINE__)); $ny_id = $r['id']; return $ny_id; }
function lineHasFieldNames($arr, $table) { if (!is_array($arr)) { #echo '<!-- lineHasFieldNames: line '.__LINE__.' -->'; return false; } // get field names of table $res = sql('select * from `' . $table . '` limit 1', $eo); for ($i = 0; $i < db_num_fields($res); $i++) { $arrTableFieldName[] = db_field_name($res, $i); } $arrCommon = array_intersect($arrTableFieldName, noSpaces($arr)); //echo '<!-- lineHasFieldNames: arrTableFieldName: '.count($arrTableFieldName).' -->'; //echo '<!-- lineHasFieldNames: arr: '.count($arr).' -->'; //echo '<!-- lineHasFieldNames: arrCommon: '.count($arrCommon).' -->'; return count($arrCommon) < count($arr) ? false : true; }
<?php @session_start(); $s_id = session_id(); $title = "Diverse Indstilinger"; $modulnr = 1; $css = "../css/standard.css"; $diffkto = NULL; include "../includes/connect.php"; include "../includes/online.php"; include "../includes/std_func.php"; # include("top.php"); $linje = NULL; $filnavn = "../temp/{$db}/{$bruger_id}.csv"; $fp = fopen($filnavn, "w"); $query = "select m_rabat from ordrelinjer"; $q = db_select("{$query}"); $fieldName = db_field_name($q, 0); $fieldType = db_field_type($q, 0); echo "{$fieldName} {$fieldType}<br>";
function opdat_3_2($under_nr, $lap_nr) { global $version; global $db; global $db_id; global $regnskab; global $regnaar; global $db_type; $s_id = session_id(); $nextver = '3.2.1'; if ($lap_nr < "1") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; transaktion('begin'); $q = db_select("select m_rabat from ordrelinjer", __FILE__ . " linje " . __LINE__); $fieldType = db_field_type($q, 0); if ($fieldType != 'numeric') { if ($db_type == "mysql") { db_modify("ALTER TABLE ordrelinjer CHANGE m_rabat m_rabat numeric(15,3)", __FILE__ . " linje " . __LINE__); } else { db_modify("ALTER TABLE ordrelinjer ALTER column m_rabat TYPE numeric(15,3)", __FILE__ . " linje " . __LINE__); } } if ($db_type == "mysql") { db_modify("ALTER TABLE ordrelinjer CHANGE rabatart rabatart varchar(10)", __FILE__ . " linje " . __LINE__); } else { db_modify("ALTER TABLE ordrelinjer ALTER column rabatart TYPE varchar(10)", __FILE__ . " linje " . __LINE__); } echo "opdaterer til ver {$nextver}<br />"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.2'; if ($lap_nr < "2") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; transaktion('begin'); if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS ordretekster (id serial NOT NULL,tekst text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS navigator (bruger_id integer,session_id text,side text,returside text,konto_id integer,ordre_id integer,vare_id integer)", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='ordretekster'"))) { db_modify("CREATE TABLE ordretekster (id serial NOT NULL,tekst text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='navigator'"))) { db_modify("CREATE TABLE navigator (bruger_id integer,session_id text,side text,returside text,konto_id integer,ordre_id integer,vare_id integer)", __FILE__ . " linje " . __LINE__); } } $i = 0; $feltnavne = array(); $q = db_select("select * from jobkort", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('ordre_id', $feltnavne)) { db_modify("ALTER TABLE jobkort ADD ordre_id integer", __FILE__ . " linje " . __LINE__); } $i = 0; $feltnavne = array(); $q = db_select("select * from adresser", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('status', $feltnavne)) { db_modify("ALTER TABLE adresser ADD status text", __FILE__ . " linje " . __LINE__); } $id1 = 0; $cat_id = NULL; $cat_beskrivelse = NULL; $q = db_select("select id,box1 from grupper where art='DGCAT' order by id", __FILE__ . " linje " . __LINE__); while ($r = db_fetch_array($q)) { if (!$id0) { $id0 = $r['id']; } $cat_id ? $cat_id .= chr(9) . $r['id'] : ($cat_id = $r['id']); $cat_beskrivelse ? $cat_beskrivelse .= chr(9) . db_escape_string($r['box1']) : ($cat_beskrivelse = db_escape_string($r['box1'])); } if ($id0) { db_modify("update grupper set beskrivelse='Div DebitorInfo',art='DebInfo',box1='{$cat_id}',box2='{$cat_beskrivelse}' where id = '{$id0}'", __FILE__ . " linje " . __LINE__); } if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS ordretekster (id serial NOT NULL,tekst text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS navigator (bruger_id integer,session_id text,side text,returside text,konto_id integer,ordre_id integer,vare_id integer)", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='ordretekster'"))) { db_modify("CREATE TABLE ordretekster (id serial NOT NULL,tekst text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='navigator'"))) { db_modify("CREATE TABLE navigator (bruger_id integer,session_id text,side text,returside text,konto_id integer,ordre_id integer,vare_id integer)", __FILE__ . " linje " . __LINE__); } } echo "opdaterer til ver {$nextver}<br />"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.3'; if ($lap_nr < "3") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; transaktion('begin'); if ($db_type == "mysql") { db_modify("CREATE TABLE IF NOT EXISTS shop_adresser (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS shop_varer (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS shop_ordrer (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS varianter (id serial NOT NULL,beskrivelse text,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS variant_typer (id serial NOT NULL,variant_id integer,shop_id integer,beskrivelse text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE IF NOT EXISTS variant_varer (id serial NOT NULL,vare_id integer,variant_type text,variant_beholdning numeric(15,3),variant_stregkode text,lager integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } else { if (!db_fetch_array(db_select("select * from pg_tables where tablename='shop_adresser'"))) { db_modify("CREATE TABLE shop_adresser (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='shop_varer'"))) { db_modify("CREATE TABLE shop_varer (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='shop_ordrer'"))) { db_modify("CREATE TABLE shop_ordrer (id serial NOT NULL,saldi_id integer,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='varianter'"))) { db_modify("CREATE TABLE varianter (id serial NOT NULL,beskrivelse text,shop_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='variant_typer'"))) { db_modify("CREATE TABLE variant_typer (id serial NOT NULL,variant_id integer,shop_id integer,beskrivelse text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } if (!db_fetch_array(db_select("select * from pg_tables where tablename='variant_varer'"))) { db_modify("CREATE TABLE variant_varer (id serial NOT NULL,vare_id integer,variant_type text,variant_beholdning numeric(15,3),variant_stregkode text,lager integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); } } db_modify("delete from grupper where art = 'DGCAT'", __FILE__ . " linje " . __LINE__); $i = 0; $feltnavne = array(); $q = db_select("select * from varer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('kategori', $feltnavne)) { db_modify("ALTER TABLE varer ADD kategori text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE varer set kategori = ''", __FILE__ . " linje " . __LINE__); } if (!in_array('varianter', $feltnavne)) { db_modify("ALTER TABLE varer ADD varianter text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE varer set varianter = ''", __FILE__ . " linje " . __LINE__); } if (!in_array('publiceret', $feltnavne)) { db_modify("ALTER TABLE varer ADD publiceret varchar(2)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE varer set publiceret = '0'", __FILE__ . " linje " . __LINE__); } $i = 0; $feltnavne = array(); $q = db_select("select * from ordrelinjer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('variant_id', $feltnavne)) { db_modify("ALTER TABLE ordrelinjer ADD variant_id text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE ordrelinjer set variant_id = ''", __FILE__ . " linje " . __LINE__); } echo "opdaterer til ver {$nextver}<br />"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.4'; if ($lap_nr < "4") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; transaktion('begin'); $i = 0; $feltnavne = array(); $q = db_select("select * from ordrelinjer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('variant_id', $feltnavne)) { db_modify("ALTER TABLE ordrelinjer ADD variant_id text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE ordrelinjer set variant_id = ''", __FILE__ . " linje " . __LINE__); } if (in_array('varianter', $feltnavne)) { db_modify("ALTER TABLE ordrelinjer drop column varianter", __FILE__ . " linje " . __LINE__); } # echo "opdaterer til ver $nextver<br />"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); transaktion('commit'); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.5'; if ($lap_nr < "5") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.6'; if ($lap_nr < "6") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.7'; if ($lap_nr < "7") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; print "<body onload=\"javascript:window.open('../utils/momskontrol.php?email=1', '', '');\">"; db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.8'; if ($lap_nr < "8") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; $feltnavne = array(); $q = db_select("select * from transaktioner", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('moms', $feltnavne)) { db_modify("ALTER TABLE transaktioner ADD moms numeric(15,3)", __FILE__ . " linje " . __LINE__); } db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.2.9'; if ($lap_nr < "9") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("ALTER TABLE online ADD column sag_rettigheder text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; db_modify("CREATE TABLE sager (id serial NOT NULL,konto_id integer,firmanavn text,addr1 text,addr2 text,postnr text,bynavn text,land text,kontakt text,email text,beskrivelse text,omfang text,ref text,udf_firmanavn text,udf_addr1 text,udf_addr2 text,udf_postnr text,udf_bynavn text,udf_kontakt text,status text,tidspkt text,hvem text,oprettet_af text,kunde_ref text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE bilag (id serial NOT NULL,navn text,beskrivelse text,datotid text,hvem text,assign_to text,assign_id int,fase numeric(15,3),kategori text,filtype text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE noter (id serial NOT NULL,notat text,beskrivelse text,datotid text,hvem text,besked_til text,assign_to text,assign_id integer,status integer,fase numeric(15,3), PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE tjekliste (id serial NOT NULL,tjekpunkt text,fase numeric(15,3),assign_to text,assign_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE tjekpunkter (id serial NOT NULL,tjekliste_id integer,assign_id integer,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE sagstekster (id serial NOT NULL,tekstnr numeric(15,0),beskrivelse text,tekst text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE loen (id serial NOT NULL,nummer numeric(15,0),kategori integer,loendate date,sag_id integer, sag_nr numeric(15,0),tekst text,ansatte text,fordeling text,timer text,t50pct text,t100pct text,hvem text,oprettet text,afsluttet text,godkendt text,sum numeric(15,3),oprettet_af text,afsluttet_af text,godkendt_af text,master_id integer,loen text,afvist text,afvist_af text,udbetalt text,art text,skur text,datoer text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE loen_enheder (id serial NOT NULL,loen_id integer,vare_id integer,op numeric(15,3),ned numeric(15,3),tekst text,pris_op numeric(15,3),pris_ned numeric(15,3),procent numeric(15,3),PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("alter table ansatte add column nummer numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("alter table ansatte add column loen numeric", __FILE__ . " linje " . __LINE__); db_modify("alter table ansatte add column extraloen numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ansatte ADD COLUMN bank text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ansatte ADD COLUMN startdate date", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ansatte ADD COLUMN slutdate date", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ansatte ADD COLUMN trainee text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ordrer ADD COLUMN betalings_id text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE openpost ADD COLUMN betalings_id text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.3.0'; include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id=1", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { db_modify("UPDATE regnskab set version = '{$nextver}' where id = 1", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; db_modify("CREATE TABLE opgaver (id serial NOT NULL,assign_id integer,assign_to text,nr numeric(15,0),beskrivelse text,omfang text,ref text,status text,tidspkt text,hvem text,oprettet_af text,kunde_ref text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE simulering (id serial NOT NULL,kontonr int4,bilag numeric(15,0),transdate date,beskrivelse text,debet numeric(15,3),kredit numeric(15,3),faktura text,kladde_id int4,projekt text,ansat numeric(15,0),logdate date,logtime time,afd int4,ordre_id int4,valuta text,valutakurs numeric(15,3),moms numeric(15,3),adresser_id int4,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("CREATE TABLE tjekskema (id serial NOT NULL,tjekliste_id integer,datotid text,opg_art text,sjak text,sag_id integer,hvem text,PRIMARY KEY (id))", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column afregnet text", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column afregnet_af text", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column korsel text", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column korsel text", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column opg_id integer", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column opg_nr integer", __FILE__ . " linje " . __LINE__); db_modify("alter table loen add column afvist_pga text", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column op_25 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column ned_25 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column op_40 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column ned_40 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column op_60 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column ned_60 numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column op_30m numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table loen_enheder add column ned_30m numeric(15,3)", __FILE__ . " linje " . __LINE__); db_modify("alter table bilag add column bilag_fase text", __FILE__ . " linje " . __LINE__); db_modify("alter table noter add column notat_fase text", __FILE__ . " linje " . __LINE__); db_modify("alter table noter add column kategori text", __FILE__ . " linje " . __LINE__); db_modify("alter table noter add column nr numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column sag_id integer", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column tilbudnr numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column datotid text", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column nr numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column returside text", __FILE__ . " linje " . __LINE__); db_modify("alter table ordrer add column sagsnr numeric(15,0)", __FILE__ . " linje " . __LINE__); db_modify("alter table transaktioner add column adresser_id integer", __FILE__ . " linje " . __LINE__); db_modify("alter table tjekpunkter add column status integer", __FILE__ . " linje " . __LINE__); db_modify("alter table tjekpunkter add column status_tekst text", __FILE__ . " linje " . __LINE__); db_modify("alter table tjekpunkter add column tjekskema_id integer", __FILE__ . " linje " . __LINE__); db_modify("update transaktioner set moms=moms*-1 where kredit > 0 and moms > 0", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1 = '{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); }
function opdat_3_5($under_nr, $lap_nr) { global $version; global $db; global $db_id; global $regnskab; global $regnaar; global $db_type; $s_id = session_id(); $nextver = '3.5.1'; if ($lap_nr < "1") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("CREATE INDEX pos_betalinger_ordre_id_idx ON pos_betalinger (ordre_id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX pos_betalinger_betalingstype_idx ON pos_betalinger (betalingstype)", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE regulering add column lager integer", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ordrelinjer add column fast_db numeric(15,2)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.2'; if ($lap_nr < "2") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("ALTER TABLE ordrer add column afd integer", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ordrelinjer add column afd integer", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE ordrelinjer add column lager integer", __FILE__ . " linje " . __LINE__); db_modify("DELETE FROM tekster where tekst_id = '677'", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.3'; if ($lap_nr < "3") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.4'; if ($lap_nr < "4") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("CREATE INDEX openpost_id_idx ON openpost (id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX openpost_konto_id_idx ON openpost (konto_id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX openpost_udlign_id_idx ON openpost (udlign_id)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX ordrer_art_idx ON ordrer (art)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX ordrer_ordrenr_idx ON ordrer (ordrenr)", __FILE__ . " linje " . __LINE__); db_modify("CREATE INDEX ordrer_betalt_idx ON ordrer (betalt)", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.5'; if ($lap_nr < "5") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("delete from tekster where id = '731'", __FILE__ . " linje " . __LINE__); db_modify("delete from tekster where id = '732'", __FILE__ . " linje " . __LINE__); $r = db_fetch_array(db_select("select box6 from grupper where art = 'DIV' and kodenr = '3'", __FILE__ . " linje " . __LINE__)); $fifo = $r['box6']; if ($fifo) { if ($r = db_fetch_array(db_select("select id from grupper where art = 'DIV' and kodenr='5'", __FILE__ . " linje " . __LINE__))) { $id = $r['id']; db_modify("update grupper set box6='1' where id = '{$id}'", __FILE__ . " linje " . __LINE__); } else { db_modify("insert into grupper (beskrivelse,kodenr,art,box1,box2,box3,box4,box5,box6,box7,box8,box9,box10,box11,box12,box13) values ('Div_valg','5','DIV','','','','','','1','','','','','','','')", __FILE__ . " linje " . __LINE__); } } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.6'; if ($lap_nr < "6") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("ALTER TABLE ordrelinjer add column tilfravalg text", __FILE__ . " linje " . __LINE__); db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.7'; if ($lap_nr < "7") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("ALTER TABLE sager add column planfraop text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE sager add column plantilop text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE sager add column planfraned text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE sager add column plantilned text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE opgaver add column opg_planfra text", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE opgaver add column opg_plantil text", __FILE__ . " linje " . __LINE__); $i = 0; $feltnavne = array(); $q = db_select("select * from ordrelinjer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('tilfravalg', $feltnavne)) { db_modify("ALTER TABLE ordrelinjer ADD tilfravalg text", __FILE__ . " linje " . __LINE__); } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } $nextver = '3.5.8'; if ($lap_nr < "8") { include "../includes/connect.php"; $r = db_fetch_array(db_select("select * from regnskab where id='1'", __FILE__ . " linje " . __LINE__)); $tmp = $r['version']; if ($tmp < $nextver) { echo "opdaterer hovedregnskab til ver {$nextver}<br />"; db_modify("UPDATE regnskab set version = '{$nextver}' where id = '1'", __FILE__ . " linje " . __LINE__); } include "../includes/online.php"; if ($db != $sqdb) { db_modify("ALTER TABLE varer add column special_from_time time", __FILE__ . " linje " . __LINE__); db_modify("ALTER TABLE varer add column special_to_time time", __FILE__ . " linje " . __LINE__); $i = 0; $feltnavne = array(); $q = db_select("select * from ordrelinjer", __FILE__ . " linje " . __LINE__); while ($i < db_num_fields($q)) { $feltnavne[$i] = db_field_name($q, $i); $i++; } if (!in_array('tilfravalg', $feltnavne)) { db_modify("ALTER TABLE ordrelinjer ADD tilfravalg text", __FILE__ . " linje " . __LINE__); } db_modify("UPDATE grupper set box1='{$nextver}' where art = 'VE'", __FILE__ . " linje " . __LINE__); } include "../includes/connect.php"; db_modify("UPDATE regnskab set version = '{$nextver}' where db = '{$db}'", __FILE__ . " linje " . __LINE__); } }
function setBackup() { global $dbname, $dbh; global $PARAM, $SUBS, $MSG, $MONTHS; if (!is_dir(getAdmSetting('BACKUP_DIR'))) { MkDir(getAdmSetting('BACKUP_DIR'), 0777); } if ($PARAM['upload'] == 1) { global $bckFile, $bckFile_name; if ($bckFile_name == '') { $SUBS['ERROR'] = $MSG[20108]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } else { if (!($UPLOAD = @file($bckFile))) { setLogAndStatus("Reading", $bckFile, 0, "setBackup()", 'READ_UPLOAD'); } $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; $upload = '## ' . $MSG[20109] . date(' d F Y H:i:s') . "\n"; $upload .= "## {$MSG['20110']} {$bckFile_name}\n"; $upload .= join('', $UPLOAD); if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", $filename, 0, "setBackup()", 'OPEN_FILE'); } fwrite($fp, $upload); fclose($fp); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20050"; printPage('_admin_done.htmlt'); return; } } //export database backup if ($PARAM['export'] == 1) { $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", 0, $filename, "setBackup()", 'OPEN_FILE'); } //write comments if any if ($PARAM['bckComments'] != '') { $comments = '##' . ereg_replace("\n", "\n##", $PARAM['bckComments']) . "\n"; fwrite($fp, $comments); } if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 0, $dbname, "setBackup()", 'LIST_TABLES'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $fields = db_list_fields($dbname, $table, $dbh); $columns = db_num_fields($fields); $tablelist = ''; for ($j = 0; $j < $columns; $j++) { if ($columns - $j == 1) { $tablelist .= db_field_name($fields, $j); } else { $tablelist .= db_field_name($fields, $j) . ','; } } $schema = "REPLACE INTO {$table} ({$tablelist}) VALUES ("; $query = "SELECT * FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'SELECT_TABLES'); while ($row = db_fetch_row($result)) { $schema_insert = ''; for ($j = 0; $j < $columns; $j++) { if (!isset($row[$j])) { $schema_insert .= ' NULL,'; } else { $schema_insert .= ' ' . dbQuote($row[$j]) . ','; } } $schema_insert = $schema . ereg_replace(',$', '', $schema_insert); $schema_insert .= ");\r\n"; fwrite($fp, $schema_insert); } $i++; } fclose($fp); // the ZIP thing -------------------- $fp = fopen($filename, "rb"); $data = fread($fp, filesize($filename)); fclose($fp); $name = array(baseName($filename)); $data = array($data); $content = makezip($name, $data); $fp = fopen('./zip/' . basename($filename) . '.ZIP', "wb"); fputs($fp, $content); fclose($fp); // the ZIP thing -------------------- $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20052"; printPage('_admin_done.htmlt'); return; } //prepare for import or delete $backups = opendir(getAdmSetting('BACKUP_DIR')); while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $BCKUPS[eregi_replace('[^a-z0-9]', '_', $file)] = getAdmSetting('BACKUP_DIR') . "/{$file}"; } } closedir($backups); reset($PARAM); while (list($k, $v) = each($PARAM)) { if (ereg('^bck_(.*)$', $k, $R)) { $BACKUPS[] = $R[1]; } } reset($PARAM); //delete backups if ($PARAM['delete'] == 1) { if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } for ($i = 0; $i < count($BACKUPS); $i++) { if (!@unlink($BCKUPS[$BACKUPS[$i]])) { setLogAndStatus("Deleting", $BCKUPS[$BACKUPS[$i]], "setBackup()", 'DEL_BACKUP'); } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20054"; printPage('_admin_done.htmlt'); return; } //import database backup if ($PARAM['import'] == 1) { if (count($BACKUPS) > 1) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20053"; printPage('_admin_done.htmlt'); return; } if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } //get backup file $file = fread(fopen($BCKUPS[$BACKUPS[0]], 'r'), filesize($BCKUPS[$BACKUPS[0]])); ////---- [Mrasnika's] Edition 21.03.2002 split_sql_file($BACKUP, $file); //reset tables if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 1, $dbname, "databaseBackup()", 'LIST_TABLES_2'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $query = "DELETE FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'RESET_TABLES'); $i++; } //fill tables while (list($k, $query) = each($BACKUP)) { if (!ereg('^#', $query)) { if (!($result = db_query($query, $dbh))) { setLogAndStatus($query, db_errno($dbh), db_error($dbh), "databaseBackup()", 'RESTORE_DB'); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20055"; printPage('_admin_done.htmlt'); return; } } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20056"; printPage('_admin_done.htmlt'); return; } $backups = opendir(getAdmSetting('BACKUP_DIR')); $last = 0; while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $date = stat(getAdmSetting('BACKUP_DIR') . "/{$file}"); if ($last < $date[9]) { $month = intval(date('m')); $SUBS['LAST'] = $MSG[20051] . date(' d ', $date[9]) . $MONTHS[$month] . date(' Y H.i.s', $date[9]); } $SUBS['SIZE'] = sprintf('%0.2f KB', $date[7] / 1024); $SUBS['NAME'] = eregi_replace('_', ':', $file); $SUBS['CHECK'] = eregi_replace('[^a-z0-9]', '_', $file); //checkbox name $SUBS['WHERE'] = getAdmSetting('BACKUP_DIR') . "/{$file}"; if (!($BACKUP = @file(getAdmSetting('BACKUP_DIR') . "/{$file}"))) { setLogAndStatus("Reading", 0, getAdmSetting('BACKUP_DIR') . "/{$file}", "setBackup()", 'READ_FILE'); } $comments = ''; //get comments from the beginning of the file for ($i = 0; $i < count($BACKUP); $i++) { if (eregi('^##(.*)$', $BACKUP[$i], $R)) { $comments .= $R[1]; } } if ($comments != '') { $SUBS['COMMENTS'] = ' ' . ereg_replace("\n", '<BR> ', htmlEncode($comments)); $SUBS['COMMENTS'] = ereg_replace('<BR> $', '', $SUBS['COMMENTS']); } else { $SUBS['COMMENTS'] = ''; } $SUBS['BACKUPS'] .= fileParse('_admin_backup_row.htmlt'); } } closedir($backups); if ($PARAM['err'] != '') { $SUBS['ERROR'] = $MSG[$PARAM['err']]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } printPage('_admin_backup.htmlt'); }
function sqlquery_io($sqlstreng) { global $bgcolor; global $bgcolor5; $titletxt = "Skriv en SQL forespørgsel uden 'select'. F.eks: * from varer eller: varenr,salgspris from varer where lukket != 'on'"; print "<form name=exportselect action=diverse.php?sektion=sqlquery_io method=post>"; print "<tr><td colspan='6'><hr></td></tr>"; print "<tr bgcolor='{$bgcolor5}'><td colspan='6'><b><u>Dataudtræk</u></b></td></tr>"; print "<tr><td colspan='6'><br></td></tr>"; print "<input type=hidden name=id value='{$id}'>"; print "<tr><td valign='top' title='{$titletxt}'>SELECT</td><td colspan='2'><textarea name='sqlstreng' rows='5' cols='80'>{$sqlstreng}</textarea></td>"; print "<td align = center><input style='width: 8em' type=submit accesskey='g' value='Send' name='submit'></td>"; print "</form>"; $x = 0; if ($sqlstreng = trim($sqlstreng)) { global $db; global $bruger_id; $linje = NULL; $filnavn = "../temp/{$db}/{$bruger_id}.csv"; $fp = fopen($filnavn, "w"); $sqlstreng = strtolower($sqlstreng); list($del1, $del2) = explode("where", $sqlstreng, 2); $fy_ord = array('brugere', 'grupper'); for ($x = 0; $x < count($fy_ord); $x++) { if (strpos($del1, $fy_ord[$x])) { print "<BODY onLoad=\"JavaScript:alert('Illegal værdi i søgestreng')\">"; exit; } } #cho "del 1 $del1<br>"; #cho "del2 $del2<br>"; for ($x = 0; $x < strlen($del2); $x++) { $t = substr($del2, $x, 1); if (!$tilde) { if ($t == "'") { $tilde = 1; $var = ''; } else { $streng .= $t; } } else { if ($t == "'") { $tilde = 0; $streng .= "'" . db_escape_string($var) . "'"; } } } #cho "$sqlstreng<br>"; $query = "select " . db_escape_string($del1); #cho "$query<br>"; $query = "select " . $sqlstreng; #cho "$query<br>"; $r = 0; $q = db_select("{$query}", __FILE__ . " linje " . __LINE__); while ($r < db_num_fields($q)) { $fieldName[$r] = db_field_name($q, $r); $fieldType[$r] = db_field_type($q, $r); $linje ? $linje .= '";"' . $fieldName[$r] . "(" . $fieldType[$r] . ")" : ($linje = '"' . $fieldName[$r] . "(" . $fieldType[$r] . ")"); $r++; } $linje ? $linje .= '"' : ($linje = NULL); if ($fp) { fwrite($fp, "{$linje}\n"); } $q = db_select("{$query}"); while ($r = db_fetch_array($q)) { $linje = NULL; $arraysize = count($r); for ($x = 0; $x < $arraysize; $x++) { if ($fieldType[$x] == 'numeric') { $r[$x] = dkdecimal($r[$x]); } else { $r[$x] = utf8_decode($r[$x]); } $linje ? $linje .= '";"' . $r[$x] : ($linje = '"' . $r[$x]); } $linje ? $linje .= '"' : ($linje = NULL); if ($fp) { fwrite($fp, "{$linje}\n"); } } fclose($fp); print "<tr><td></td><td align='left' colspan='3'> Højreklik her: <a href='{$filnavn}'>Datafil</a> og vælg 'gem destination som'</td></tr>"; } }
echo '<TABLE BORDER="1"><THEAD><TH>NOM CHAMP</TH><TH>TYPE</TH><TH>LIBELLE</TH><TH>TYP. AFF</TH><TH>VALEURS</TH><TH>COMMENTAIRE</TH></THEAD>'; // DU au fait que la fonction mysql_field_flags ne fonctionne correctement qu'avec un resultat "NORMAL" et pas avec une requete du type SHOW FIELDS if ($_SESSION[db_type]=="mysql") $table_def = mysql_query("SHOW FIELDS FROM $CSpIC$NM_TABLE$CSpIC"); //$resf=mysql_list_fields ($DBName, $CSpIC$NM_TABLE$CSpIC); // ins�e un champ commun de description de la table s'il n'existe pas $rpct=db_query("SELECT NM_CHAMP FROM $TBDname WHERE NM_TABLE='$NM_TABLE' AND NM_CHAMP='$NmChDT'"); if (db_num_rows($rpct)==0) db_query("INSERT INTO $TBDname (NM_TABLE, NM_CHAMP,LIBELLE, ORDAFF, ORDAFF_L) values ('$NM_TABLE','$NmChDT','$NM_TABLE', '$i', '$i')"); for ($j = 0; $j < $nfields; $j++) { echo "<TR><TD>"; if ($_SESSION[db_type]=="mysql") $row_table_def = mysql_fetch_array($table_def); $NM_CHAMP=($CREATION!="false" ? db_field_name ($resf, $j) : $tbLCHP[$j]); //$NM_CHAMP=$row_table_def['Field']; $tbNM_CHAMP[$j]=$NM_CHAMP; $TYP_CHAMP=""; $CREATMAJ=false; if ($CREATION=="MAJ") { $rqCE=db_query("SELECT * from $TBDname where NM_TABLE='$NM_TABLE' AND NM_CHAMP='$NM_CHAMP'"); // si champ pas existant il est a cr�r if (db_num_rows($rqCE)==0) $CREATMAJ=true; } // cree l'enregistrement en MAJ ou if ($CREATION=="vrai" || $CREATMAJ) { // init sp�iales en fonction des noms ou des types de champs // des types, etc echo "<B><U>Creation </U></B>"; $TT_AVMAJ="";
name="default_value" style="height: 22px; padding-right: 0;" id="default_value"> <option value>-- Select Value --</option> <?php if (in_array($Proj->metadata[$_POST['field_name']]['element_type'], array('radio', 'select'))) { foreach (parseEnum($Proj->metadata[$_POST['field_name']]['element_enum']) as $this_code => $this_label) { if ($_POST['default_value'] == $this_code) { echo "<option value='{$this_code}' selected>{$this_label}</option>"; } else { echo "<option value='{$this_code}'>{$this_label}</option>"; } } } else { $field_enum_result = db_query($Proj->metadata[$_POST['field_name']]['element_enum']); $field_name = db_field_name($field_enum_result, 0); if ($field_enum_result) { while ($field_enum_row = db_fetch_assoc($field_enum_result)) { $this_value = $field_enum_row[$field_name]; if ($_POST['default_value'] == $this_value) { echo "<option value='{$this_value}' selected>{$this_value}</option>"; } else { echo "<option value='{$this_value}'>{$this_value}</option>"; } } } } ?> </select> <?php echo $checkbox ?>