28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39 $langs->loadLangs(array(
'bills',
'companies'));
43 $lineid =
GETPOST(
'lineid',
'int');
44 $socid =
GETPOST(
'socid',
'int');
45 $action =
GETPOST(
'action',
'aZ09');
49 $socid = $user->socid;
54 if ($id > 0 || !empty($ref)) {
55 $ret = $object->fetch($id, $ref,
'',
'', (!empty($conf->global->INVOICE_USE_SITUATION) ? $conf->global->INVOICE_USE_SITUATION : 0));
65 if ($action ==
'addcontact' && $user->rights->facture->creer) {
66 if ($result > 0 && $id > 0) {
69 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
73 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
76 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
77 $langs->load(
"errors");
78 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"),
null,
'errors');
83 } elseif ($action ==
'swapstatut' && $user->rights->facture->creer) {
85 $result = $object->swapContactStatus(
GETPOST(
'ligne',
'int'));
86 } elseif ($action ==
'deletecontact' && $user->rights->facture->creer) {
88 $result = $object->delete_contact($lineid);
91 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
103 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'ContactsAddresses');
104 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
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();
125 $totalpaid = $object->getSommePaiement();
127 print
dol_get_fiche_head($head,
'contact', $langs->trans(
'InvoiceCustomer'), -1,
'bill');
131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
133 $morehtmlref =
'<div class="refidno">';
135 $morehtmlref .=
$form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
136 $morehtmlref .=
$form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'',
null,
null,
'', 1);
138 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1,
'customer');
141 $langs->load(
"projects");
142 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
143 if ($user->rights->facture->creer) {
144 if ($action !=
'classify') {
146 $morehtmlref .=
' : ';
148 if ($action ==
'classify') {
150 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
151 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
152 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
153 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
154 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
155 $morehtmlref .=
'</form>';
157 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
160 if (!empty($object->fk_project)) {
162 $proj->fetch($object->fk_project);
163 $morehtmlref .=
' : '.$proj->getNomUrl(1);
165 $morehtmlref .=
' - '.$proj->title;
172 $morehtmlref .=
'</div>';
174 $object->totalpaid = $totalpaid;
176 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
183 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
184 foreach ($dirtpls as $reldir) {
192 print
"ErrorRecordNotFound";