Code

First layout adaptions
[gosa.git] / plugins / admin / systems / class_glpiManufacturer.inc
1 <?php
3 class glpiManufacturer 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= TRUE;
12   var $attributes= array("name","type","address","website","phonenumber","comments","deleted","fax","email");
13   var $objectclasses= array("whatever");
15   var $ui;
17   var $editMode = false;
18   var $Edit_Add = "edit";
20   var $name       ="";
21   var $type       ="";
22   var $address    ="";
23   var $website    ="";
24   var $phonenumber="";
25   var $comments   ="";
26   var $deleted    ="";
27   var $fax        ="";
28   var $email      ="";
29   var $ID         =-1;
31   function glpiManufacturer($config, $dn= NULL)
32   {
33     plugin::plugin ($config, $dn);
34     $this->ui = get_userinfo();  
35   }
37   function execute()
38   {
39     plugin::execute();
40     $smarty  = get_smarty();
41     $display = "";
43     if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
44       $this->parent->handle->removeEnterprise($_POST['manufacturer']);
45     }
47     if(isset($_POST['add_manu'])){
48       $this->editMode = true;
49       $this->Edit_Add = "add";
50       foreach($this->attributes as $atr){
51         $this->$atr = "";
52       }
53     }
55     if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
56       $this->editMode = true;
57       $this->Edit_Add = "edit";
58       $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
59       $tmp = $tmp[0];
60       foreach($this->attributes as $atr){
61         $this->$atr = "";
62       }
63       foreach($this->attributes as $atr){
64         if(isset($tmp[$atr])){
65           $this->$atr = $tmp[$atr];
66         }
67       }
68       $this->ID = $_POST['manufacturer'];
69     }
71     if(isset($_POST['close_manufacturer'])){
72       $this->editMode=false;
73     }
75     if(isset($_POST['save_manufacturer'])){
77       $tmp = array();
78       foreach($this->attributes as $attrs){
79         $tmp[$attrs]=$this->$attrs;
80       }
82       $allok = true;
83       if(empty($tmp['name'])){
84         print_red(_("Please specify a name."));
85         $allok = false;
86       }
88       if($allok){
89         if($this->Edit_Add == "add"){
90           $this->parent->handle->addEnterprise($tmp);
91           $this->editMode=false;
92         }else{
93           $this->parent->handle->updateEnterprise($tmp,$this->ID);
94           $this->editMode=false;
95         }
96       }
97     }
99     if($this->editMode == true){
100       $this->save_object();
101       foreach($this->attributes as $attrs){
102         $smarty->assign($attrs,$this->$attrs);
103       }
105       $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
106       return($display);
107     }
110     $smarty->assign("Manus",    $this->parent->handle->getEnterprises());
111     $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprises()));
112     $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
113     return($display);
114   }
116   /* Save to LDAP */
117   function save()
118   {
119   }
121   function save_object()
122   {
123     foreach($this->attributes as $attr){
124       if(isset($_POST[$attr])){
125         $this->$attr = $_POST[$attr];
126       }
127     }
128   }
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>