aeedaa4d2ddc07d2098f576214f4c810be8b8359
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 $smarty = get_smarty();
40 $display = "";
42 if((isset($_POST['remove_manu']))&&(isset($_POST['manufacturer']))){
43 $this->parent->handle->removeEnterprisesType($_POST['manufacturer']);
44 }
46 if(isset($_POST['add_manu'])){
47 $this->editMode = true;
48 $this->Edit_Add = "add";
49 foreach($this->attributes as $atr){
50 $this->$atr = "";
51 }
52 }
54 if((isset($_POST['edit_manu']))&&(isset($_POST['manufacturer']))){
55 $this->editMode = true;
56 $this->Edit_Add = "edit";
57 $tmp = $this->parent->handle->getEnterprise($_POST['manufacturer']);
58 $tmp = $tmp[0];
59 foreach($this->attributes as $atr){
60 $this->$atr = "";
61 }
62 foreach($this->attributes as $atr){
63 if(isset($tmp[$atr])){
64 $this->$atr = $tmp[$atr];
65 }
66 }
67 $this->ID = $_POST['manufacturer'];
68 }
70 if(isset($_POST['close_manufacturer'])){
71 $this->editMode=false;
72 }
74 if(isset($_POST['save_manufacturer'])){
76 $tmp = array();
77 foreach($this->attributes as $attrs){
78 $tmp[$attrs]=$this->$attrs;
79 }
81 $allok = true;
82 if(empty($tmp['name'])){
83 print_red(_("Please specify a name."));
84 $allok = false;
85 }
87 if($allok){
88 if($this->Edit_Add == "add"){
89 $this->parent->handle->addEnterprisesType($tmp);
90 $this->editMode=false;
91 }else{
92 $this->parent->handle->updateEnterprisesType($tmp,$this->ID);
93 $this->editMode=false;
94 }
95 }
96 }
98 if($this->editMode == true){
99 $this->save_object();
100 foreach($this->attributes as $attrs){
101 $smarty->assign($attrs,$this->$attrs);
102 }
104 $display.= $smarty->fetch(get_template_path('glpiManufacturerAdd.tpl', TRUE));
105 return($display);
106 }
109 $smarty->assign("Manus", $this->parent->handle->getEnterprisesTypes());
110 $smarty->assign("ManuKeys", array_flip($this->parent->handle->getEnterprisesTypes()));
111 $display.= $smarty->fetch(get_template_path('glpiManufacturer.tpl', TRUE));
112 return($display);
113 }
115 /* Save to LDAP */
116 function save()
117 {
118 }
120 function save_object()
121 {
122 foreach($this->attributes as $attr){
123 if(isset($_POST[$attr])){
124 $this->$attr = $_POST[$attr];
125 }
126 }
127 }
129 }
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>