dolibarr  7.0.0-beta
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@capnetworks.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->load('bills');
37 $langs->load("companies");
38 
39 $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('facid','int'));
40 $ref = GETPOST('ref','alpha');
41 $action = GETPOST('action','alpha');
42 
43 // Security check
44 if ($user->societe_id) $socid=$user->societe_id;
45 $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture');
46 
47 $object = new FactureFournisseur($db);
48 $object->fetch($id, $ref);
49 
50 $permissionnote=$user->rights->fournisseur->facture->creer; // Used by the include of actions_setnotes.inc.php
51 
52 
53 /*
54  * Actions
55  */
56 
57 include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
58 
59 // Set label
60 if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
61 {
62  $object->label=$_POST['label'];
63  $result=$object->update($user);
64  if ($result < 0) dol_print_error($db);
65 }
66 
67 
68 /*
69  * View
70  */
71 
72 $form = new Form($db);
73 
74 $title = $langs->trans('SupplierInvoice') . " - " . $langs->trans('Notes');
75 $helpurl = "EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores";
76 llxHeader('', $title, $helpurl);
77 
78 if ($object->id > 0)
79 {
80  $object->fetch_thirdparty();
81 
82  $alreadypaid=$object->getSommePaiement();
83 
84  $head = facturefourn_prepare_head($object);
85  $titre=$langs->trans('SupplierInvoice');
86  dol_fiche_head($head, 'note', $titre, -1, 'bill');
87 
88 
89  // Supplier invoice card
90  $linkback = '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
91 
92  $morehtmlref='<div class="refidno">';
93  // Ref supplier
94  $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
95  $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
96  // Thirdparty
97  $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
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 
218 llxFooter();
219 
220 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:58
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header 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.
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.
if(empty($reshook)) $form
View.
Definition: perms.php:103
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:46
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.
print
Draft customers invoices.
Definition: index.php:91
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.