-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
categorie.php
733 lines (610 loc) · 23 KB
/
categorie.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/categories/categorie.php
* \ingroup category
* \brief Page to show category tab
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$langs->load("categories");
$langs->load("products");
$socid = GETPOST('socid','int');
$id = GETPOST('id','int');
$ref = GETPOST('ref');
$type = GETPOST('type');
$removecat = GETPOST('removecat','int');
$parent=GETPOST('parent','int');
$dbtablename = '';
// For categories on third parties
if (! empty($socid)) $id = $socid;
if (! isset($type)) $type = 0;
if ($type == 1 || $type == 2) $socid = $id;
if ($id || $ref)
{
if ($type == 0) {
$elementtype = 'product';
$objecttype = 'produit|service&categorie';
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
$dbtablename = 'product';
$fieldid = isset($ref)?'ref':'rowid';
}
elseif ($type == 1) {
$elementtype = 'fournisseur';
$objecttype = 'societe&categorie';
$objectid = isset($id)?$id:(isset($socid)?$socid:'');
$dbtablename = '&societe';
$fieldid = 'rowid';
}
elseif ($type == 2) {
$elementtype = 'societe';
$objecttype = 'societe&categorie';
$objectid = isset($id)?$id:(isset($socid)?$socid:'');
$dbtablename = '&societe';
$fieldid = 'rowid';
}
elseif ($type == 3) {
$elementtype = 'member';
$objecttype = 'adherent&categorie';
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
$dbtablename = 'adherent';
$fieldid = ! empty($ref)?'ref':'rowid';
}
elseif ($type == 4) {
$elementtype = 'societe';
$objecttype = 'contact';
$objectid = isset($id)?$id:(isset($ref)?$ref:'');
$dbtablename = 'socpeople&societe';
$fieldid = ! empty($ref)?'ref':'rowid';
}
}
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid);
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard'));
/*
* Actions
*/
$parameters=array('id'=>$socid);
$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
$error=$hookmanager->error; $errors=array_merge($errors, (array) $hookmanager->errors);
if (empty($reshook))
{
// Remove element from category
if ($removecat > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
$object = new Fournisseur($db);
$result = $object->fetch($objectid);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'societe';
}
if ($type == 3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
if ($type == 4 && $user->rights->societe->creer)
{
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$object = new Contact($db);
$result = $object->fetch($objectid);
$elementtype = 'contact';
}
$cat = new Categorie($db);
$result=$cat->fetch($removecat);
$result=$cat->del_type($object,$elementtype);
if ($result < 0)
{
setEventMessage($cat->error,'errors');
setEventMessage($cat->errors,'errors');
}
}
// Add object into a category
if ($parent > 0)
{
if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer))
{
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$object = new Product($db);
$result = $object->fetch($id, $ref);
$elementtype = 'product';
}
if ($type==1 && $user->rights->societe->creer)
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
$object = new Fournisseur($db);
$result = $object->fetch($objectid);
$elementtype = 'fournisseur';
}
if ($type==2 && $user->rights->societe->creer)
{
$object = new Societe($db);
$result = $object->fetch($objectid);
$elementtype = 'societe';
}
if ($type==3 && $user->rights->adherent->creer)
{
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$object = new Adherent($db);
$result = $object->fetch($objectid);
$elementtype = 'member';
}
if ($type == 4 && $user->rights->societe->creer)
{
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
$object = new Contact($db);
$result = $object->fetch($objectid);
$elementtype = 'contact';
}
$cat = new Categorie($db);
$result=$cat->fetch($parent);
$result=$cat->add_type($object,$elementtype);
if ($result >= 0)
{
setEventMessage($langs->trans("WasAddedSuccessfully",$cat->label));
}
else
{
if ($cat->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
setEventMessage($langs->trans("ObjectAlreadyLinkedToCategory"),'warnings');
}
else
{
setEventMessage($cat->error,'errors');
setEventMessage($cat->errors,'errors');
}
}
}
}
/*
* View
*/
$form = new Form($db);
/*
* Fiche categorie de client et/ou fournisseur
*/
if ($socid)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$langs->load("companies");
if (! empty($conf->notification->enabled)) $langs->load("mails");
$soc = new Societe($db);
$result = $soc->fetch($socid);
llxHeader("","",$langs->trans("Category"));
// Show tabs
$head = societe_prepare_head($soc);
dol_fiche_head($head, 'category', $langs->trans("ThirdParty"),0,'company');
print '<table class="border" width="100%">';
print '<tr><td width="25%">'.$langs->trans("ThirdPartyName").'</td><td colspan="3">';
print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom','','&type='.$type);
print '</td></tr>';
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
{
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>';
}
if ($soc->client)
{
print '<tr><td>';
print $langs->trans('CustomerCode').'</td><td colspan="3">';
print $soc->code_client;
if ($soc->check_codeclient() <> 0) print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
print '</td></tr>';
}
if ($soc->fournisseur)
{
print '<tr><td>';
print $langs->trans('SupplierCode').'</td><td colspan="3">';
print $soc->code_fournisseur;
if ($soc->check_codefournisseur() <> 0) print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
print '</td></tr>';
}
if (! empty($conf->barcode->enabled))
{
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->barcode.'</td></tr>';
}
// Address
print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3">';
print dol_print_address($soc->address,'gmap','thirdparty',$object->id);
print '</td></tr>';
// Zip / Town
print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->zip."</td>";
print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->town."</td></tr>";
// Country
if ($soc->country)
{
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
$img=picto_from_langcode($soc->country_code);
print ($img?$img.' ':'');
print $soc->country;
print '</td></tr>';
}
// EMail
print '<tr><td>'.$langs->trans('EMail').'</td><td colspan="3">';
print dol_print_email($soc->email,0,$soc->id,'AC_EMAIL');
print '</td></tr>';
// Web
print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3">';
print dol_print_url($soc->url);
print '</td></tr>';
// Phone
print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dol_print_phone($soc->phone,$soc->country_code,0,$soc->id,'AC_TEL').'</td>';
print '<td>'.$langs->trans('Fax').'</td><td>'.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'</td></tr>';
print '</table>';
dol_fiche_end();
if ($soc->client) formCategory($db,$soc,2,$socid,$user->rights->societe->creer);
if ($soc->client && $soc->fournisseur) print '<br><br>';
if ($soc->fournisseur) formCategory($db,$soc,1,$socid,$user->rights->societe->creer);
}
else if ($id || $ref)
{
if ($type == 0)
{
$langs->load("products");
/*
* Category card for product
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
// Product
$product = new Product($db);
$result = $product->fetch($id, $ref);
llxHeader("","",$langs->trans("CardProduct".$product->type));
$head=product_prepare_head($product, $user);
$titre=$langs->trans("CardProduct".$product->type);
$picto=($product->type==1?'service':'product');
dol_fiche_head($head, 'category', $titre,0,$picto);
print '<table class="border" width="100%">';
// Ref
print "<tr>";
print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($product,'ref','',1,'ref');
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>';
// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')</td><td>';
print $product->getLibStatut(2,0);
print '</td></tr>';
// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')</td><td>';
print $product->getLibStatut(2,1);
print '</td></tr>';
print '</table>';
dol_fiche_end();
formCategory($db,$product,0,$socid,($user->rights->produit->creer || $user->rights->service->creer));
}
if ($type == 3)
{
$langs->load("members");
/*
* Category card for member
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
// Produit
$member = new Adherent($db);
$result = $member->fetch($id, $ref);
$membert = new AdherentType($db);
$membert->fetch($member->typeid);
llxHeader("","",$langs->trans("Member"));
$head=member_prepare_head($member, $user);
$titre=$langs->trans("Member");
$picto='user';
dol_fiche_head($head, 'category', $titre,0,$picto);
$rowspan=5;
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan+=1;
if (! empty($conf->societe->enabled)) $rowspan++;
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td class="valeur">';
print $form->showrefnav($member,'id');
print '</td></tr>';
// Login
if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED))
{
print '<tr><td>'.$langs->trans("Login").' / '.$langs->trans("Id").'</td><td class="valeur">'.$member->login.' </td></tr>';
}
// Morphy
print '<tr><td>'.$langs->trans("Nature").'</td><td class="valeur" >'.$member->getmorphylib().'</td>';
/*print '<td rowspan="'.$rowspan.'" align="center" valign="middle" width="25%">';
print $form->showphoto('memberphoto',$member);
print '</td>';*/
print '</tr>';
// Type
print '<tr><td>'.$langs->trans("Type").'</td><td class="valeur">'.$membert->getNomUrl(1)."</td></tr>\n";
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td class="valeur">'.$member->societe.'</td></tr>';
// Civility
print '<tr><td>'.$langs->trans("UserTitle").'</td><td class="valeur">'.$member->getCivilityLabel().' </td>';
print '</tr>';
// Lastname
print '<tr><td>'.$langs->trans("Lastname").'</td><td class="valeur">'.$member->lastname.' </td>';
print '</tr>';
// Firstname
print '<tr><td>'.$langs->trans("Firstname").'</td><td class="valeur">'.$member->firstname.' </td>';
print '</tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td class="valeur">'.$member->getLibStatut(4).'</td></tr>';
print '</table>';
dol_fiche_end();
formCategory($db,$member,3,0,$user->rights->adherent->creer);
}
if ($type == 4)
{
$langs->load("contact");
/*
* Category card for contact
*/
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
// Produit
$object = new Contact($db);
$result = $object->fetch($id, $ref);
$object->fetch_thirdparty();
llxHeader("","",$langs->trans("Contact"));
$head=contact_prepare_head($object, $user);
$titre=$langs->trans("ContactsAddresses");
$picto='contact';
dol_fiche_head($head, 'category', $titre,0,$picto);
$rowspan=5;
if (! empty($conf->societe->enabled)) $rowspan++;
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
print '<td class="valeur">';
print $form->showrefnav($object,'rowid');
print '</td></tr>';
// Name
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
// Company
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
{
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
if (!empty($object->thirdparty->id))
{
print $object->thirdparty->getNomUrl(1);
}
else
{
print $langs->trans("ContactNotLinkedToCompany");
}
print '</td></tr>';
}
// Civility
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">';
print $object->getCivilityLabel();
print '</td></tr>';
// Role
print '<tr><td>'.$langs->trans("PostOrFunction").'</td><td colspan="3">'.$object->poste.'</td>';
// Address
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3">';
dol_print_address($object->address,'gmap','contact',$object->id);
print '</td></tr>';
// Zip/Town
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3">';
print $object->zip;
if ($object->zip) print ' ';
print $object->town.'</td></tr>';
// Country
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="3">';
$img=picto_from_langcode($object->country_code);
if ($img) print $img.' ';
print $object->country;
print '</td></tr>';
// State
if (empty($conf->global->SOCIETE_DISABLE_STATE))
{
print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$object->state.'</td>';
}
// Phone
print '<tr><td>'.$langs->trans("PhonePro").'</td><td>'.dol_print_phone($object->phone_pro,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>';
print '<td>'.$langs->trans("PhonePerso").'</td><td>'.dol_print_phone($object->phone_perso,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td></tr>';
print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td>'.dol_print_phone($object->phone_mobile,$object->country_code,$object->id,$object->socid,'AC_TEL').'</td>';
print '<td>'.$langs->trans("Fax").'</td><td>'.dol_print_phone($object->fax,$object->country_code,$object->id,$object->socid,'AC_FAX').'</td></tr>';
// Email
print '<tr><td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email,$object->id,$object->socid,'AC_EMAIL').'</td>';
if (! empty($conf->mailing->enabled))
{
$langs->load("mails");
print '<td class="nowrap">'.$langs->trans("NbOfEMailingsReceived").'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/mailing/liste.php?filteremail='.urlencode($object->email).'">'.$object->getNbOfEMailings().'</a></td>';
}
else
{
print '<td colspan="2"> </td>';
}
print '</tr>';
// Instant message and no email
print '<tr><td>'.$langs->trans("IM").'</td><td>'.$object->jabberid.'</td>';
if (!empty($conf->mailing->enabled))
{
print '<td>'.$langs->trans("No_Email").'</td><td>'.yn($object->no_email).'</td>';
}
else
{
print '<td colspan="2"> </td>';
}
print '</tr>';
print '<tr><td>'.$langs->trans("ContactVisibility").'</td><td colspan="3">';
print $object->LibPubPriv($object->priv);
print '</td></tr>';
// Note Public
print '<tr><td valign="top">'.$langs->trans("NotePublic").'</td><td colspan="3">';
print nl2br($object->note_public);
print '</td></tr>';
// Note Private
print '<tr><td valign="top">'.$langs->trans("NotePrivate").'</td><td colspan="3">';
print nl2br($object->note_private);
print '</td></tr>';
// Other attributes
$parameters=array('socid'=>$socid, 'colspan' => ' colspan="3"');
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if (empty($reshook) && ! empty($extrafields->attribute_label))
{
print $object->showOptionals($extrafields);
}
print '</table>';
dol_fiche_end();
formCategory($db,$object,4,$socid, $user->rights->societe->creer);
}
}
/**
* Function to output a form to add object into a category
*
* @param DoliDb $db Database handler
* @param Object $object Object we want to see categories it can be classified into
* @param int $typeid Type of category (0, 1, 2, 3)
* @param int $socid Id thirdparty
* @param string $showclassifyform 1=Add form to 'Classify', 0=Do not show form to 'Classify'
* @return int 0
*/
function formCategory($db,$object,$typeid,$socid=0,$showclassifyform=1)
{
global $user,$langs,$form,$bc;
if ($typeid == 0) $title = $langs->trans("ProductsCategoriesShort");
if ($typeid == 1) $title = $langs->trans("SuppliersCategoriesShort");
if ($typeid == 2) $title = $langs->trans("CustomersProspectsCategoriesShort");
if ($typeid == 3) $title = $langs->trans("MembersCategoriesShort");
if ($typeid == 4) $title = $langs->trans("ContactCategoriesShort");
print '<br>';
print_fiche_titre($title,'','');
// Form to add record into a category
if ($showclassifyform)
{
print '<form method="post" action="'.DOL_URL_ROOT.'/categories/categorie.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="typeid" value="'.$typeid.'">';
print '<input type="hidden" name="type" value="'.$typeid.'">';
print '<input type="hidden" name="id" value="'.$object->id.'">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td width="40%">';
print $langs->trans("ClassifyInCategory").' ';
print $form->select_all_categories($typeid,'auto');
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans("Classify").'"></td>';
if ($user->rights->categorie->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/categories/fiche.php?action=create&origin='.$object->id.'&type='.$typeid.'&urlfrom='.urlencode($_SERVER["PHP_SELF"].'?'.(($typeid==1||$typeid==2)?'socid':'id').'='.$object->id.'&type='.$typeid).'">';
print $langs->trans("CreateCat").' ';
print img_picto($langs->trans("Create"),'filenew');
print "</a>";
print '</td>';
}
print '</tr>';
print '</table>';
print '</form>';
print '<br>';
}
$c = new Categorie($db);
$cats = $c->containing($object->id,$typeid);
if (count($cats) > 0)
{
if ($typeid == 0) $title=$langs->trans("ProductIsInCategories");
if ($typeid == 1) $title=$langs->trans("CompanyIsInSuppliersCategories");
if ($typeid == 2) $title=$langs->trans("CompanyIsInCustomersCategories");
if ($typeid == 3) $title=$langs->trans("MemberIsInCategories");
if ($typeid == 4) $title=$langs->trans("ContactIsInCategories");
print "\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$title.':</td></tr>';
$var = true;
foreach ($cats as $cat)
{
$ways = $cat->print_all_ways();
foreach ($ways as $way)
{
$var = ! $var;
print "<tr ".$bc[$var].">";
// Categorie
print "<td>";
//$c->id=;
//print $c->getNomUrl(1);
print img_object('','category').' '.$way."</td>";
// Link to delete from category
print '<td align="right">';
$permission=0;
if ($typeid == 0) $permission=($user->rights->produit->creer || $user->rights->service->creer);
if ($typeid == 1) $permission=$user->rights->societe->creer;
if ($typeid == 2) $permission=$user->rights->societe->creer;
if ($typeid == 3) $permission=$user->rights->adherent->creer;
if ($typeid == 4) $permission=$user->rights->societe->creer;
if ($permission)
{
print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid)?'id':'socid')."=".$object->id."&type=".$typeid."&removecat=".$cat->id."'>";
print img_delete($langs->trans("DeleteFromCat")).' ';
print $langs->trans("DeleteFromCat")."</a>";
}
else
{
print ' ';
}
print "</td>";
print "</tr>\n";
}
}
print "</table>\n";
}
else if ($cats < 0)
{
print $langs->trans("ErrorUnknown");
}
else
{
if ($typeid == 0) $title=$langs->trans("ProductHasNoCategory");
if ($typeid == 1) $title=$langs->trans("CompanyHasNoCategory");
if ($typeid == 2) $title=$langs->trans("CompanyHasNoCategory");
if ($typeid == 3) $title=$langs->trans("MemberHasNoCategory");
if ($typeid == 4) $title=$langs->trans("ContactHasNoCategory");
print $title;
print "<br/>";
}
return 0;
}
llxFooter();
$db->close();