dolibarr  7.0.0-beta
contacts.tpl.php
1 <?php
2 /* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
3  * Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2015-2016 Charlie BENKE <charlie@patas-monkey.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * This template needs:
20  * $object
21  * $withproject (if we are on task contact)
22  */
23 
24 // Protection to avoid direct call of template
25 if (empty($object) || ! is_object($object))
26 {
27  print "Error, template page can't be called as URL";
28  exit;
29 }
30 
31 
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
34 
35 $module = $object->element;
36 
37 // Special cases
38 if ($module == 'propal') { $permission=$user->rights->propale->creer; }
39 elseif ($module == 'fichinter') { $permission=$user->rights->ficheinter->creer; }
40 elseif ($module == 'invoice_supplier') { $permission=$user->rights->fournisseur->facture->creer; }
41 elseif ($module == 'order_supplier') { $permission=$user->rights->fournisseur->commande->creer; }
42 elseif ($module == 'project') { $permission=$user->rights->projet->creer; }
43 elseif ($module == 'action') { $permission=$user->rights->agenda->myactions->create; }
44 elseif ($module == 'shipping') { $permission=$user->rights->expedition->creer; }
45 elseif ($module == 'project_task') { $permission=$user->rights->projet->creer; }
46 elseif (! isset($permission) && isset($user->rights->$module->creer))
47 {
48  $permission=$user->rights->$module->creer;
49 }
50 elseif (! isset($permission) && isset($user->rights->$module->write))
51 {
52  $permission=$user->rights->$module->write;
53 }
54 
55 $formcompany= new FormCompany($db);
56 $companystatic=new Societe($db);
57 $contactstatic=new Contact($db);
58 $userstatic=new User($db);
59 
60 ?>
61 
62 <!-- BEGIN PHP TEMPLATE CONTACTS -->
63 <div class="div-table-responsive">
64 <div class="tagtable centpercent noborder allwidth">
65 
66 <?php
67 if ($permission) {
68 ?>
69  <form class="tagtr liste_titre">
70  <div class="tagtd liste_titre"><?php echo $langs->trans("Nature"); ?></div>
71  <div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
72  <div class="tagtd liste_titre"><?php echo $langs->trans("Users").'/'.$langs->trans("Contacts"); ?></div>
73  <div class="tagtd liste_titre"><?php echo $langs->trans("ContactType"); ?></div>
74  <div class="tagtd liste_titre">&nbsp;</div>
75  <div class="tagtd liste_titre">&nbsp;</div>
76  </form>
77 
78  <?php
79 
80  $var=true;
81  if (empty($hideaddcontactforuser))
82  {
83 
84  ?>
85  <form class="tagtr impair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
86  <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
87  <input type="hidden" name="id" value="<?php echo $object->id; ?>" />
88  <input type="hidden" name="action" value="addcontact" />
89  <input type="hidden" name="source" value="internal" />
90  <?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
91  <div class="nowrap tagtd"><?php echo img_object('','user').' '.$langs->trans("Users"); ?></div>
92  <div class="tagtd"><?php echo $conf->global->MAIN_INFO_SOCIETE_NOM; ?></div>
93  <div class="tagtd maxwidthonsmartphone"><?php echo $form->select_dolusers($user->id, 'userid', 0, (! empty($userAlreadySelected)?$userAlreadySelected:null), 0, null, null, 0, 56); ?></div>
94  <div class="tagtd maxwidthonsmartphone">
95  <?php
96  $tmpobject=$object;
97  if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
98  echo $formcompany->selectTypeContact($tmpobject, '', 'type','internal');
99  ?></div>
100  <div class="tagtd">&nbsp;</div>
101  <div class="tagtd center"><input type="submit" class="button" value="<?php echo $langs->trans("Add"); ?>"></div>
102  </form>
103 
104  <?php
105  }
106 
107  if (empty($hideaddcontactforthirdparty))
108  {
109 
110  ?>
111 
112  <form class="tagtr pair" action="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id; ?>" method="POST">
113  <input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>" />
114  <input type="hidden" name="id" value="<?php echo $object->id; ?>" />
115  <input type="hidden" name="action" value="addcontact" />
116  <input type="hidden" name="source" value="external" />
117  <?php if ($withproject) print '<input type="hidden" name="withproject" value="'.$withproject.'">'; ?>
118  <div class="tagtd nowrap noborderbottom"><?php echo img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); ?></div>
119  <div class="tagtd nowrap maxwidthonsmartphone noborderbottom">
120  <?php $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->socid; ?>
121  <?php
122  // add company icon before select list
123  if ($selectedCompany)
124  {
125  echo img_object('', 'company', 'class="hideonsmartphone"');
126  }
127  ?>
128  <?php $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 'id', $selectedCompany, 'newcompany', '', 0); ?>
129  </div>
130  <div class="tagtd maxwidthonsmartphone noborderbottom">
131  <?php $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid', 0, '', '', 0, 'minwidth200'); ?>
132  </div>
133  <div class="tagtd maxwidthonsmartphone noborderbottom">
134  <?php
135  $tmpobject=$object;
136  if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
137  $formcompany->selectTypeContact($tmpobject, '', 'type','external'); ?>
138  </div>
139  <div class="tagtd noborderbottom">&nbsp;</div>
140  <div class="tagtd center noborderbottom">
141  <input type="submit" id="add-customer-contact" class="button" value="<?php echo $langs->trans("Add"); ?>"<?php if (! $nbofcontacts) echo ' disabled'; ?>>
142  </div>
143  </form>
144 
145 <?php
146  }
147 }
148 ?>
149 
150  <form class="tagtr liste_titre liste_titre_add formnoborder">
151  <div class="tagtd liste_titre"><?php echo $langs->trans("Nature"); ?></div>
152  <div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
153  <div class="tagtd liste_titre"><?php echo $langs->trans("Users").'/'.$langs->trans("Contacts"); ?></div>
154  <div class="tagtd liste_titre"><?php echo $langs->trans("ContactType"); ?></div>
155  <div class="tagtd liste_titre center"><?php echo $langs->trans("Status"); ?></div>
156  <div class="tagtd liste_titre">&nbsp;</div>
157  </form>
158 
159  <?php $var=true; ?>
160 
161  <?php
162  $arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts
163  foreach($arrayofsource as $source) {
164 
165  $tmpobject=$object;
166  if ($object->element == 'shipping' && is_object($objectsrc)) $tmpobject=$objectsrc;
167 
168  $tab = $tmpobject->liste_contact(-1,$source);
169  $num=count($tab);
170 
171  $i = 0;
172  while ($i < $num) {
173  $var = !$var;
174  ?>
175 
176  <form class="tagtr <?php echo $var?"pair":"impair"; ?>">
177  <div class="tagtd" align="left">
178  <?php if ($tab[$i]['source']=='internal') echo $langs->trans("User"); ?>
179  <?php if ($tab[$i]['source']=='external') echo $langs->trans("ThirdPartyContact"); ?>
180  </div>
181  <div class="tagtd" align="left">
182  <?php
183  if ($tab[$i]['socid'] > 0)
184  {
185  $companystatic->fetch($tab[$i]['socid']);
186  echo $companystatic->getNomUrl(1);
187  }
188  if ($tab[$i]['socid'] < 0)
189  {
190  echo $conf->global->MAIN_INFO_SOCIETE_NOM;
191  }
192  if (! $tab[$i]['socid'])
193  {
194  echo '&nbsp;';
195  }
196  ?>
197  </div>
198  <div class="tagtd">
199  <?php
200  $statusofcontact = $tab[$i]['status'];
201 
202  if ($tab[$i]['source']=='internal')
203  {
204  $userstatic->id=$tab[$i]['id'];
205  $userstatic->lastname=$tab[$i]['lastname'];
206  $userstatic->firstname=$tab[$i]['firstname'];
207  $userstatic->photo=$tab[$i]['photo'];
208  $userstatic->login=$tab[$i]['login'];
209  echo $userstatic->getNomUrl(-1);
210  }
211  if ($tab[$i]['source']=='external')
212  {
213  $contactstatic->id=$tab[$i]['id'];
214  $contactstatic->lastname=$tab[$i]['lastname'];
215  $contactstatic->firstname=$tab[$i]['firstname'];
216  echo $contactstatic->getNomUrl(1);
217  }
218  ?>
219  </div>
220  <div class="tagtd"><?php echo $tab[$i]['libelle']; ?></div>
221  <div class="tagtd center">
222  <?php //if ($object->statut >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">'; ?>
223  <?php
224  if ($tab[$i]['source']=='internal')
225  {
226  $userstatic->id=$tab[$i]['id'];
227  $userstatic->lastname=$tab[$i]['lastname'];
228  $userstatic->firstname=$tab[$i]['firstname'];
229  echo $userstatic->LibStatut($tab[$i]['statuscontact'],3);
230  }
231  if ($tab[$i]['source']=='external')
232  {
233  $contactstatic->id=$tab[$i]['id'];
234  $contactstatic->lastname=$tab[$i]['lastname'];
235  $contactstatic->firstname=$tab[$i]['firstname'];
236  echo $contactstatic->LibStatut($tab[$i]['statuscontact'],3);
237  }
238  ?>
239  <?php //if ($object->statut >= 0) echo '</a>'; ?>
240  </div>
241  <div class="tagtd nowrap right">
242  <?php if ($permission) { ?>
243  &nbsp;<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=deletecontact&amp;lineid='.$tab[$i]['rowid']; ?>"><?php echo img_delete(); ?></a>
244  <?php } ?>
245  </div>
246  </form>
247 
248 <?php $i++; ?>
249 <?php } } ?>
250 
251 </div>
252 </div>
253 <!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->
254 <?php
255  if (is_object($hookmanager))
256  {
257  $hookmanager->initHooks(array('contacttpl'));
258  $parameters=array();
259  $reshook=$hookmanager->executeHooks('formContactTpl',$parameters,$object,$action);
260  }
261 ?>
262 <!-- END PHP TEMPLATE CONTACTS -->
Class to manage contact/addresses.
Class to manage Dolibarr users.
Definition: user.class.php:39
if(empty($reshook)) $form
View.
Definition: perms.php:103
Class to build HTML component for third parties management Only common components are here...
Class to manage third parties objects (customers, suppliers, prospects...)
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:104
print
Draft customers invoices.
Definition: index.php:91
type
Definition: viewcat.php:283