27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.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';
37 $langs->loadLangs(array(
"facture",
"orders",
"sendings",
"companies"));
41 $action =
GETPOST(
'action',
'aZ09');
45 $socid = $user->socid;
47 $result =
restrictedArea($user,
'fournisseur', $id,
'commande_fournisseur',
'commande');
48 $hookmanager->initHooks(array(
'ordersuppliercardcontact'));
57 if ($action ==
'addcontact' && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
58 $result = $object->fetch($id);
60 if ($result > 0 && $id > 0) {
63 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
67 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
70 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
71 $langs->load(
"errors");
72 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
77 } elseif ($action ==
'swapstatut' && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
79 if ($object->fetch($id)) {
80 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
84 } elseif ($action ==
'deletecontact' && ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer)) {
87 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
90 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
102 $title = $langs->trans(
'SupplierOrder').
" - ".$langs->trans(
'ContactsAddresses');
103 $help_url =
'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
108 $contactstatic =
new Contact($db);
109 $userstatic =
new User($db);
118 if ($id > 0 || !empty($ref)) {
119 $langs->trans(
"OrderCard");
121 if ($object->fetch($id, $ref) > 0) {
122 $object->fetch_thirdparty();
125 print
dol_get_fiche_head($head,
'contact', $langs->trans(
"SupplierOrder"), -1,
'order');
129 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/commande/list.php'.(!empty($socid) ?
'?socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
131 $morehtmlref =
'<div class="refidno">';
133 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
134 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'',
null,
null,
'', 1);
136 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
138 if (!empty($conf->project->enabled)) {
139 $langs->load(
"projects");
140 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
141 if ($user->rights->fournisseur->commande->creer || $user->rights->supplier_order->creer) {
142 if ($action !=
'classify') {
144 $morehtmlref .=
' : ';
146 if ($action ==
'classify') {
148 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
149 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
150 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
151 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
152 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
153 $morehtmlref .=
'</form>';
155 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
158 if (!empty($object->fk_project)) {
160 $proj->fetch($object->fk_project);
161 $morehtmlref .=
' : '.$proj->getNomUrl(1);
163 $morehtmlref .=
' - '.$proj->title;
170 $morehtmlref .=
'</div>';
173 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
178 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
181 print
"ErrorRecordNotFound";