Revision: 665
http://tutos.svn.sourceforge.net/tutos/?rev=665&view=rev
Author: gokohnert
Date: 2012-06-27 12:32:08 +0000 (Wed, 27 Jun 2012)
Log Message:
-----------
fix overview
Modified Paths:
--------------
trunk/php/expense/expense.pinc
trunk/php/expense/expense_overview.php
trunk/php/expense/expense_select.php
Modified: trunk/php/expense/expense.pinc
===================================================================
--- trunk/php/expense/expense.pinc 2012-06-27 11:13:02 UTC (rev 664)
+++ trunk/php/expense/expense.pinc 2012-06-27 12:32:08 UTC (rev 665)
@@ -298,7 +298,7 @@
function getRefLink($text = "") {
global $lang;
if ( is_object($this->ref) ) {
- return $this->ref->getLink();
+ return $this->ref->getLink($text);
}
return $lang['HistoryDeleted'];
}
@@ -309,7 +309,7 @@
function getAdrRefLink($text = "") {
global $lang;
if ( is_object($this->adr_ref) ) {
- return $this->adr_ref->getLink();
+ return $this->adr_ref->getLink($text);
}
return $lang['HistoryDeleted'];
}
@@ -820,7 +820,7 @@
case 'ExpenseInvoice':
case 'ExpenseCreate':
$x = resolve_history_obj($f,$this->dbconn);
- break;
+ break;
case 'ExpenseCategory':
$x = resolve_history_lgarr ($f,'ExpenseCategories');
break;
@@ -830,7 +830,7 @@
case 'ExpenseStartTime':
case 'ExpenseEndTime':
$x = resolve_history_datetime($f,$this->dbconn,false);
- break;
+ break;
default:
return null;
}
Modified: trunk/php/expense/expense_overview.php
===================================================================
--- trunk/php/expense/expense_overview.php 2012-06-27 11:13:02 UTC (rev 664)
+++ trunk/php/expense/expense_overview.php 2012-06-27 12:32:08 UTC (rev 665)
@@ -154,7 +154,9 @@
$this->flds++;
$this->preflds++;
}
- $r .= $this->orderHeader('',$lang['ExpenseAddress'],$this->link2);
+ if ($this->head['adr_id']) {
+ $r .= $this->orderHeader('',$lang['ExpenseAddress'],$this->link2);
+ }
if ($this->head['category']) {
$r .= $this->orderHeader('category',$lang['ExpenseCategory'],$this->link2);
$this->flds++;
@@ -198,17 +200,28 @@
$x = $this->mark_filter(myentities($b->getFullName()),'name');
$r .= ' <td class="over_l">'. $b->getLink($x,'ss='.$ss) ."</td>\n";
if ($this->head['link_id']) {
- $r .= ' <td class="over_l">'. $b->getRefLink() ."</td>\n";
+ $x = '';
+ if ( is_object($b->ref) ) {
+ $x = $this->mark_filter(myentities($b->ref->getFullName()),'nsrn');
+ }
+ $r .= ' <td class="over_l">'. $b->getRefLink($x) ."</td>\n";
}
if ($this->head['supplier']) {
+ $x = '';
if (is_object($b->supplier)) {
- $x = $this->mark_filter(myentities($b->supplier->getFullName()),'supfn');
+ $x = $this->mark_filter(myentities($b->supplier->getFullName()),'supplier');
}
$r .= ' <td class="over_l">'. (is_object($b->supplier) ? $b->supplier->getLink($x):' ') ."</td>\n";
}
- $r .= ' <td class="over_l">'. $b->getAdrRefLink() ."</td>\n";
+ if ($this->head['adr_id']) {
+ $x = '';
+ if ( is_object($b->adr_ref) ) {
+ $x = $this->mark_filter(myentities($b->adr_ref->getFullName()),'adr_id');
+ }
+ $r .= ' <td class="over_l">'. $b->getAdrRefLink($x) ."</td>\n";
+ }
if ($this->head['category']) {
$r .= ' <td class="over_l">'. $b->getCategory() ."</td>\n";
@@ -326,7 +339,7 @@
* prepare
*/
Function prepare() {
- global $msg,$lang;
+ global $msg,$lang,$table;
$this->layout_id = useexpenses;
$this->name = $lang['ExpensesOverview'];
@@ -340,12 +353,13 @@
$this->link1 = 'expense/expense_overview.php';
$this->filter = array();
- $this->head['link_id'] = true;
- $this->head['custom'] = true;
- $this->head['mods'] = true;
+ $this->head['link_id'] = true;
+ $this->head['custom'] = true;
+ $this->head['mods'] = true;
$this->head['supplier'] = true;
$this->head['category'] = true;
$this->head['quantity'] = true;
+ $this->head['adr_id'] = true;
if (isset($this->hide['category']) && $this->hide['category'] ) {
$this->head['category'] = false;
@@ -361,26 +375,40 @@
}
$this->link1 = addHiddenFields($this->link1);
- $reftype = "";
- $name = "";
- $nsrn = "";
- $nscr = "";
+ if (isset($_GET['ext'])) {
+ $this->ext = $_GET['ext'];
+ $this->link1 = addUrlParameter($this->link1,"ext=".$this->ext);
+ } else {
+ $this->ext = 2; // call from somewhere else
+ }
- if ( isset($_GET['reftype']) ) {
- $reftype = $_GET['reftype'];
- }
+ $reftype = '';
+ $name = '';
+ $nsrn = '';
+ $nscr = '';
+
if ( isset($_GET['name']) ) {
$name = $_GET['name'];
}
- if ( isset($_GET['nsrn']) ) {
- $nsrn = $_GET['nsrn'];
+ if ($this->ext != 0) {
+ if ( isset($_GET['reftype']) ) {
+ $reftype = $_GET['reftype'];
+ $this->link1 = addUrlParameter($this->link1,"reftype=". $reftype);
+ $this->filter['reftype'] = $reftype;
+ }
+ if ( isset($_GET['nsrn']) ) {
+ $nsrn = $_GET['nsrn'];
+ $this->link1 = addUrlParameter($this->link1,"nsrn=". $nsrn);
+ $this->filter['nsrn'] = $nsrn;
+ }
+ if ( isset($_GET['nscr']) ) {
+ $nscr = $_GET['nscr'];
+ $this->link1 = addUrlParameter($this->link1,"nscr=".UrlEncode($nscr));
+ $this->filter['nscr'] = $nscr;
+ }
}
- if ( isset($_GET['nscr']) ) {
- $nscr = $_GET['nscr'];
- }
-
- $j = "SELECT DISTINCT e.* FROM ". $this->dbconn->prefix ."expenses e "; // select + join
+ $j = "SELECT DISTINCT e.* FROM ". $this->dbconn->prefix .$table['expense'][name].' e '; // select + join
$q = "";
$pre = " WHERE ";
@@ -416,7 +444,7 @@
$nsrn = "";
}
if ( ($reftype == 1) || ($reftype == -1) ) {
- $j .= ", ". $this->dbconn->prefix ."companies c ";
+ $j .= ", ". $this->dbconn->prefix .$table['company'][name].' c ';
$q .= " ". $pre . "(e.link_id=c.id ";
if ( $nsrn != "" ) {
$q .= " AND ". $this->dbconn->Like("c.name",$nsrn);
@@ -425,7 +453,7 @@
$pre = " OR ";
}
if ( ($reftype == 2) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."departments d ";
+ $j .= ",". $this->dbconn->prefix .$table['department'][name].' d ';
$q .= " ". $pre . "(e.link_id=d.id ";
if ( $nsrn != "" ) {
$q .= " AND ". $this->dbconn->Like("d.name",$nsrn);
@@ -434,7 +462,7 @@
$pre = " OR ";
}
if ( ($reftype == 3) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."addresses a ";
+ $j .= ",". $this->dbconn->prefix .$table['address'][name].' a ';
$q .= $pre ."( (";
$q .= $this->dbconn->Like("a.f_name",$nsrn) ." OR ";
$q .= $this->dbconn->Like("a.m_name",$nsrn) ." OR ";
@@ -443,7 +471,7 @@
$pre = " OR ";
}
if ( ($reftype == 4) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."bugs b";
+ $j .= ",". $this->dbconn->prefix .$table['bugtracking'][name].' b';
$q .= " ". $pre . "(e.link_id=b.id ";
if ( $nsrn != "" ) {
$q .= " AND ". $this->dbconn->Like("b.short",$nsrn);
@@ -452,7 +480,7 @@
$pre = " OR ";
}
if ( ($reftype == 5) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."products p";
+ $j .= ",". $this->dbconn->prefix .$table['product'][name].' p';
$q .= $pre ."( e.link_id=p.id ";
if ( $nsrn != "" ) {
$q .= " AND (";
@@ -463,19 +491,19 @@
$pre = " OR ";
}
if ( ($reftype == 6) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."teams t";
+ $j .= ",". $this->dbconn->prefix .$table['team'][name].' t';
$q .= $pre . "(e.link_id=t.id AND ". $this->dbconn->Like("t.name",$nsrn) .")";
$pre = " OR ";
}
if ( ($reftype == 7) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."tasks k";
+ $j .= ",". $this->dbconn->prefix .$table['task'][name].' k';
$q .= $pre . "(e.link_id=k.id AND ". $this->dbconn->Like("k.name",$nsrn) .")";
$pre = " OR ";
}
if ( ($reftype == 8) || ($reftype == -1) ) {
- $j .= ",". $this->dbconn->prefix ."installations i";
- if ( ! stristr($j, "products") ) {
- $j .= ",". $this->dbconn->prefix ."products p";
+ $j .= ",". $this->dbconn->prefix.$table['installation'][name].' i';
+ if ( ! stristr($j, $table['product'][name]) ) {
+ $j .= ",".$this->dbconn->prefix.$table['product'][name].' p';
}
$q .= $pre ."( e.link_id=i.id AND i.product_id=p.id AND (";
$q .= $this->dbconn->Like("p.name",$nsrn) ." OR ";
@@ -484,25 +512,10 @@
}
$pre = "AND ";
- $this->link1 = addUrlParameter($this->link1,"reftype=". $reftype);
- $this->link1 = addUrlParameter($this->link1,"nsrn=". $nsrn);
- // remember this
- $_SESSION['expensesearchreftype'] = $reftype;
- $this->filter['reftype'] = $reftype;
}
- if ( ($nscr != "*") && ($nscr != "") ) {
- $j .= ", addresses ";
- $q .= $pre ."( (";
- $q .= $this->dbconn->Like("addresses.f_name",$nscr) ." OR ";
- $q .= $this->dbconn->Like("addresses.m_name",$nscr) ." OR ";
- $q .= $this->dbconn->Like("addresses.l_name",$nscr) .")";
- $q .= " AND e.creator=addresses.id )";
- $pre = "AND ";
- $this->link1 = addUrlParameter($this->link1,"nscr=".UrlEncode($nscr));
- $this->filter['nscr'] = $nscr;
- }
+ // remember this
+ $_SESSION['expensesearchreftype'] = $reftype;
-
$this->q = $j.$q;
$this->qpre = $pre;
@@ -518,6 +531,14 @@
overview_arg($this,'supfn',OVERVIEW_ARG_FN,'expense',array('supplier'),'ExpenseSupplier','e.','cd');
overview_arg($this,'supid',OVERVIEW_ARG_OBJID,'expense',array('supplier'),'ExpenseSupplier','e.');
+ // adr
+ overview_arg($this,'adrfn',OVERVIEW_ARG_FN,'expense',array('adr_id'),'ExpenseAddress','e.','at');
+ overview_arg($this,'adrid',OVERVIEW_ARG_OBJID,'expense',array('adr_id'),'ExpenseAddress','e.');
+
+ // creator
+ overview_arg($this,'crfn',OVERVIEW_ARG_FN,'expense',array('creator'),'ExpenseCreator','e.','a');
+ overview_arg($this,'crid',OVERVIEW_ARG_OBJID,'expense',array('creator'),'ExpenseCreator','e.');
+
// category
overview_arg($this,'cat',OVERVIEW_ARG_INT,'expense',array('category'),array('ExpenseCategory','ExpenseCategories'),'e.');
@@ -535,7 +556,7 @@
foreach ($custom[1] as $s) {
$this->q = preg_replace('# where#i',','.$s.' WHERE',$this->q);
}
- # $msg .= $this->q;
+ // $msg = addLine($this->q,$msg);
check_dbacl($this->dbconn,$this->q, $this->user->id);
Modified: trunk/php/expense/expense_select.php
===================================================================
--- trunk/php/expense/expense_select.php 2012-06-27 11:13:02 UTC (rev 664)
+++ trunk/php/expense/expense_select.php 2012-06-27 12:32:08 UTC (rev 665)
@@ -36,10 +36,8 @@
$this->width = 3;
$r = '';
$r .= "<form id=\"expensesearch\" name=\"expensesearch\" method=\"get\" action=\"expense_overview.php\">\n";
- if ( $this->ext == false ) {
- $this->addHidden("reftype",0);
- }
$r .= $this->SelectTableStart();
+ $this->addHidden('ext',$this->ext);
$r .= $this->headline($lang['SearchForExpense']);
$r .= $this->ContentRowStart();
@@ -70,7 +68,7 @@
}
$r .= $this->ContentRowStart('ext');
- $r .= $this->showfieldc($lang['ExpenseRefType']);
+ $r .= $this->showfieldc($lang['ExpenseRefType'],0,'reftype');
$r .= $this->showdata($this->ExpenseAskRefType($this->nsrt,1),2);
$r .= $this->ContentRowEnd();
@@ -85,13 +83,18 @@
$r .= $this->ContentRowEnd();
$r .= $this->ContentRowStart('ext');
+ $r .= $this->showfieldc($lang['ExpenseAddress'],0,'adr');
+ $r .= $this->showdata(select_from_array_or_input($this->obj,"adr",null,1,'at'),2);
+ $r .= $this->ContentRowEnd();
+
+ $r .= $this->ContentRowStart('ext');
$r .= $this->showfieldc($lang['ExpenseCategory'],0,'cat');
$r .= $this->showdata(SelectLangArray('cat','ExpenseCategories',-1,true),2);
$r .= $this->ContentRowEnd();
$r .= $this->ContentRowStart('ext');
- $r .= $this->showfieldc($lang['ExpenseCreator'],0,'nscr');
- $r .= $this->showdata('<input type="text" value="" name="nscr" id="nscr" />',2);
+ $r .= $this->showfieldc($lang['ExpenseCreator'],0,'cr');
+ $r .= $this->showdata(select_from_array_or_input($this->obj,"cr",null,1,'a'),2);
$r .= $this->ContentRowEnd();
$r .= $this->ContentRowStart('ext');
@@ -127,7 +130,7 @@
function ExpenseAskRefType ($default,$any) {
global $lang;
- $r = '<select name="reftype">';
+ $r = '<select id="reftype" name="reftype">';
foreach ($lang['ExpenseReferences'] as $i => $f ) {
$r .= "<option value=\"". $i ."\" ";
if ( $i == $default ) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|