30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/images.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
37 if (!empty($conf->projet->enabled)) {
38 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
41 $langs->loadLangs(array(
'bills',
'other',
'companies'));
44 $action =
GETPOST(
'action',
'aZ09');
45 $confirm =
GETPOST(
'confirm',
'alpha');
49 if ($user->socid) $socid = $user->socid;
50 $result =
restrictedArea($user,
'fournisseur', $id,
'facture_fourn',
'facture');
53 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
54 $sortfield =
GETPOST(
"sortfield",
'alpha');
55 $sortorder =
GETPOST(
"sortorder",
'alpha');
57 if (empty($page) || $page == -1) { $page = 0; }
58 $offset = $limit * $page;
59 $pageprev = $page - 1;
60 $pagenext = $page + 1;
61 if (!$sortorder) $sortorder =
"ASC";
62 if (!$sortfield) $sortfield =
"name";
65 if ($object->fetch($id, $ref))
67 $object->fetch_thirdparty();
69 $upload_dir = $conf->fournisseur->facture->dir_output.
'/'.
get_exdir($object->id, 2, 0, 0, $object,
'invoice_supplier').$ref;
77 include_once DOL_DOCUMENT_ROOT.
'/core/actions_linkedfiles.inc.php';
84 $form =
new Form($db);
86 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'Documents');
87 $helpurl =
"EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
95 $totalpaye = $object->getSommePaiement();
97 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
99 $morehtmlref =
'<div class="refidno">';
101 $morehtmlref .= $form->editfieldkey(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', 0, 1);
102 $morehtmlref .= $form->editfieldval(
"RefSupplier",
'ref_supplier', $object->ref_supplier, $object, 0,
'string',
'', null, null,
'', 1);
104 $morehtmlref .=
'<br>'.$langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
105 if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.$object->thirdparty->id.
'&search_company='.urlencode($object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
107 if (!empty($conf->projet->enabled))
109 $langs->load(
"projects");
110 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
111 if ($user->rights->facture->creer)
113 if ($action !=
'classify')
115 $morehtmlref .=
' : ';
116 if ($action ==
'classify') {
118 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
119 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
120 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
121 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
122 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
123 $morehtmlref .=
'</form>';
125 $morehtmlref .= $form->form_project(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
128 if (!empty($object->fk_project)) {
130 $proj->fetch($object->fk_project);
131 $morehtmlref .=
'<a href="'.DOL_URL_ROOT.
'/projet/card.php?id='.$object->fk_project.
'" title="'.$langs->trans(
'ShowProject').
'">';
132 $morehtmlref .= $proj->ref;
133 $morehtmlref .=
'</a>';
139 $morehtmlref .=
'</div>';
141 $object->totalpaye = $totalpaye;
143 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref,
'', 0);
145 print '<div class="fichecenter">';
146 print '<div class="underbanner clearboth"></div>';
149 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) ==
'desc' ?SORT_DESC:SORT_ASC), 1);
151 foreach ($filearray as $key => $file)
153 $totalsize += $file[
'size'];
159 if ($action ==
'delete')
161 print $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&urlfile='.urlencode($_GET[
"urlfile"]), $langs->trans(
'DeleteFile'), $langs->trans(
'ConfirmDeleteFile'),
'confirm_deletefile',
'', 0, 1);
164 print '<table class="border tableforfield centpercent">';
167 print '<tr><td class="titlefield">'.$langs->trans(
'Type').
'</td><td>';
168 print $object->getLibType();
172 $facreplaced->fetch($object->fk_facture_source);
173 print ' ('.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
')';
178 $facusing->fetch($object->fk_facture_source);
179 print ' ('.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
')';
182 $facidavoir = $object->getListIdAvoirFromInvoice();
183 if (count($facidavoir) > 0)
185 print ' ('.$langs->transnoentities(
"InvoiceHasAvoir");
187 foreach ($facidavoir as $id)
189 if ($i == 0)
print ' ';
192 $facavoir->fetch($id);
193 print $facavoir->getNomUrl(1);
208 print '<tr><td>'.$form->editfieldkey(
"Label",
'label', $object->label, $object, 0).
'</td><td>';
209 print $form->editfieldval(
"Label",
'label', $object->label, $object, 0);
213 print '<tr><td>'.$langs->trans(
'AmountHT').
'</td><td>'.
price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
214 print '<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td>'.
price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
218 if ($mysoc->localtax1_assuj ==
"1")
220 print '<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
221 print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
224 if ($mysoc->localtax2_assuj ==
"1")
226 print '<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
227 print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).
'</td>';
230 print '<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td>'.
price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).
'</td></tr>';
232 print '</table><br>';
234 print '<div class="underbanner clearboth"></div>';
236 print '<table class="border tableforfield centpercent">';
239 print '<tr><td class="titlefield nowrap">'.$langs->trans(
'NbOfAttachedFiles').
'</td><td>'.count($filearray).
'</td></tr>';
241 print '<tr><td>'.$langs->trans(
'TotalSizeOfAttachedFiles').
'</td><td>'.
dol_print_size($totalsize, 1, 1).
'</td></tr>';
246 print '<div class="clearboth"></div>';
251 $modulepart =
'facture_fournisseur';
252 $permission = $user->rights->fournisseur->facture->creer;
253 $permtoedit = $user->rights->fournisseur->facture->creer;
254 $param =
'&facid='.$object->id;
256 $defaulttpldir =
'/core/tpl';
257 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
258 foreach ($dirtpls as $module => $reldir)
260 if (!empty($module)) {
261 $tpl =
dol_buildpath($reldir.
'/document_actions_post_headers.tpl.php');
263 $tpl = DOL_DOCUMENT_ROOT.$reldir.
'/document_actions_post_headers.tpl.php';
266 if (empty($conf->file->strict_mode)) {
267 $res = @include $tpl;
274 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.
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.
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. ...
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.
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.
facturefourn_prepare_head($object)
Prepare array with list of tabs.
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.
const TYPE_CREDIT_NOTE
Credit note invoice.
print
Draft customers invoices.
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.