summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 625da52)
raw | patch | inline | side by side (parent: 625da52)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 19 Jan 2006 10:39:14 +0000 (10:39 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 19 Jan 2006 10:39:14 +0000 (10:39 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2526 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_glpiPrinterAccount.inc | patch | blob | history | |
plugins/admin/systems/class_glpiPrinterCartridges.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/glpiPrinter.tpl | patch | blob | history | |
plugins/admin/systems/glpiPrinterCartridges.tpl | [new file with mode: 0644] | patch | blob |
diff --git a/plugins/admin/systems/class_glpiPrinterAccount.inc b/plugins/admin/systems/class_glpiPrinterAccount.inc
index 624ba23a549b2df0db94151e2fa2623cf59ff8c4..7c86816893efac3be2284de5e8a6efe33a4732b8 100644 (file)
var $comments = ""; // Comment
- var $type = 0; // System type id
+ var $type = 0; // printer type id
var $serial = "";
var $otherserial = "";
var $ramSize = 0;
var $usedDevices = array(); // Which devices are currently selected
var $usedAttachments = array(); // Used Attachments
-
+ var $usedCartridges = array(); // Used Cartridges
/* Contructor
Sets default values and checks if we already have an existing glpi account
foreach($atts as $attachment){
$this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc'];
}
+
+ $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
+ foreach($cart as $key => $cartridge){
+ $this->usedCartridges[$key]=$cartridge;
+ $this->usedCartridges[$key]['status']="exists";
+ }
+
+
}else{
$this->is_account = false;
}
$smarty= get_smarty();
$display= "";
+ $smarty->assign("CartridgesACL",chkacl($this->acl,"Cartridges"));
+
/* Assign smarty defaults
To avoid undefined indexes, if there is an error with the glpi db
*/
}
}
+ /* ##########################################################################
+ * Printer Cartridge handling
+ */
+
+ /* Abort cartridge select dialog
+ */
+ if(isset($_POST['SelectCartridgeCancel'])){
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Get selected cartridges and add them to our list
+ */
+ if(isset($_POST['SelectCartridgeSave'])){
+ $this->cur_dialog->save_object();
+ $carts = $this->cur_dialog->save();
+ foreach($carts as $cart){
+ $cart['status'] = "new";
+ $this->usedCartridges[] = $cart;
+ }
+ $this->cur_dialog = false;
+ $this->edit_type = false;
+ }
+
+ /* Remove cartridge
+ */
+ if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges']))){
+ if(isset($this->usedCartridges[$_POST['Cartridges']])){
+ if($this->usedCartridges[$_POST['Cartridges']]['status'] == "exists"){
+ $this->usedCartridges[$_POST['Cartridges']]['status'] = "deleted";
+ }else{
+ unset($this->usedCartridges[$_POST['Cartridges']]);
+ }
+ }
+ }
+
+ /* Open Attachment pool to add/edit Attachments
+ */
+ if(isset($_POST['AddCartridge'])){
+ $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
+ $this->dialog = true;
+ }
+
+
/* ##########################################################################
* Draw Dialogs
*/
$smarty->assign("Attachments", $this->getUsedAttachments());
$smarty->assign("AttachmentKeys", array_flip($this->getUsedAttachments()));
+ /* Assign Cartridges
+ */
+ $smarty->assign("Cartridges", $this->getUsedCartridges());
+ $smarty->assign("CartridgeKeys", $this->getUsedCartridges(true));
/* ##########################################################################
* Assign contact and technical responsible person
}
$tmp = $this->handle->getPrinterInformations($this->dn);
$this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
+
+ foreach($this->usedCartridges as $cart){
+ if($cart['status'] == "deleted"){
+ $this->handle->removeCartridgeFromPrinter($cart['ID']);
+ }elseif($cart['status'] == "new"){
+ $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
+ }
+ }
}
}
}
return($ret);
}
-
+
+ function getUsedCartridges($flip = false)
+ {
+ $ret = array();
+ foreach($this->usedCartridges as $key => $value){
+ if($value['status'] == "deleted") continue;
+ if($flip){
+ $ret[$key] = $key;
+ }else{
+ $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
+ }
+ }
+ return($ret);
+ }
}
diff --git a/plugins/admin/systems/class_glpiPrinterCartridges.inc b/plugins/admin/systems/class_glpiPrinterCartridges.inc
--- /dev/null
@@ -0,0 +1,187 @@
+<?php
+
+class glpiPrinterCartridges extends plugin
+{
+ /* CLI vars */
+ var $cli_summary= "Manage server basic objects";
+ var $cli_description= "Some longer text\nfor help";
+ var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
+
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array();
+ var $objectclasses = array("whatever");
+
+ var $parent = NULL; // Contains parent class, to access glpi db handle
+ var $usedCartridges = array(); // IDs of used cartridges for this printer
+ var $PrinterType = 0; // Specifies which cartridge types are available
+
+ function glpiPrinterCartridges ($config, $dn= NULL,$type)
+ {
+ plugin::plugin ($config, $dn);
+
+ /* Assign some basic settings */
+ $this->ui = get_userinfo();
+ if(!isset($_SESSION['glpiCartridgeRegex'])){
+ $_SESSION['glpiCartridgeRegex'] = "*";
+ }
+
+ /* Only display cartridges for this type of printer */
+ $this->PrinterType = $type;
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+ $display ="";
+ $smarty = get_smarty();
+
+ /* Check poted vars and do the requested job, but only once */
+ $only_once = true;
+ foreach($_POST as $name => $value){
+
+ /* We have to create a new cartridge */
+ if(preg_match("/^newcartridge/",$name)&&($only_once)){
+ echo "new Cartridge";
+
+ $only_once = false;
+ }
+ }
+
+ /* Edit cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="edit_cartridge"){
+ print_a($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ echo "edit";
+ }
+
+ /* remove cartridge */
+ if(isset($_GET['act'])&&$_GET['act']=="del_cartridge"){
+ print_a($this->parent->handle->getCartridgeTypeInformations($_GET['id']));
+ echo "remove";
+ }
+
+ /* Create divlist */
+ $divlist = new divlist("glpi devices");
+ $divlist->SetEntriesPerPage(0);
+ $divlist->SetHeader(array(
+ array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
+ array("string" => _("Cartridges"), "attach" => "style=''"),
+ array("string" => _("Action"), "attach" => "style='width:60px;border-right:0px;text-align:right;'" )));
+
+ /* Links for editing,adding.... */
+ $edit = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'>%s</a>";
+ $editdel = "<a href='?plug=".$_GET['plug']."&act=edit_cartridge&id=%s'><img src='images/edit.png' alt='"._("Edit")."' border=0></a>";
+ $editdel.= "<a href='?plug=".$_GET['plug']."&act=del_cartridge&id=%s'><img src='images/edittrash.png' alt='"._("Delete")."' border=0></a>";
+
+ /* Checkbox for selection of some cartridges */
+ $useCartridge = "<input type='hidden' name='wasOnPage_%s' value='%s'><input type='checkbox' value='%s' name='useCartridge_%s' %CHECKED%>";
+
+ /* Add cartridges */
+ $cart = $this->getCartridgeTypes();
+ foreach($cart as $key=>$cartr){
+
+ /* check if this cartridge is selected */
+ $chk = "";
+ if(isset($this->usedCartridges[$key])){
+ $chk = " checked ";
+ }
+
+ /* Add fields */
+ $field1 = array("string" => preg_replace("/%s/",($key),preg_replace("/%CHECKED%/",$chk,$useCartridge)), "attach" => "style='text-align:center;width:20px;'");
+ $field2 = array("string" => sprintf($edit,($key),$cartr['cartridgeName']." [".$cartr['cartridgeTypeName']."]"), "attach" => "style=''");
+ $field3 = array("string" => sprintf($editdel,($key),($key)),
+ "attach" => "style='width:60px;border-right:0px;text-align:right;'");
+ $divlist->AddEntry(array($field1,$field2,$field3));
+
+ }
+
+ /* Create list header */
+ $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
+ " <input class='center' type='image' align='middle'
+ src='images/zip.png' title='"._("New monitor")."' alt='"._("M")."' name='newcartridge'> ".
+ "</div>";
+
+ /* Tell smarty some vars */
+ $filter= $_SESSION['glpiCartridgeRegex'];
+ $smarty->assign("devicehead", $listhead);
+ $smarty->assign("devices", $divlist->DrawList());
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("searchu_image", get_template_path('images/search_user.png'));
+ $smarty->assign("tree_image", get_template_path('images/tree.png'));
+ $smarty->assign("infoimage", get_template_path('images/info.png'));
+ $smarty->assign("launchimage", get_template_path('images/launch.png'));
+ $smarty->assign("apply", apply_filter());
+ $smarty->assign("alphabet", generate_alphabet());
+ $smarty->assign("cartridge_regex", $filter['device_regex']);
+
+ $display.= $smarty->fetch(get_template_path('glpiPrinterCartridges.tpl', TRUE));
+ return($display);
+ }
+
+ /* Save device to glpi database
+ * If this is a new device, create a new entry, else update this entry
+ */
+ function save()
+ {
+ $carts = $this->getCartridgeTypes();
+ $ret = array();
+ foreach($this->usedCartridges as $key){
+ $tmp =array();
+ $tmp['date_use'] = date("Y-m-d");
+ $tmp['ID'] = -1;
+ $tmp['type_ID'] = $carts[$key]['cartridgeID'];
+ $tmp['name'] = $carts[$key]['cartridgeName'];
+ $tmp['FK_glpi_printers']= -1;
+ $tmp['type_name'] = $carts[$key]['cartridgeTypeName'];
+ $ret[$key] = $tmp;
+ }
+ return($ret);
+ }
+
+ /* this only gets all already defined devices */
+ function reload()
+ {
+ $this->devices = $this->parent->handle->getDevices();
+ ksort($this->devices);
+ }
+
+ /* This funtions saves all POST variables.
+ The variable must be in the array $this->EditEntry
+ */
+ function save_object()
+ {
+ /* Checkbox handling
+ * Check which checkbox is selected
+ */
+ foreach($_POST as $name => $value){
+ if(preg_match("/wasOnPage/",$name)){
+ $id = preg_replace("/wasOnPage_/","",$name);
+ if(isset($_POST['useCartridge_'.$id])){
+ $this->usedCartridges[$id]=$id;
+ }else{
+ unset($this->usedCartridges[$id]);
+ }
+ }
+ }
+ }
+
+ /* This function cehck all created devices if you wan't to create device specific check
+ use >>if($attr['device_type']=="moboard")<< to create a device type depending check
+ */
+ function check($attr)
+ {
+ $message = array();
+ return($message);
+ }
+
+ /* Return cartriges for our divlist */
+ function getCartridgeTypes()
+ {
+ $ret = array();
+ $ret = $this->parent->handle->getAvailableCartridgeTypes($this->PrinterType);
+ return($ret);
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
index 03a758cf3c779717ed594fe61580751ce0f1ce14..d41003fee022814d82d5c898cdb5079c5e58f67f 100644 (file)
</td>
</tr>
</table>
+<br>
<p class="seperator" > </p>
+ <h2>{t}Information{/t}</h2>
+ <table summary="" width="100%">
+ <tr>
+ <td>
+ <textarea name="comments" style="width:100%;height:100px;" {$commentsACL}>{$comments}</textarea>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
<h2>{t}Supported interfaces{/t}</h2>
<table summary="" width="100%">
<tr>
</tr>
</table>
<input name="glpiPrinterFlagsPosted" value="1" type="hidden">
- </td>
- <td style="border-left: 1px solid rgb(160, 160, 160); vertical-align: top; padding-right: 5px;">
- <h2>{t}Information{/t}</h2>
- <table summary="" width="100%">
+ <p class="seperator" > </p>
+ <h2>{t}Attachments{/t}</h2>
+ <table summary="" width="100%">
<tr>
- <td style="vertical-align: top;">
- {t}Comments{/t}
- </td>
<td>
- <textarea name="comments" style="width:100%;height:110px;" {$commentsACL}>{$comments}</textarea>
+ <select name="Attachments" {$AttachmentsACL} style="height:100px;width:100%;" multiple>
+ {html_options values=$AttachmentKeys output=$Attachments}
+ </select>
+ <input name="AddAttachment" value="{t}Add{/t}" type="submit">
+ <input name="RemoveAttachment" value="{t}Remove{/t}" type="submit">
</td>
</tr>
</table>
<p class="seperator" > </p>
- <h2>{t}Attachments{/t}</h2>
+ <h2>{t}Installed cartridges{/t}</h2>
<table summary="" width="100%">
<tr>
<td>
- <select name="Attachments" {$AttachmentsACL} style="height:120px;width:100%;" multiple>
- {html_options values=$AttachmentKeys output=$Attachments}
+ <select name="Cartridges" {$CartridgesACL} style="height:100px;width:100%;" multiple>
+ {html_options values=$CartridgeKeys output=$Cartridges}
</select>
- <input name="AddAttachment" value="{t}Add{/t}" type="submit">
- <input name="RemoveAttachment" value="{t}Remove{/t}" type="submit">
+ <input name="AddCartridge" value="{t}Add{/t}" type="submit">
+ <input name="RemoveCartridge" value="{t}Remove{/t}" type="submit">
</td>
</tr>
</table>
diff --git a/plugins/admin/systems/glpiPrinterCartridges.tpl b/plugins/admin/systems/glpiPrinterCartridges.tpl
--- /dev/null
@@ -0,0 +1,54 @@
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;" >
+ <div class="contentboxh">
+ <p class="contentboxh">
+ {t}List of available cartridge type for this type of printer{/t}
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$devicehead}
+ </div>
+ <div style='height:4px;'></div>
+ <div class="contentboxb" style="border-top:1px solid #B0B0B0;">
+ {$devices}
+ <input type=hidden name="edit_helper">
+ </div>
+ </td>
+ <td style="vertical-align:top;">
+ <div class="contentboxh" style="border-bottom:1px solid #B0B0B0;">
+ <p class="contentboxh"><img src="{$infoimage}" align="right" alt="[i]">{t}Information{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <p class="contentboxb">
+ {t}This dialog allows you to create new types of cartridges, and select one or more types for your printer. Cartridge types depends on the printer type you have selected. For each selected cartridge type there will be a new cartridge created, this allows you to select the same cartridge type for more then one printer.{/t}
+ </p>
+ </div>
+ <br>
+ <div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filters{/t}</p>
+ </div>
+ <div class="contentboxb">
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+ {$alphabet}
+ </table>
+<table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+<tr>
+<td><LABEL for="regex"><img alt="{t}Display cartridge types matching{/t}" src="{$search_image}" align=middle></label></td>
+<td width="99%">
+<input type='text' style='width:99%' name='cartridge_regex' maxlength='20' value='{$cartridge_regex}' title='{t}Regular expression for matching cartridge types{/t}' onChange="mainform.submit()">
+</td>
+</tr>
+</table>
+ {$apply}
+ </div>
+ </td>
+</tr>
+</table>
+
+<input type="hidden" name="ignore">
+<p class="seperator"> </p>
+<div align="right">
+ <input type="submit" name="SelectCartridgeSave" value="{t}Use{/t}">
+ <input type="submit" name="SelectCartridgeCancel" value="{t}Cancel{/t}">
+</div>