diff --git a/index.php b/index.php index 26336f12..b9b053e6 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ //sivann at gmail.com 2008-2014 $version=file_get_contents("VERSION"); -$fordbversion=6; +$fordbversion=7; /*********************************************************************** *********************************************************************** diff --git a/php/editsoftware.php b/php/editsoftware.php index afc4dc3f..340e2d73 100644 --- a/php/editsoftware.php +++ b/php/editsoftware.php @@ -123,6 +123,17 @@ db_exec($dbh,$sql); } + // user relations + if (!isset($_POST['userlnk'])) $userlnk=array(); + //update software - item links (installed into) + //remove old links for this object + $sql="delete from users2soft where softid=$id"; + db_exec($dbh,$sql); + //add new links for each checked checkbox + for ($i=0;$i
  • +
  • @@ -296,12 +308,27 @@ if ($lictype=="1") {$t1="checked";$t0="";$t2="";} if ($lictype=="2") {$t2="checked";$t0="";$t1="";} ?> - + License Per: - name='lictype' value='0'>Box - name='lictype' value='1'>CPU - name='lictype' value='2'>Core + + + + + + + + + +
    + name='lictype' value='0'/>Box + + name='lictype' value='1'/>CPU +
    + name='lictype' value='2'/>Core + + name='lictype' value='3'/>User +
    @@ -476,7 +503,7 @@ "target=_blank href='$scriptname?action=edititem&id=".$ir['id']."'>
    ". $ir['id']. "
    "; - echo "".$typeid2name[$ir['itemtypeid']]. + echo "".$typeid2name[$ir['itemtypeid']]. " ". "".$agents[$ir['manufacturerid']]['title']. " ". "".$ir['model']. " ". "".$ir['label']." ". diff --git a/php/edituser.php b/php/edituser.php index bdb373eb..f863491c 100644 --- a/php/edituser.php +++ b/php/edituser.php @@ -177,6 +177,27 @@ echo $institems; } ?> +
    + fetchAll(PDO::FETCH_ASSOC); + $nitems=count($ri); + $institems=""; + for ($i=0;$i<$nitems;$i++) { + $x=($i+1).": ".$ri[$i]['txt']; + if ($i%2) $bcolor="#D9E3F6"; else $bcolor="#ffffff"; + $institems.="\t
    ". + "$x
    \n"; + } + echo $institems; + } + ?> diff --git a/php/listsoftware.php b/php/listsoftware.php index 295b7c75..dbad634e 100644 --- a/php/listsoftware.php +++ b/php/listsoftware.php @@ -67,14 +67,19 @@ foreach($r as $k => $v) { ${$k} = $v; } // get all columns as variables //print a table row + if ($lictype<3) { $sql="SELECT items.id i_id, status,manufacturerid,model,dnsname,cpuno,corespercpu from items,item2soft ". " where item2soft.itemid=items.id AND item2soft.softid={$r['id']}"; + } else { + $sql="SELECT users.id i_id, userdesc from users,users2soft ". + " where users2soft.userid=users.id AND users2soft.softid={$r['id']}"; + } $sthi=db_execute($dbh,$sql); $ri=$sthi->fetchAll(PDO::FETCH_ASSOC); $nitems=count($ri); $institems=""; $licitems=0; - + for ($i=0;$i<$nitems;$i++) { $rstatus=(int)$ri[$i]['status']; if ($rstatus==1) { $attr="style='background-color:green;font-weight:bold;color:#efefef' title='Status: Stored'"; } @@ -82,17 +87,23 @@ elseif ($rstatus==3) { $attr="style='background-color:#cecece;font-weight:bold;' title='Status: Obsolete'"; } else { $attr=" title='Status: In Use' "; } + if ($lictype<3) { $x=($i+1).": ({$ri[$i]['i_id']}) ".$agents[$ri[$i]['manufacturerid']]['title']." ".$ri[$i]['model']." ".$ri[$i]['dnsname']; - + $action = 'edititem'; + } else { + $x=($i+1).": ({$ri[$i]['i_id']}) ".$ri[$i]['userdesc']; + $action = 'edituser'; + } if ($i%2) $bcolor="#D9E3F6"; //if ($i%2) $bcolor="#ECF1FB"; else $bcolor="#ffffff"; $institems.="
    ". - "$x
    "; + "$x"; if (empty($lictype) || $lictype==0) { $licitems++; } //per box elseif ($lictype==1) { $licitems+=$ri[$i]['cpuno']; } //per cpu elseif ($lictype==2) { $licitems+=$ri[$i]['cpuno']*$ri[$i]['corespercpu']; } //per core + elseif ($lictype==3) { $licitems++; } //per user }//items @@ -128,7 +139,7 @@ if ($licqty<$licitems) $style="style='font-weight:bold;color:red'"; elseif ($licqty==$licitems) $style="style='font-weight:normal;color:black'"; elseif ($licqty>$licitems) $style="style='font-weight:bold;color:#00aa00'"; - + $mend=strlen($maintend)?date($dateparam,$maintend):""; $mendkey=strlen($maintend)?date("Ymd",$maintend):"0"; $d=strlen($purchdate)?date($dateparam,$purchdate):""; diff --git a/updates/db/6_7.sql b/updates/db/6_7.sql new file mode 100644 index 00000000..6751af1c --- /dev/null +++ b/updates/db/6_7.sql @@ -0,0 +1,4 @@ +begin transaction; +CREATE TABLE users2soft (userid INTEGER, softid INTEGER, instdate INTEGER); +update settings set dbversion=7; +commit;