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";
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage Dolibarr users.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage suppliers invoices.
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, $mode=0)
Check permissions of a user to show a page and an object.
facturefourn_prepare_head($object)
Prepare array with list of tabs.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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.
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.