Code

Added copy & paste for ogroups
[gosa.git] / plugins / admin / systems / class_glpiPrinterAccount.inc
1 <?php
3 class glpiPrinterAccount extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary= "Manage server basic objects";
7   var $cli_description= "Some longer text\nfor help";
8   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account= FALSE;
12   var $attributes= array("ID","name","contact","ramSize","flags_serial","flags_par","flags_usb",
13       "tech_num","comments","date_mod","location","domain","network","contact_num","serial","otherserial",
14       "type","is_template","FK_glpi_enterprise","deleted");
16   var $ID                 ;       // Is set if this entry is edited 
17   var $name               = "";    // This should be the dn of this entry 
18   var $FK_glpi_enterprise = 0;     // Manufacturer id
19   var $tech_num           = "";    // Technical responsible person
20   var $contact_num        = "";    // Contact person
21   
22   var $comments           = "";    // Comment
23   
24   var $type               = 0;     // printer type id
25   var $serial             = "";   
26   var $otherserial        = "";  
27   var $ramSize            = 0;
28   var $flags_serial       = false;
29   var $flags_par          = false;
30   var $flags_usb          = false;
32   var $date_mod           = "";    // Modification timestamp
33   
34   var $location           = 0;     // Not used yet
35   var $domain             = 0;     // ? Set to 0
36   var $network            = 0;     // ? Set to 0 
38   var $is_template        = 0;     // Used as template ?
39   var $contact            = "";    // Empty
40   var $deleted            = "N";   // Deleted entries should have this set to Y
42   var $rename             = false;
43   var $select_type        ;
45   var $editManufacturer   = false;
47   /* Not necessary, cause we use mysql databse */
48   var $objectclasses= array("whatever");
50   /* Used to remember if this was an account (simply: is this an edited entry) */
51   var $initially_was_account = false;
53   /* Remember current dialog */
54   var $edit_type            = false;
55   var $edit_os              = false;
57   var $data;
58   var $handle = NULL;               // Glpi class handle used to query database
60   var $cur_dialog = NULL;           // This contains the sub dialog handle
62   var $orig_dn;                     // To check if dn, has changed 
63   var $ui;                          // Some GOsa specific user informations 
64   
65   var $usedDevices      = array();  // Which devices are currently selected 
66   var $usedAttachments  = array();  // Used Attachments 
67   var $usedCartridges   = array();  // Used Cartridges
69   /* Contructor 
70      Sets default values and checks if we already have an existing glpi account
71    */
72   function glpiPrinterAccount ($config, $dn= NULL)
73   {
74     plugin::plugin ($config, $dn);
75     $this->ui= get_userinfo();
77     $this->is_account = false;
79     /* Abort class construction, if no db is defined */
80     if(!isset($this->config->data['SERVERS']['GLPI'])){
81       return;
82     }
84     // Get informations about databse connection
85     $this->data = $this->config->data['SERVERS']['GLPI'];
87     // Abort if mysql extension is missing 
88     if(!is_callable("mysql_connect")){
89       return;
90     }
92     // Create handle of glpi class, and check if database connection is established 
93     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
95     if(!$this->handle->is_connected){
96       return;
97     } 
99     // If this dn is already used in database, then get all informations for this entry 
100     if($this->handle->is_printer_account($this->dn)){
101       $this->is_account = true;
102       $tmp = ($this->handle->getPrinterInformations($this->dn));
104       foreach(array("tech_num","FK_glpi_enterprise","type","comments","contact_num","flags_serial","flags_par","flags_usb","ramSize") as $attr){
105         $this->$attr = $tmp[0][$attr];
106       }
107       
108       $atts = $this->handle->getAssignPrinterAttachments($tmp[0]['ID']);
109       foreach($atts as $attachment){
110         $this->usedAttachments[$attachment['FK_doc']]=$attachment['FK_doc']; 
111       }
113       $cart= $this->handle->getUsedCartridges($tmp[0]['ID']);
114       foreach($cart as $key => $cartridge){
115         $this->usedCartridges[$key]=$cartridge; 
116         $this->usedCartridges[$key]['status']="exists"; 
117       }
120     }else{
121       $this->is_account = false;
122     }
124     /* set defaults */
125     $this->name                 = $this->dn;
126     $this->orig_dn              = $this->dn;
127     $this->initially_was_account = $this->is_account;
128   }
130   function execute()
131   {
132     /* Call parent execute */
133     plugin::execute();
135     /* Fill templating stuff */
136     $smarty= get_smarty();
137     $display= "";
139     $smarty->assign("CartridgesACL",chkacl($this->acl,"Cartridges"));
141     /*  Assign smarty defaults 
142         To avoid undefined indexes, if there is an error with the glpi db
143      */ 
144     foreach(array("PrinterTypeKeys","PrinterTypes","ManufacturerKeys","Manufacturers","Attachments","AttachmentKeys","CartridgeKeys","Cartridges") as $attr){
145       $smarty->assign($attr,array());
146       $smarty->assign($attr."ACL"," disabled ");
147     }
148     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","comments","flags_serial","flags_par","flags_usb","AttachmentsDiv") as $attr){
149       $smarty->assign($attr,"");
150       $smarty->assign($attr."ACL"," disabled ");
151     }
153     /* Check if there is a glpi database server defined 
154       */
155     if(!isset($this->config->data['SERVERS']['GLPI'])){
156       print_red(_("There is no server with valid glpi database service."));
157       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
158     }
160     $this->data = $this->config->data['SERVERS']['GLPI'];
162     /* Check if we can call mysql_connect 
163        If we can't, there is no the mysql-php extension
164      */
165     if(!is_callable("mysql_connect")){
166       print_red(_("Can't connect to glpi database, the php-mysql extension is missing."));
167       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
168     }
170     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
172     /*  If handle == false, abort
173         Seems that the server, username and or password is wrong
174      */
175     if(!$this->handle->is_connected){
176       print_red(_("Can't connect to glpi database, check configuration twice."));
177       return($smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE)));
178     } 
180     /*  All checks are ok
181         Lets handle Posts, templates etc below ...
182      */
183     
184     $users = $this->handle->getUsers();
185     $ldap= $this->config->get_ldap_link();
187     
188     /*  ##########################################################################
189      *  Some tab management   
190      */
192     /* Do we need to flip is_account state? */
193     if (isset($_POST['modify_state'])){
194       $this->is_account= !$this->is_account;
195     }
197     /* Show tab dialog headers */
198     if ($this->is_account){
199       $display= $this->show_header(_("Remove inventory"),
200           _("This server has inventory features enabled. You can disable them by clicking below."));
201     } else {
202       $display= $this->show_header(_("Add inventory"),
203           _("This server has inventory features disabled. You can enable them by clicking below."));
204       return ($display);
205     }
207     
208     /*  ##########################################################################
209      *  Printer type management 
210      *  Dialog 
211      */
213     /* Rename was requested */
214     if(isset($_POST['Rename_PType_OK'])){
215       $tmp = $this->handle->getPrinterTypes();
216       $allok = true;
217       foreach($tmp as $id => $name){
218         if(trim($name) == trim($_POST['string'])){
219           $allok = false;
220         }
221       }
222       if($allok){
223         $this->handle->updatePrinterType($_POST['string'],$this->select_type);
224         $this->rename = false;
225       }else{
226         print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['string']));
227       }
228     }
230     /* abort rename 
231      */
232     if(isset($_POST['Rename_Cancel'])){
233       $this->rename = false;
234     }
236     /* Printer type management
237      */
238     if(isset($_POST['edit_type'])){
239       $this->dialog = true;
240       $this->edit_type=true;
241     }
243     /* This closes the printer type editing dialog
244      */
245     if(isset($_POST['close_edit_type'])){
246       $this->edit_type=false;
247       $this->dialog = false;
248     }
250     /* This appends a new printer to our sytem types
251      */
252     if((isset($_POST['add_type']))&&(!empty($_POST['type_string']))){
253     
254       $tmp = $this->handle->getPrinterTypes();
255       $allok = true;
256       foreach($tmp as $id => $name){
257         if(trim($name) == trim($_POST['type_string'])){
258           $allok = false;
259         }
260       }
261       if($allok){
262         $this->handle->addPrinterType($_POST['type_string']);  
263       }else{
264         print_red(sprintf(_("Can't rename given printer type to '%s', because this type name already exists."),$_POST['type_string']));
265       }
266     }
268     /* Remove selected type from our printer types list
269      */
270     if((isset($_POST['del_type']))&&(!empty($_POST['select_type']))){
271       $tmp = $this->handle->is_printerTypeUsed($_POST['select_type']);
272       if(count($tmp)){
273         $str = "";
274         foreach($tmp as $id => $name){
275           $str .= $name.", ";
276         }
277         $str = preg_replace("/, $/","",$str); 
278         print_red(sprintf(_("Can't delete printer type, it is still in use by '%s'."),$str));
279       }else{
280         $this->handle->removePrinterType($_POST['select_type']);  
281       }
282     }
284     /* Rename selected printer type to given string
285      */
286     if((isset($_POST['rename_type']))&&(!empty($_POST['select_type']))||($this->rename)){
287       $this->rename = true;
289       $smarty->assign("Method","rename");
291       $tmp = $this->handle->getPrinterTypes();
293       if(isset($_POST['select_type'])){
294         $this->select_type = $_POST['select_type'];
295       }  
296       $smarty->assign("string",$tmp[$this->select_type]);
297       if(isset($_POST['string'])){
298         $smarty->assign("string",$_POST['string']);
299       }
301       $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
302       return($display);
303     }  
305     /* Someone wants to edit the printer types ... 
306        So, lets open a new dialog which provides some buttons to edit the types
307      */
308     if($this->edit_type){
309       $smarty->assign("Method","edit");
310       $smarty->assign("PrinterTypes",            $this->handle->getPrinterTypes());
311       $smarty->assign("PrinterTypeKeys",         array_flip($this->handle->getPrinterTypes()));
312       $display= $smarty->fetch(get_template_path('glpi_edit_printer_type.tpl', TRUE));
313       return($display);
314     }
317     /*  ##########################################################################
318      *  Edit manufacturers 
319      *  Dialog 
320      */
322     /* Open dialog which allows to edit the manufacturers
323      */
324     if(isset($_POST['edit_manufacturer'])){
325       $this->cur_dialog = new glpiManufacturer($this->config,$this->dn);
326       $this->dialog = true;
327       $this->editManufacturer =true;
328     }
330     /* Close manufacturer editing dialog
331      */
332     if((isset($_POST['close_edit_manufacturer']))&&($this->editManufacturer)){
333       $this->dialog = false;
334       $this->cur_dialog = false;
335       $this->editManufacturer=false;
336     }
339     /*  ##########################################################################
340      *  Technical responsible person
341      *  Contact person 
342      *  Dialog 
343      */
345     /* Show dialog to select a new contact person
346      * Select a contact person
347      */
348     if(isset($_POST['SelectContactPerson'])){
349       $this->addUser = "contact";
350       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
351     }
353     /* Selecte technical responsible person
354      */
355     if(isset($_POST['SelectTechPerson'])){
356       $this->addUser ="tech";
357       $this->cur_dialog= new glpiSelectUser($this->config,$this->dn,"user_tech_num");
358     }
360     /* Abort user selection
361      */
362     $smarty->assign("AbortSelectUser","SelectUserCancel");
363     if(isset($_POST['SelectUserCancel'])){
364       $this->dialog = false;
365       $this->addUser ="";
366       $this->cur_dialog = false;
367     }
369     /* Technical responsible/contact person selected */
370     if(isset($_GET['act'])&&($_GET['act']=="user_tech_num")){
372       /* Get posted id */
373       $id = base64_decode($_GET['id']);
375       /* Check if user is already created in glpi database */
376       if(!in_array($id,$users)){
378         /* If this user doesn't exists in glpi db, we must create him */
379         $atr = $ldap->fetch($ldap->cat($id));
380         $tmp = array();
381         $use = array( "cn"              =>"name",
382             "mail"            =>"email",
383             "telephoneNumber" =>"phone");
385         /* Create array */
386         foreach($use as $gosa => $glpi){
387           if(isset($atr[$gosa])){
388             $tmp[$glpi]= $atr[$gosa][0];
389           }
390         }
392         /* Add this user */
393         $this->handle->addUser($tmp,$id);
394       }
396       /* Re-read users */
397       $users = ($this->handle->getUsers());
399       /* Get user */
400       $tmp = array_flip($users);
401       $id=$tmp[$id];
403       /* Use user id, close dialog */
404       if($this->addUser == "tech"){
405         $this->tech_num = $id;
406       }else{
407         $this->contact_num = $id;
408       }
409       $this->cur_dialog   = false;
410       $this->dialog= false;
411     }
414     /*  ##########################################################################
415      *  Handle attachments 
416      */
417     
418     /* Attachment pool was closed with use
419      */
420     if(isset($_POST['UseAttachment'])){
421       if(count($this->cur_dialog->check())){
422         foreach($this->cur_dialog->check() as $msg){
423           print_red($msg);
424         }
425       }else{
426         $this->cur_dialog->save_object();
427         $this->usedAttachments = $this->cur_dialog->save();
428         $this->cur_dialog = false;
429         $this->edit_type = false; 
430       }
431     }
432    
433     /* Attachment pool was closed with abort
434      */ 
435     if(isset($_POST['AbortAttachment'])){
436       $this->cur_dialog = false;
437       $this->edit_type = false; 
438     }
440     /* Open Attachment pool to add/edit Attachments
441      */
442     if(isset($_POST['AddAttachment'])){
443       $this->cur_dialog = new glpiAttachmentPool($this->config,$this->dn,$this->usedAttachments);
444       $this->dialog = true;
445     }
446     
447     /* Remove Attachment from this tab 
448      */
449     $once = true;
450     foreach($_POST as $name => $value){
451       if((preg_match("/^delAttachment_/",$name))&&($once)){
452         $once= false;
453         $name = preg_replace("/^delAttachment_/","",$name);
454         $entry = preg_replace("/_.*$/","",$name);
455         if(isset($this->usedAttachments[$entry])){
456           unset($this->usedAttachments[$entry]);
457         }
458       }
459     }
460     if((isset($_POST['RemoveAttachment']))&&(isset($_POST['Attachments']))){
461       if(isset($this->usedAttachments[$_POST['Attachments']])){
462         unset($this->usedAttachments[$_POST['Attachments']]);
463       }
464     }
466     /*  ##########################################################################
467      *  Printer Cartridge handling 
468      */
470     /* Abort cartridge select dialog
471      */
472     if(isset($_POST['SelectCartridgeCancel'])){
473       $this->cur_dialog = false;
474       $this->edit_type = false; 
475     }
477     /* Get selected cartridges and add them to our list 
478      */ 
479     if(isset($_POST['SelectCartridgeSave'])){
480       $this->cur_dialog->save_object();
481       $carts = $this->cur_dialog->save();
482       foreach($carts as $cart){
483         $cart['status'] = "new";
484         $this->usedCartridges[] = $cart;
485       }
486       $this->cur_dialog = false;
487       $this->edit_type = false; 
488     }
490     /* Remove cartridge  
491      */
492     if((isset($_POST['RemoveCartridge']))&&(isset($_POST['Cartridges']))){
494       foreach($_POST['Cartridges'] as $cartID){
496         if(isset($this->usedCartridges[$cartID])){
497           if($this->usedCartridges[$cartID]['status'] == "exists"){
498             $this->usedCartridges[$cartID]['status'] = "deleted";
499           }else{
500             unset($this->usedCartridges[$cartID]);
501           }
502         }
503       }
504     }
506     /* Open Attachment pool to add/edit Attachments
507      */
508     if(isset($_POST['AddCartridge'])){
509       $this->cur_dialog = new glpiPrinterCartridges($this->config,$this->dn,$this->type);
510       $this->dialog = true;
511     }
514     /*  ##########################################################################
515      *  Draw Dialogs
516      */
517     /* if( cur_dialog != false || cur_dialog != NULL) 
518      * There is a dialog which wants to be displayed 
519      */
520     if($this->cur_dialog){
521       $this->cur_dialog->save_object();
522       $this->dialog=true;
523       $this->cur_dialog->parent = &$this;
524       return($this->cur_dialog->execute());
525     }else{
526       $this->dialog= false;
527     }
530     /*  ##########################################################################
531      *  Assign listbox / checkbox .... values to smarty  
532      */
533     /* Assign smarty defaults */ 
534     foreach(array("PrinterTypes","PrinterTypeKeys","Manufacturers","TechnicalResponsibles","Attachments","Cartridges") as $attr){
535       $smarty->assign($attr,array());
536       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
537     }
539     /* Assign some vars to smarty 
540      */
541     foreach(array("type","FK_glpi_enterprise","tech_num","contact_num","flags_serial","flags_par","flags_usb") as $attr){
542       $smarty->assign($attr,"");
543       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
544     }
547     /* Assign ACLs to smarty*/
548     foreach($this->attributes as $attr){
549       $smarty->assign($attr."ACL",chkacl($this->acl,$attr));
550     }
552     $smarty->assign("comments",               $this->comments);
553     $smarty->assign("flags_serial",            $this->flags_serial);
554     $smarty->assign("flags_par",               $this->flags_par);
555     $smarty->assign("flags_usb",               $this->flags_usb);
557     /* Assign system types 
558      */
559     $smarty->assign("PrinterTypes",           $this->handle->getPrinterTypes());
560     $smarty->assign("PrinterTypeKeys",        array_flip($this->handle->getPrinterTypes()));
561     $smarty->assign("type",                   $this->type);
563     /* Append manufacturers
564      */
565     $smarty->assign("ManufacturerKeys",       array_flip($this->handle->getEnterprises()));
566     $smarty->assign("Manufacturers",          $this->handle->getEnterprises());
567     $smarty->assign("FK_glpi_enterprise",     $this->FK_glpi_enterprise);
569     /* Assign used Attachments
570     */
572     $divlist = new divSelectBox("glpiAttachmentsList");
573     $divlist-> SetHeight(120);
574     $atts = $this->getUsedAttachments(true);
575     $downlink = "<a href='get_attachment.php?id=%s' target='_blank'>%s</a>";
576     $del_link = "<input type='image' src='images/edittrash.png' name='delAttachment_%s'>";
577     foreach($atts as $id => $attachment){
578       $divlist->AddEntry
579           (
580         array(
581             array("string"=>$attachment['name']),
582             array("string"=>$attachment['mime']),
583             array("string"=>sprintf($downlink,$id,$attachment['filename'])),
584             array("string"=>sprintf($del_link,$attachment['ID']),"attach"=>"style='border-right:0px;'"),
585              )
586           );
587     }
589     $smarty->assign("AttachmentsDiv"          ,$divlist->DrawList());
590     $smarty->assign("Attachments",            $this->getUsedAttachments());
591     $smarty->assign("AttachmentKeys",         array_flip($this->getUsedAttachments()));
593     /* Assign Cartridges 
594      */
595     $smarty->assign("Cartridges",            $this->getUsedCartridges());
596     $smarty->assign("CartridgeKeys",         $this->getUsedCartridges(true));
598     /*  ##########################################################################
599      *  Assign contact and technical responsible person 
600      */
601     if(isset($users[$this->contact_num])){
602       $tr = $ldap->fetch($ldap->cat($users[$this->contact_num]));
603       $str = "";
604       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
605       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
606       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
607       $smarty->assign("contact_num",               $str);
608     }else{
609       $smarty->assign("contact_num",               _("N/A"));
610     }
612     /* Handle tech person 
613        Assign name ... to smarty, if set
614      */ 
615     if(isset($users[$this->tech_num])){
616       $tr = $ldap->fetch($ldap->cat($users[$this->tech_num]));
617       $str = "";
618       if(isset($tr['givenName'][0])){   $str .= $tr['givenName'][0]." ";      }
619       if(isset($tr['sn'][0])) {         $str .= $tr['sn'][0]." ";             }
620       if(isset($tr['uid'][0])){         $str .= "[".$tr['uid'][0]."]";        }
621       $smarty->assign("tech_num",               $str);
622     }else{
623       $smarty->assign("tech_num",               _("N/A"));
624     }
626     /* If theres a cartridge selected, you can't change the printer type.
627      */ 
628     $disp = true;
630     foreach($this->usedCartridges as $cart){
631       if($cart['status'] != "deleted"){
632         $disp = false;
633       }
634     }
635     if($disp==false){
636       $smarty->assign("typeACL","disabled");
637     }
639     $display.= $smarty->fetch(get_template_path('glpiPrinter.tpl', TRUE));
640     return($display);
641   }
643   function remove_from_parent()
644   {
645     $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
646     if($this->initially_was_account){
647       $this->handle->removePrinterInformations($this->dn); 
648     }
649   }
652   /* Save data to object */
653   function save_object()
654   {
655     if(isset($_POST['glpiPrinterFlagsPosted'])){
656       plugin::save_object();
657       foreach($this->attributes as $attrs){
658         if(isset($_POST[$attrs])){
659           $this->$attrs = $_POST[$attrs];
660         }
661       }
663       foreach(array("flags_serial","flags_par","flags_usb") as $checkboxes){
664         if(isset($_POST[$checkboxes])){
665           $this->$checkboxes = 1;
666         }else{
667           $this->$checkboxes = 0;
668         }
669       }
670     }
672   }
675   /* Check supplied data */
676   function check()
677   {
678     $message= array();
680     //    if($this->TechnicalResponsible == ""){
681     //      $message[] = _("Please select a technical responsible person for this entry.");
682     //    }
684     return ($message);
685   }
687   /* Save to LDAP */
688   function save()
689   {
690     if($this->is_account){
691         $attrs = array();
692       $this->date_mod = date("Y-m-d H:i:s");
693       foreach($this->attributes as $attr){
694         $attrs[$attr] = $this->$attr;
695       }
696       $attrs['name'] = $this->dn;
697       unset($attrs['ID']);
698       $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']);
699       if($this->initially_was_account&&$this->is_account){
700         $this->handle->updatePrinterInformations($attrs,$this->dn);
701       }elseif($this->is_account){
702         $this->handle->addPrinterInformations($attrs,$this->dn);
703       }
704       $tmp = $this->handle->getPrinterInformations($this->dn);
705       $this->handle->addAttachmentsToPrinter($this->usedAttachments,$tmp[0]['ID']);
707       foreach($this->usedCartridges as $cart){
708         if($cart['status'] == "deleted"){
709           $this->handle->removeCartridgeFromPrinter($cart['ID']);
710         }elseif($cart['status'] == "new"){
711           $this->handle->addCartridgeFromPrinter($tmp[0]['ID'],$cart['type_ID']);
712         }
713       }
714     }
715   }
717   /* Return used attachments */
718   function getUsedAttachments($divlist = false)
719   {
720     $atts =$this->handle->getAttachments();
721     $ret = array();
722     foreach($atts as $entry){
723       if(in_array($entry['ID'],$this->usedAttachments)){
724         if($divlist){
725           $ret[$entry['ID']] = $entry;
726         }else{
727           $cm ="";
728           if(isset($entry['comment'])){
729             $cm=" [".$entry['comment']."]";
730           }
731           if(isset($entry['mime'])){
732             $cm.=" -".$entry['mime']."";
733           }
735           $ret[$entry['ID']]= $entry['name'].$cm;
736         }
737       }
738     }
739     return($ret);
740   }
742   function getUsedCartridges($flip = false)
743   {
744     $ret = array();
745     foreach($this->usedCartridges as $key => $value){
746       if($value['status'] == "deleted") continue;
747       if($flip){
748         $ret[$key] = $key;    
749       }else{
750         $ret[$key] = $value['name']." [".$value['type_name']."] "._("since")." :".$value['date_use'];
751       }
752     }
753     return($ret);
754   }  
758 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
759 ?>