26 require
'../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/sendings.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
32 if (!empty($conf->project->enabled)) {
33 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38 $langs->loadLangs(array(
'orders',
'sendings',
'companies'));
42 $action =
GETPOST(
'action',
'aZ09');
45 if ($id > 0 || !empty($ref)) {
46 $object->fetch($id, $ref);
47 $object->fetch_thirdparty();
49 if (!empty($object->origin)) {
50 $typeobject = $object->origin;
51 $origin = $object->origin;
52 $object->fetch_origin();
56 if ($typeobject ==
'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
58 $objectsrc->fetch($object->$typeobject->id);
60 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
61 $objectsrc =
new Propal($db);
62 $objectsrc->fetch($object->$typeobject->id);
68 $socid = $user->socid;
77 if ($action ==
'addcontact' && $user->rights->expedition->creer) {
78 if ($result > 0 && $id > 0) {
81 $result = $objectsrc->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
85 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
88 if ($objectsrc->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
89 $langs->load(
"errors");
90 $mesg = $langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType");
92 $mesg = $objectsrc->error;
93 $mesgs = $objectsrc->errors;
97 } elseif ($action ==
'swapstatut' && $user->rights->expedition->creer) {
99 $result = $objectsrc->swapContactStatus(
GETPOST(
'ligne',
'int'));
100 } elseif ($action ==
'deletecontact' && $user->rights->expedition->creer) {
102 $result = $objectsrc->delete_contact(
GETPOST(
"lineid",
'int'));
105 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
118 $help_url =
'EN:Module_Shipments|FR:Module_Expéditions|ES:Módulo_Expediciones|DE:Modul_Lieferungen';
125 $contactstatic =
new Contact($db);
126 $userstatic =
new User($db);
135 if ($id > 0 || !empty($ref)) {
136 $langs->trans(
"OrderCard");
139 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"Shipment"), -1, $object->picto);
143 $linkback =
'<a href="'.DOL_URL_ROOT.
'/expedition/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
145 $morehtmlref =
'<div class="refidno">';
147 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'', 0, 1);
148 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'', $object->ref_customer, $object, $user->rights->expedition->creer,
'string',
'',
null,
null,
'', 1);
150 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
152 if (!empty($conf->project->enabled)) {
153 $langs->load(
"projects");
154 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
156 if ($action !=
'classify') {
157 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
159 if ($action ==
'classify') {
161 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
162 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
163 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
164 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
165 $morehtmlref .=
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
166 $morehtmlref .=
'</form>';
168 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
173 $morehtmlref .=
' : ';
174 if (!empty($objectsrc->fk_project)) {
176 $proj->fetch($objectsrc->fk_project);
177 $morehtmlref .=
' : '.$proj->getNomUrl(1);
179 $morehtmlref .=
' - '.$proj->title;
186 $morehtmlref .=
'</div>';
189 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
192 print
'<div class="fichecenter">';
194 print
'<div class="underbanner clearboth"></div>';
196 print
'<table class="border centpercent tableforfield">';
199 if ($typeobject ==
'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) {
200 print
'<tr><td class="titlefield">';
202 $objectsrc->fetch($object->$typeobject->id);
203 print $langs->trans(
"RefOrder").
'</td>';
204 print
'<td colspan="3">';
205 print $objectsrc->getNomUrl(1,
'commande');
209 if ($typeobject ==
'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) {
210 print
'<tr><td class="titlefield">';
211 $objectsrc =
new Propal($db);
212 $objectsrc->fetch($object->$typeobject->id);
213 print $langs->trans(
"RefProposal").
'</td>';
214 print
'<td colspan="3">';
215 print $objectsrc->getNomUrl(1,
'expedition');
231 print
'<div class="clearboth"></div>';
240 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
241 $preselectedtypeofcontact =
dol_getIdFromCode($db,
'SHIPPING',
'c_type_contact',
'code',
'rowid');
242 foreach ($dirtpls as $reldir) {