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';
34 if (!empty($conf->projet->enabled)) {
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');
48 if ($user->socid) $socid = $user->socid;
58 if ($action ==
'addcontact' && $user->rights->facture->creer)
60 $result = $object->fetch($id);
62 if ($result > 0 && $id > 0)
66 $result = $object->add_contact($contactid, $typeid,
GETPOST(
"source",
'aZ09'));
71 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
74 if ($object->error ==
'DB_ERROR_RECORD_ALREADY_EXISTS')
76 $langs->load(
"errors");
77 setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), null,
'errors');
83 elseif ($action ==
'swapstatut' && $user->rights->facture->creer)
85 if ($object->fetch($id))
87 $result = $object->swapContactStatus(
GETPOST(
'ligne'));
92 elseif ($action ==
'deletecontact' && $user->rights->facture->creer)
95 $result = $object->delete_contact($lineid);
99 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
111 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'ContactsAddresses');
112 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
115 $form =
new Form($db);
117 $contactstatic =
new Contact($db);
118 $userstatic =
new User($db);
127 if ($id > 0 || !empty($ref))
129 if ($object->fetch($id, $ref) > 0)
131 $object->fetch_thirdparty();
135 $totalpaye = $object->getSommePaiement();
141 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
143 $morehtmlref =
'<div class="refidno">';
145 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', 0, 1);
146 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client', $object->ref_client, $object, 0,
'string',
'', null, null,
'', 1);
148 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1,
'customer');
150 if (!empty($conf->projet->enabled))
152 $langs->load(
"projects");
153 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
154 if ($user->rights->facture->creer)
156 if ($action !=
'classify') {
158 $morehtmlref .=
' : ';
160 if ($action ==
'classify') {
162 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
163 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
164 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
165 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
166 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
167 $morehtmlref .=
'</form>';
169 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
172 if (!empty($object->fk_project)) {
174 $proj->fetch($object->fk_project);
175 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
176 $morehtmlref .= $proj->ref;
177 $morehtmlref .=
'</a>';
183 $morehtmlref .=
'</div>';
185 $object->totalpaye = $totalpaye;
187 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0,
'',
'', 1);
194 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array(
'/core/tpl'));
195 foreach ($dirtpls as $reldir)
202 print "ErrorRecordNotFound";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Dolibarr users.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage projects.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
Class to manage invoices.
dol_banner_tab($object, $paramid, $morehtml= '', $shownav=1, $fieldid= 'rowid', $fieldref= 'ref', $morehtmlref= '', $moreparam= '', $nodbprefix=0, $morehtmlleft= '', $morehtmlstatus= '', $onlybanner=0, $morehtmlright= '')
Show tab footer of a card.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.