dolibarr  13.0.2
note.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
6  * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21 
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
32 if (!empty($conf->projet->enabled)) {
33  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
34 }
35 
36 $langs->loadLangs(array("bills", "companies"));
37 
38 $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('facid', 'int'));
39 $ref = GETPOST('ref', 'alpha');
40 $action = GETPOST('action', 'aZ09');
41 
42 // Security check
43 if ($user->socid) $socid = $user->socid;
44 $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
45 
46 $object = new FactureFournisseur($db);
47 $object->fetch($id, $ref);
48 
49 $permissionnote = $user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
50 
51 
52 /*
53  * Actions
54  */
55 
56 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
57 
58 // Set label
59 if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
60 {
61  $object->label = $_POST['label'];
62  $result = $object->update($user);
63  if ($result < 0) dol_print_error($db);
64 }
65 
66 
67 /*
68  * View
69  */
70 
71 $form = new Form($db);
72 
73 $title = $langs->trans('SupplierInvoice')." - ".$langs->trans('Notes');
74 $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
75 llxHeader('', $title, $helpurl);
76 
77 if ($object->id > 0)
78 {
79  $object->fetch_thirdparty();
80 
81  $alreadypaid = $object->getSommePaiement();
82 
83  $head = facturefourn_prepare_head($object);
84  $titre = $langs->trans('SupplierInvoice');
85  print dol_get_fiche_head($head, 'note', $titre, -1, 'supplier_invoice');
86 
87 
88  // Supplier invoice card
89  $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
90 
91  $morehtmlref = '<div class="refidno">';
92  // Ref supplier
93  $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
94  $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
95  // Thirdparty
96  $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
97  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>)';
98  // Project
99  if (!empty($conf->projet->enabled))
100  {
101  $langs->load("projects");
102  $morehtmlref .= '<br>'.$langs->trans('Project').' ';
103  if ($user->rights->fournisseur->commande->creer)
104  {
105  if ($action != 'classify') {
106  // $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
107  $morehtmlref .= ' : ';
108  }
109  if ($action == 'classify') {
110  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
111  $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
112  $morehtmlref .= '<input type="hidden" name="action" value="classin">';
113  $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
114  $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
115  $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
116  $morehtmlref .= '</form>';
117  } else {
118  $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
119  }
120  } else {
121  if (!empty($object->fk_project)) {
122  $proj = new Project($db);
123  $proj->fetch($object->fk_project);
124  $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
125  $morehtmlref .= $proj->ref;
126  $morehtmlref .= '</a>';
127  } else {
128  $morehtmlref .= '';
129  }
130  }
131  }
132  $morehtmlref .= '</div>';
133 
134  $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
135 
136  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
137 
138  print '<div class="fichecenter">';
139  print '<div class="underbanner clearboth"></div>';
140 
141  print '<table class="border centpercent tableforfield">';
142 
143  // Type
144  print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>';
145  print $object->getLibType();
146  if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
147  {
148  $facreplaced = new FactureFournisseur($db);
149  $facreplaced->fetch($object->fk_facture_source);
150  print ' ('.$langs->transnoentities("ReplaceInvoice", $facreplaced->getNomUrl(1)).')';
151  }
152  if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE)
153  {
154  $facusing = new FactureFournisseur($db);
155  $facusing->fetch($object->fk_facture_source);
156  print ' ('.$langs->transnoentities("CorrectInvoice", $facusing->getNomUrl(1)).')';
157  }
158 
159  $facidavoir = $object->getListIdAvoirFromInvoice();
160  if (count($facidavoir) > 0)
161  {
162  print ' ('.$langs->transnoentities("InvoiceHasAvoir");
163  $i = 0;
164  foreach ($facidavoir as $fid)
165  {
166  if ($i == 0) print ' ';
167  else print ',';
168  $facavoir = new FactureFournisseur($db);
169  $facavoir->fetch($fid);
170  print $facavoir->getNomUrl(1);
171  }
172  print ')';
173  }
174  if ($facidnext > 0)
175  {
176  $facthatreplace = new FactureFournisseur($db);
177  $facthatreplace->fetch($facidnext);
178  print ' ('.$langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)).')';
179  }
180  print '</td></tr>';
181 
182  // Label
183  print '<tr><td>'.$form->editfieldkey("Label", 'label', $object->label, $object, 0).'</td><td>';
184  print $form->editfieldval("Label", 'label', $object->label, $object, 0);
185  print '</td></tr>';
186 
187  // Amount
188  print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht, 1, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
189  print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva, 1, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
190 
191  // Amount Local Taxes
192  //TODO: Place into a function to control showing by country or study better option
193  if ($societe->localtax1_assuj == "1") //Localtax1
194  {
195  print '<tr><td>'.$langs->transcountry("AmountLT1", $societe->country_code).'</td>';
196  print '<td>'.price($object->total_localtax1, 1, $langs, 0, -1, -1, $conf->currency).'</td>';
197  print '</tr>';
198  }
199  if ($societe->localtax2_assuj == "1") //Localtax2
200  {
201  print '<tr><td>'.$langs->transcountry("AmountLT2", $societe->country_code).'</td>';
202  print '<td>'.price($object->total_localtax2, 1, $langs, 0, -1, -1, $conf->currency).'</td>';
203  print '</tr>';
204  }
205  print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc, 1, $langs, 0, -1, -1, $conf->currency).'</td></tr>';
206 
207  print "</table>";
208 
209  print '<br>';
210 
211  print '<div class="underbanner clearboth"></div>';
212  $cssclass = "titlefield";
213  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
214 
216 }
217 
218 // End of page
219 llxFooter();
220 $db->close();
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.
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...
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
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.
facturefourn_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:34
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.
Definition: index.php:89
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.
llxFooter()
Empty footer.
Definition: wrapper.php:59