47 |
|
|
48 |
// Creation user |
// Creation user |
49 |
$nuser = new User($db); |
$nuser = new User($db); |
50 |
$nuser->nom = $contact->nom; |
$nuser->nom = $contact->name; |
51 |
$nuser->prenom = $contact->prenom; |
$nuser->prenom = $contact->firstname; |
52 |
$nuser->create_from_contact($contact); |
$nuser->create_from_contact($contact); |
53 |
} |
} |
54 |
|
|
55 |
if ($_POST["action"] == 'add') |
if ($_POST["action"] == 'add') |
56 |
{ |
{ |
57 |
|
$contact = new Contact($db); |
58 |
|
|
59 |
|
$contact->socid = $_POST["socid"]; |
60 |
|
|
61 |
|
$contact->name = $_POST["name"]; |
62 |
|
$contact->firstname = $_POST["firstname"]; |
63 |
|
$contact->civilite_id = $_POST["civilite_id"]; |
64 |
|
$contact->poste = $_POST["poste"]; |
65 |
|
$contact->address = $_POST["address"]; |
66 |
|
$contact->cp = $_POST["cp"]; |
67 |
|
$contact->ville = $_POST["ville"]; |
68 |
|
$contact->fk_pays = $_POST["pays_id"]; |
69 |
|
$contact->email = $_POST["email"]; |
70 |
|
$contact->phone_pro = $_POST["phone_pro"]; |
71 |
|
$contact->phone_perso = $_POST["phone_perso"]; |
72 |
|
$contact->phone_mobile = $_POST["phone_mobile"]; |
73 |
|
$contact->fax = $_POST["fax"]; |
74 |
|
$contact->jabberid = $_POST["jabberid"]; |
75 |
|
|
76 |
|
$contact->note = $_POST["note"]; |
77 |
|
|
78 |
if (! $_POST["name"]) |
if (! $_POST["name"]) |
79 |
{ |
{ |
80 |
array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Lastname"))); |
array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Lastname"))); |
81 |
$_GET["action"]="create"; |
$_GET["action"]="create"; |
82 |
} |
} |
83 |
|
/* |
84 |
if (! $_POST["firstname"]) |
if (! $_POST["firstname"]) |
85 |
{ |
{ |
86 |
array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Firstname"))); |
array_push($error,$langs->trans("ErrorFieldRequired",$langs->trans("Firstname"))); |
87 |
$_GET["action"]="create"; |
$_GET["action"]="create"; |
88 |
} |
} |
89 |
|
*/ |
90 |
if ($_POST["name"] && $_POST["firstname"]) |
if ($_POST["name"] && $_POST["firstname"]) |
91 |
{ |
{ |
|
$contact = new Contact($db); |
|
|
|
|
|
$contact->socid = $_POST["socid"]; |
|
|
|
|
|
$contact->name = $_POST["name"]; |
|
|
$contact->firstname = $_POST["firstname"]; |
|
|
$contact->civilite_id = $_POST["civilite_id"]; |
|
|
$contact->poste = $_POST["poste"]; |
|
|
$contact->address = $_POST["address"]; |
|
|
$contact->cp = $_POST["cp"]; |
|
|
$contact->ville = $_POST["ville"]; |
|
|
$contact->fk_pays = $_POST["pays_id"]; |
|
|
$contact->email = $_POST["email"]; |
|
|
$contact->phone_pro = $_POST["phone_pro"]; |
|
|
$contact->phone_perso = $_POST["phone_perso"]; |
|
|
$contact->phone_mobile = $_POST["phone_mobile"]; |
|
|
$contact->fax = $_POST["fax"]; |
|
|
$contact->jabberid = $_POST["jabberid"]; |
|
|
|
|
|
$contact->note = $_POST["note"]; |
|
|
|
|
92 |
$id = $contact->create($user); |
$id = $contact->create($user); |
93 |
if ($id > 0) |
if ($id > 0) |
94 |
{ |
{ |
95 |
Header("Location: fiche.php?id=".$id); |
Header("Location: fiche.php?id=".$id); |
96 |
|
exit; |
97 |
} |
} |
98 |
|
|
99 |
$error=array($contact->error); |
$error=array($contact->error); |
110 |
$result = $contact->delete($_GET["id"]); |
$result = $contact->delete($_GET["id"]); |
111 |
|
|
112 |
Header("Location: index.php"); |
Header("Location: index.php"); |
113 |
|
exit; |
114 |
} |
} |
115 |
|
|
116 |
|
|
124 |
$contact->socid = $_POST["socid"]; |
$contact->socid = $_POST["socid"]; |
125 |
$contact->name = $_POST["name"]; |
$contact->name = $_POST["name"]; |
126 |
$contact->firstname = $_POST["firstname"]; |
$contact->firstname = $_POST["firstname"]; |
127 |
$contact->civilite_id = $_POST["civilite_id"]; |
$contact->civilite_id = $_POST["civilite_id"]; |
128 |
$contact->poste = $_POST["poste"]; |
$contact->poste = $_POST["poste"]; |
129 |
|
|
130 |
$contact->address = $_POST["address"]; |
$contact->address = $_POST["address"]; |
160 |
|
|
161 |
if ($socid) |
if ($socid) |
162 |
{ |
{ |
163 |
$objsoc = new Societe($db); |
$objsoc = new Societe($db); |
164 |
$objsoc->fetch($socid); |
$objsoc->fetch($socid); |
|
} |
|
|
|
|
|
// Affiche les erreurs |
|
|
if (sizeof($error)) |
|
|
{ |
|
|
print "<div class='error'>"; |
|
|
print join("<br>",$error); |
|
|
print "</div>\n"; |
|
165 |
} |
} |
166 |
|
|
167 |
|
|
170 |
*/ |
*/ |
171 |
if ($_GET["id"] > 0) |
if ($_GET["id"] > 0) |
172 |
{ |
{ |
173 |
// Si edition contact deja existant |
// Si edition contact deja existant |
174 |
|
$contact = new Contact($db); |
175 |
$contact = new Contact($db); |
$return=$contact->fetch($_GET["id"], $user); |
176 |
$return=$contact->fetch($_GET["id"], $user); |
if ($return < 0) |
177 |
if ($return < 0) { |
{ |
178 |
dolibarr_print_error('',$contact->error); |
dolibarr_print_error('',$contact->error); |
179 |
} |
} |
180 |
|
|
181 |
$h=0; |
$h=0; |
182 |
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; |
$head[$h][0] = DOL_URL_ROOT.'/contact/fiche.php?id='.$_GET["id"]; |
183 |
$head[$h][1] = $langs->trans("General"); |
$head[$h][1] = $langs->trans("General"); |
184 |
$hselected=$h; |
$hselected=$h; |
185 |
$h++; |
$h++; |
186 |
|
|
187 |
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; |
$head[$h][0] = DOL_URL_ROOT.'/contact/perso.php?id='.$_GET["id"]; |
188 |
$head[$h][1] = $langs->trans("PersonalInformations"); |
$head[$h][1] = $langs->trans("PersonalInformations"); |
189 |
$h++; |
$h++; |
190 |
|
|
191 |
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; |
$head[$h][0] = DOL_URL_ROOT.'/contact/exportimport.php?id='.$_GET["id"]; |
192 |
$head[$h][1] = $langs->trans("ExportImport"); |
$head[$h][1] = $langs->trans("ExportImport"); |
193 |
$h++; |
$h++; |
194 |
|
|
195 |
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; |
$head[$h][0] = DOL_URL_ROOT.'/contact/info.php?id='.$_GET["id"]; |
196 |
$head[$h][1] = $langs->trans("Info"); |
$head[$h][1] = $langs->trans("Info"); |
197 |
$h++; |
$h++; |
198 |
|
|
199 |
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); |
dolibarr_fiche_head($head, $hselected, $langs->trans("Contact").": ".$contact->firstname.' '.$contact->name); |
200 |
} |
} |
201 |
|
|
202 |
|
|
206 |
*/ |
*/ |
207 |
if ($_GET["action"] == 'delete') |
if ($_GET["action"] == 'delete') |
208 |
{ |
{ |
209 |
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Źtes-vous sūr de vouloir supprimer ce contact ?","confirm_delete"); |
$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"],"Supprimer le contact","Źtes-vous sūr de vouloir supprimer ce contact ?","confirm_delete"); |
210 |
print '<br>'; |
print '<br>'; |
211 |
} |
} |
212 |
|
|
213 |
if ($_GET["action"] == 'create') |
if ($_GET["action"] == 'create') |
217 |
* |
* |
218 |
*/ |
*/ |
219 |
print_fiche_titre($langs->trans("AddContact")); |
print_fiche_titre($langs->trans("AddContact")); |
|
print '<br>'; |
|
220 |
|
|
221 |
|
// Affiche les erreurs |
222 |
|
if (sizeof($error)) |
223 |
|
{ |
224 |
|
print "<div class='error'>"; |
225 |
|
print join("<br>",$error); |
226 |
|
print "</div>\n"; |
227 |
|
} |
228 |
|
|
229 |
|
print '<br>'; |
230 |
print '<form method="post" action="fiche.php">'; |
print '<form method="post" action="fiche.php">'; |
231 |
print '<input type="hidden" name="action" value="add">'; |
print '<input type="hidden" name="action" value="add">'; |
232 |
print '<table class="border" width="100%">'; |
print '<table class="border" width="100%">'; |
251 |
print '</td></tr>'; |
print '</td></tr>'; |
252 |
} |
} |
253 |
|
|
254 |
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">'; |
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; |
255 |
print $form->select_civilite($obj->civilite); |
print $form->select_civilite($contact->civilite_id); |
256 |
print '</td></tr>'; |
print '</td></tr>'; |
257 |
|
|
258 |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td width="35%"><input name="name" type="text" size="20" maxlength="80" value="'.$contact->nom.'"></td>'; |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>'; |
259 |
print '<td width="15%">'.$langs->trans("Firstname").'</td><td width="35%"><input name="firstname" type="text" size="15" maxlength="80" value="'.$contact->prenom.'"></td></tr>'; |
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="15" maxlength="80" value="'.$contact->firstname.'"></td></tr>'; |
260 |
|
|
261 |
print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td>'; |
print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td>'; |
262 |
|
|
263 |
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><input name="address" type="text" size="50" maxlength="80"></td>'; |
print '<tr><td>'.$langs->trans("Address").'</td><td colspan="3"><input name="address" type="text" size="50" maxlength="80" value="'.$contact->address.'"></td>'; |
264 |
|
|
265 |
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'"> '; |
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td colspan="3"><input name="cp" type="text" size="6" maxlength="80" value="'.$contact->cp.'"> '; |
266 |
print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>'; |
print '<input name="ville" type="text" size="20" value="'.$contact->ville.'" maxlength="80"></td></tr>'; |
273 |
print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>'; |
print '<td>Tel Perso</td><td><input name="phone_perso" type="text" size="18" maxlength="80" value="'.$contact->phone_perso.'"></td></tr>'; |
274 |
|
|
275 |
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>'; |
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>'; |
276 |
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80"></td></tr>'; |
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>'; |
277 |
|
|
278 |
print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>'; |
print '<tr><td>'.$langs->trans("Email").'</td><td colspan="3"><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td></tr>'; |
279 |
|
|
280 |
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>'; |
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>'; |
281 |
|
|
282 |
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3"><textarea name="note" cols="60" rows="3"></textarea></td></tr>'; |
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="note"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.$contact->note.'</textarea></td></tr>'; |
283 |
|
|
284 |
print '<tr><td>'.$langs->trans("BillingContact").'</td><td colspan="3">'; |
print '<tr><td>'.$langs->trans("BillingContact").'</td><td colspan="3">'; |
285 |
print $form->selectyesno("facturation",$contact->facturation); |
print $form->selectyesno("facturation",$contact->facturation); |
290 |
|
|
291 |
print "</form>"; |
print "</form>"; |
292 |
} |
} |
293 |
elseif ($_GET["action"] == 'edit') |
elseif ($_GET["action"] == 'edit' && $_GET["id"]) |
294 |
{ |
{ |
295 |
/* |
/* |
296 |
* Fiche en mode edition |
* Fiche en mode edition |
297 |
* |
* |
298 |
*/ |
*/ |
299 |
|
|
300 |
|
// Affiche les erreurs |
301 |
|
if (sizeof($error)) |
302 |
|
{ |
303 |
|
print "<div class='error'>"; |
304 |
|
print join("<br>",$error); |
305 |
|
print "</div>\n"; |
306 |
|
} |
307 |
|
|
308 |
print '<form method="post" action="fiche.php?id='.$_GET["id"].'">'; |
print '<form method="post" action="fiche.php?id='.$_GET["id"].'">'; |
309 |
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; |
print '<input type="hidden" name="id" value="'.$_GET["id"].'">'; |
310 |
print '<input type="hidden" name="action" value="update">'; |
print '<input type="hidden" name="action" value="update">'; |
318 |
$objsoc = new Societe($db); |
$objsoc = new Societe($db); |
319 |
$objsoc->fetch($contact->socid); |
$objsoc->fetch($contact->socid); |
320 |
|
|
321 |
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->nom_url.'</td></tr>'; |
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->nom_url.'</td></tr>'; |
322 |
} |
} |
323 |
else |
else |
324 |
{ |
{ |
325 |
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'; |
print '<tr><td width="15%">'.$langs->trans("Company").'</td><td colspan="3">'; |
326 |
print $langs->trans("ContactNotLinkedToCompany"); |
print $langs->trans("ContactNotLinkedToCompany"); |
327 |
print '</td></tr>'; |
print '</td></tr>'; |
328 |
} |
} |
330 |
print $form->select_civilite($contact->civilite_id); |
print $form->select_civilite($contact->civilite_id); |
331 |
print '</td></tr>'; |
print '</td></tr>'; |
332 |
|
|
333 |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td width="35%"><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>'; |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td><input name="name" type="text" size="20" maxlength="80" value="'.$contact->name.'"></td>'; |
334 |
print '<td width="15%">'.$langs->trans("Firstname").'</td><td width="35%"><input name="firstname" type="text" size="15" maxlength="80" value="'.$contact->firstname.'"></td></tr>'; |
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%"><input name="firstname" type="text" size="20" maxlength="80" value="'.$contact->firstname.'"></td></tr>'; |
335 |
|
|
336 |
print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td></tr>'; |
print '<tr><td>Poste/Fonction</td><td colspan="3"><input name="poste" type="text" size="50" maxlength="80" value="'.$contact->poste.'"></td></tr>'; |
337 |
|
|
350 |
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>'; |
print '<tr><td>Portable</td><td><input name="phone_mobile" type="text" size="18" maxlength="80" value="'.$contact->phone_mobile.'"></td>'; |
351 |
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>'; |
print '<td>'.$langs->trans("Fax").'</td><td><input name="fax" type="text" size="18" maxlength="80" value="'.$contact->fax.'"></td></tr>'; |
352 |
|
|
353 |
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="50" maxlength="80" value="'.$contact->email.'"></td>'; |
print '<tr><td>'.$langs->trans("EMail").'</td><td><input name="email" type="text" size="40" maxlength="80" value="'.$contact->email.'"></td>'; |
354 |
if ($conf->mailing->enabled) |
if ($conf->mailing->enabled) |
355 |
{ |
{ |
356 |
$langs->load("mails"); |
$langs->load("mails"); |
363 |
} |
} |
364 |
print '</tr>'; |
print '</tr>'; |
365 |
|
|
366 |
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="50" maxlength="80" value="'.$contact->jabberid.'"></td></tr>'; |
print '<tr><td>Jabberid</td><td colspan="3"><input name="jabberid" type="text" size="40" maxlength="80" value="'.$contact->jabberid.'"></td></tr>'; |
367 |
|
|
368 |
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3">'; |
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; |
369 |
print '<textarea name="note" cols="60" rows="3">'; |
print '<textarea name="note" cols="70" rows="'.ROWS_3.'">'; |
370 |
print $contact->note; |
print $contact->note; |
371 |
print '</textarea></td></tr>'; |
print '</textarea></td></tr>'; |
372 |
|
|
384 |
|
|
385 |
print "</form>"; |
print "</form>"; |
386 |
} |
} |
387 |
else |
elseif ($_GET["id"]) |
388 |
{ |
{ |
389 |
/* |
/* |
390 |
* Fiche en mode visualisation |
* Fiche en mode visualisation |
407 |
print '</td></tr>'; |
print '</td></tr>'; |
408 |
} |
} |
409 |
|
|
410 |
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">'; |
print '<tr><td width="15%">'.$langs->trans("UserTitle").'</td><td colspan="3">'; |
411 |
//TODO Aller chercher le libellé de la civilite a partir de l'id $contact->civilite_id |
print $form->civilite_name($contact->civilite_id); |
|
//print '<tr><td valign="top">Titre : '.$contact->civilite."<br>"; |
|
|
print $contact->civilite_id; |
|
412 |
print '</td></tr>'; |
print '</td></tr>'; |
413 |
|
|
414 |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td width="35%">'.$contact->name.'</td>'; |
print '<tr><td width="15%">'.$langs->trans("Lastname").'</td><td>'.$contact->name.'</td>'; |
415 |
print '<td width="15%">'.$langs->trans("Firstname").'</td><td width="35%">'.$contact->firstname.'</td></tr>'; |
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="25%">'.$contact->firstname.'</td></tr>'; |
416 |
|
|
417 |
print '<tr><td>Poste/Fonction</td><td colspan="3">'.$contact->poste.'</td>'; |
print '<tr><td>Poste/Fonction</td><td colspan="3">'.$contact->poste.'</td>'; |
418 |
|
|
455 |
|
|
456 |
print '<tr><td>Jabberid</td><td colspan="3">'.$contact->jabberid.'</td></tr>'; |
print '<tr><td>Jabberid</td><td colspan="3">'.$contact->jabberid.'</td></tr>'; |
457 |
|
|
458 |
print '<tr><td>'.$langs->trans("Note").'</td><td colspan="3">'; |
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3">'; |
459 |
print nl2br($contact->note); |
print nl2br($contact->note); |
460 |
print '</td></tr>'; |
print '</td></tr>'; |
461 |
|
|