28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
34 if (!empty($conf->project->enabled)) {
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
38 $langs->loadLangs(array(
"bills",
"other",
"companies"));
42 $action =
GETPOST(
'action',
'aZ09');
46 $socid = $user->socid;
48 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
49 $hookmanager->initHooks(array(
'invoicesuppliercardcontact'));
58 if ($action ==
'addcontact' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
59 $result = $object->fetch($id, $ref);
61 if ($result > 0 && $id > 0) {
64 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
68 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
71 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
72 $langs->load(
"errors");
73 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
78 } elseif ($action ==
'swapstatut' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
80 if ($object->fetch($id)) {
81 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
85 } elseif ($action ==
'deletecontact' && ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer)) {
88 $result = $object->delete_contact(
GETPOST(
"lineid",
'int'));
91 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
103 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'ContactsAddresses');
104 $helpurl =
"EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
109 $contactstatic =
new Contact($db);
110 $userstatic =
new User($db);
119 if ($id > 0 || !empty($ref)) {
120 if ($object->fetch($id, $ref) > 0) {
121 $object->fetch_thirdparty();
123 $alreadypaid = $object->getSommePaiement();
127 print
dol_get_fiche_head($head,
'contact', $langs->trans(
'SupplierInvoice'), -1,
'supplier_invoice');
129 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!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);
137 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
138 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
141 if (!empty($conf->project->enabled)) {
142 $langs->load(
"projects");
143 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
144 if ($user->rights->facture->creer) {
145 if ($action !=
'classify') {
147 $morehtmlref .=
' : ';
149 if ($action ==
'classify') {
151 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
152 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
153 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
154 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
155 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
156 $morehtmlref .=
'</form>';
158 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
161 if (!empty($object->fk_project)) {
163 $proj->fetch($object->fk_project);
164 $morehtmlref .=
' : '.$proj->getNomUrl(1);
166 $morehtmlref .=
' - '.$proj->title;
173 $morehtmlref .=
'</div>';
175 $object->totalpaid = $alreadypaid;
177 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
261 include DOL_DOCUMENT_ROOT.
'/core/tpl/contacts.tpl.php';
263 print
"ErrorRecordNotFound";