dolibarr  9.0.0
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 <http://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','alpha');
41 
42 // Security check
43 if ($user->societe_id) $socid=$user->societe_id;
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  dol_fiche_head($head, 'note', $titre, -1, 'bill');
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 href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
107  $morehtmlref.=' : ';
108  if ($action == 'classify') {
109  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
110  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
111  $morehtmlref.='<input type="hidden" name="action" value="classin">';
112  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
113  $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
114  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
115  $morehtmlref.='</form>';
116  } else {
117  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
118  }
119  } else {
120  if (! empty($object->fk_project)) {
121  $proj = new Project($db);
122  $proj->fetch($object->fk_project);
123  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
124  $morehtmlref.=$proj->ref;
125  $morehtmlref.='</a>';
126  } else {
127  $morehtmlref.='';
128  }
129  }
130  }
131  $morehtmlref.='</div>';
132 
133  $object->totalpaye = $alreadypaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
134 
135  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
136 
137  print '<div class="fichecenter">';
138  print '<div class="underbanner clearboth"></div>';
139 
140  print '<table class="border" width="100%">';
141 
142  // Type
143  print '<tr><td class="titlefield">'.$langs->trans('Type').'</td><td>';
144  print $object->getLibType();
145  if ($object->type == FactureFournisseur::TYPE_REPLACEMENT)
146  {
147  $facreplaced=new FactureFournisseur($db);
148  $facreplaced->fetch($object->fk_facture_source);
149  print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
150  }
151  if ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE)
152  {
153  $facusing=new FactureFournisseur($db);
154  $facusing->fetch($object->fk_facture_source);
155  print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
156  }
157 
158  $facidavoir=$object->getListIdAvoirFromInvoice();
159  if (count($facidavoir) > 0)
160  {
161  print ' ('.$langs->transnoentities("InvoiceHasAvoir");
162  $i=0;
163  foreach($facidavoir as $fid)
164  {
165  if ($i==0) print ' ';
166  else print ',';
167  $facavoir=new FactureFournisseur($db);
168  $facavoir->fetch($fid);
169  print $facavoir->getNomUrl(1);
170  }
171  print ')';
172  }
173  if ($facidnext > 0)
174  {
175  $facthatreplace=new FactureFournisseur($db);
176  $facthatreplace->fetch($facidnext);
177  print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
178  }
179  print '</td></tr>';
180 
181  // Label
182  print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td>';
183  print $form->editfieldval("Label",'label',$object->label,$object,0);
184  print '</td></tr>';
185 
186  // Amount
187  print '<tr><td>'.$langs->trans('AmountHT').'</td><td>'.price($object->total_ht,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
188  print '<tr><td>'.$langs->trans('AmountVAT').'</td><td>'.price($object->total_tva,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
189 
190  // Amount Local Taxes
191  //TODO: Place into a function to control showing by country or study better option
192  if ($societe->localtax1_assuj=="1") //Localtax1
193  {
194  print '<tr><td>'.$langs->transcountry("AmountLT1",$societe->country_code).'</td>';
195  print '<td>'.price($object->total_localtax1,1,$langs,0,-1,-1,$conf->currency).'</td>';
196  print '</tr>';
197  }
198  if ($societe->localtax2_assuj=="1") //Localtax2
199  {
200  print '<tr><td>'.$langs->transcountry("AmountLT2",$societe->country_code).'</td>';
201  print '<td>'.price($object->total_localtax2,1,$langs,0,-1,-1,$conf->currency).'</td>';
202  print '</tr>';
203  }
204  print '<tr><td>'.$langs->trans('AmountTTC').'</td><td>'.price($object->total_ttc,1,$langs,0,-1,-1,$conf->currency).'</td></tr>';
205 
206  print "</table>";
207 
208  print '<br>';
209 
210  print '<div class="underbanner clearboth"></div>';
211  $cssclass="titlefield";
212  include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
213 
214  dol_fiche_end();
215 }
216 
217 // End of page
218 llxFooter();
219 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
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.
const TYPE_REPLACEMENT
Replacement invoice.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
Class to manage suppliers invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
facturefourn_prepare_head($object)
Prepare array with list of tabs.
Definition: fourn.lib.php:34
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...
const TYPE_CREDIT_NOTE
Credit note invoice.
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_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.