31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 if (!empty($conf->project->enabled)) {
39 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
42 $langs->loadLangs(array(
'bills',
'other',
'companies'));
45 $action =
GETPOST(
'action',
'aZ09');
46 $confirm =
GETPOST(
'confirm',
'alpha');
51 $socid = $user->socid;
53 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
54 $hookmanager->initHooks(array(
'invoicesuppliercarddocument'));
57 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
58 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61 if (empty($page) || $page == -1) {
64 $offset = $limit * $page;
65 $pageprev = $page - 1;
66 $pagenext = $page + 1;
75 if ($object->fetch($id, $ref)) {
76 $object->fetch_thirdparty();
78 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
81 $permissiontoadd = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
88 include DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
97 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'Documents');
98 $helpurl =
"EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
101 if ($object->id > 0) {
103 print
dol_get_fiche_head($head,
'documents', $langs->trans(
'SupplierInvoice'), -1,
'supplier_invoice');
105 $totalpaid = $object->getSommePaiement();
107 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
109 $morehtmlref =
'<div class="refidno">';
111 $morehtmlref .=
$form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
112 $morehtmlref .=
$form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', null, null,
'', 1);
114 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
115 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) {
116 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
119 if (!empty($conf->project->enabled)) {
120 $langs->load(
"projects");
121 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
122 if ($user->rights->facture->creer) {
123 if ($action !=
'classify') {
125 $morehtmlref .=
' : ';
127 if ($action ==
'classify') {
129 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
130 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
131 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
132 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
133 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
134 $morehtmlref .=
'</form>';
136 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
139 if (!empty($object->fk_project)) {
141 $proj->fetch($object->fk_project);
142 $morehtmlref .=
' : '.$proj->getNomUrl(1);
144 $morehtmlref .=
' - '.$proj->title;
151 $morehtmlref .=
'</div>';
153 $object->totalpaid = $totalpaid;
155 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0);
157 print
'<div class="fichecenter">';
158 print
'<div class="underbanner clearboth"></div>';
161 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
163 foreach ($filearray as $key => $file) {
164 $totalsize += $file[
'size'];
170 if ($action ==
'delete') {
171 print
$form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&urlfile='.urlencode($_GET[
"urlfile"]), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
174 print
'<table class="border tableforfield centpercent">';
177 print
'<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
178 print
'<span class="badgeneutral">';
179 print $object->getLibType();
183 $facreplaced->fetch($object->fk_facture_source);
184 print
' ('.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
')';
188 $facusing->fetch($object->fk_facture_source);
189 print
' ('.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
')';
192 $facidavoir = $object->getListIdAvoirFromInvoice();
193 if (count($facidavoir) > 0) {
194 $invoicecredits = array();
195 foreach ($facidavoir as $facid) {
197 $facavoir->fetch($facid);
198 $invoicecredits[] = $facavoir->getNomUrl(1);
200 print
' ('.$langs->transnoentities(
"InvoiceHasAvoir") . (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits) .
')';
212 print
'<tr><td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td><td>';
213 print
$form->editfieldval(
"Label",
'label', $object->label, $object, 0);
217 print
'<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
218 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
222 if ($mysoc->localtax1_assuj ==
"1") {
223 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
224 print
'<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
227 if ($mysoc->localtax2_assuj ==
"1") {
228 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
229 print
'<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
232 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
234 print
'</table><br>';
236 print
'<div class="underbanner clearboth"></div>';
238 print
'<table class="border tableforfield centpercent">';
241 print
'<tr><td class="titlefield nowrap">'.$langs->trans(
'NbOfAttachedFiles').
'</td><td>'.count($filearray).
'</td></tr>';
243 print
'<tr><td>'.$langs->trans(
'TotalSizeOfAttachedFiles').
'</td><td>'.
dol_print_size($totalsize, 1, 1).
'</td></tr>';
248 print
'<div class="clearboth"></div>';
253 $modulepart =
'facture_fournisseur';
254 $permission = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
255 $permtoedit = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
256 $param =
'&facid='.$object->id;
258 $defaulttpldir =
'/core/tpl';
259 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
260 foreach ($dirtpls as $module => $reldir) {
261 if (!empty($module)) {
262 $tpl =
dol_buildpath($reldir.
'/document_actions_post_headers.tpl.php');
264 $tpl = DOL_DOCUMENT_ROOT.$reldir.
'/document_actions_post_headers.tpl.php';
267 if (empty($conf->file->strict_mode)) {
268 $res = @include $tpl;
277 print $langs->trans(
'ErrorUnknown');
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.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage suppliers invoices.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
Class to manage projects.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
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.
const TYPE_CREDIT_NOTE
Credit note invoice.
dol_print_size($size, $shortvalue=0, $shortunit=0)
Return string with formated size.
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.