PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/compta/facture/note.php

https://github.com/zeert/dolibarr
PHP | 136 lines | 74 code | 30 blank | 32 comment | 14 complexity | 6de9352e30f30ebe4246cdd20c3684b0 MD5 | raw file
  1<?php
  2/* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3 * Copyright (C) 2004-2008 Laurent Destailleur  <eldy@users.sourceforge.net>
  4 * Copyright (C) 2005-2012 Regis Houssin        <regis@dolibarr.fr>
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License as published by
  8 * the Free Software Foundation; either version 2 of the License, or
  9 * (at your option) any later version.
 10 *
 11 * This program is distributed in the hope that it will be useful,
 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14 * GNU General Public License for more details.
 15 *
 16 * You should have received a copy of the GNU General Public License
 17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 18 */
 19
 20/**
 21 *      \file       htdocs/compta/facture/note.php
 22 *      \ingroup    facture
 23 *      \brief      Fiche de notes sur une facture
 24 */
 25
 26require("../../main.inc.php");
 27require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
 28require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php');
 29require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php');
 30
 31$langs->load("companies");
 32$langs->load("bills");
 33
 34$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int'));  // For backward compatibility
 35$ref=GETPOST('ref','alpha');
 36$socid=GETPOST('socid','int');
 37$action=GETPOST('action','alpha');
 38
 39// Security check
 40$socid=0;
 41if ($user->societe_id) $socid=$user->societe_id;
 42$result=restrictedArea($user,'facture',$id,'');
 43
 44$object = new Facture($db);
 45$object->fetch($id);
 46
 47
 48/******************************************************************************/
 49/*                     Actions                                                */
 50/******************************************************************************/
 51
 52if ($action == 'setnote_public' && $user->rights->facture->creer)
 53{
 54	$object->fetch($id);
 55	$result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES));
 56	if ($result < 0) dol_print_error($db,$object->error);
 57}
 58
 59else if ($action == 'setnote' && $user->rights->facture->creer)
 60{
 61	$object->fetch($id);
 62	$result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES));
 63	if ($result < 0) dol_print_error($db,$object->error);
 64}
 65
 66
 67/******************************************************************************/
 68/* Affichage fiche                                                            */
 69/******************************************************************************/
 70
 71llxHeader();
 72
 73$form = new Form($db);
 74
 75if ($id > 0 || ! empty($ref))
 76{
 77	$object = new Facture($db);
 78	$object->fetch($id,$ref);
 79
 80	$soc = new Societe($db);
 81    $soc->fetch($object->socid);
 82
 83    $head = facture_prepare_head($object);
 84    dol_fiche_head($head, 'note', $langs->trans("InvoiceCustomer"), 0, 'bill');
 85
 86
 87    print '<table class="border" width="100%">';
 88
 89    $linkback = '<a href="'.DOL_URL_ROOT.'/compta/facture/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
 90
 91	// Ref
 92	print '<tr><td width="25%">'.$langs->trans('Ref').'</td>';
 93	print '<td colspan="3">';
 94	$morehtmlref='';
 95	$discount=new DiscountAbsolute($db);
 96	$result=$discount->fetch(0,$object->id);
 97	if ($result > 0)
 98	{
 99		$morehtmlref=' ('.$langs->trans("CreditNoteConvertedIntoDiscount",$discount->getNomUrl(1,'discount')).')';
100	}
101	if ($result < 0)
102	{
103		dol_print_error('',$discount->error);
104	}
105	print $form->showrefnav($object, 'ref', $linkback, 1, 'facnumber', 'ref', $morehtmlref);
106	print '</td></tr>';
107
108	// Ref customer
109	print '<tr><td width="20%">';
110	print '<table class="nobordernopadding" width="100%"><tr><td>';
111	print $langs->trans('RefCustomer');
112	print '</td>';
113	print '</tr></table>';
114	print '</td>';
115	print '<td colspan="5">';
116	print $object->ref_client;
117	print '</td></tr>';
118
119    // Company
120    print '<tr><td>'.$langs->trans("Company").'</td>';
121    print '<td colspan="3">'.$soc->getNomUrl(1,'compta').'</td>';
122
123    print "</table>";
124
125    print '<br>';
126
127	include(DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php');
128
129	dol_fiche_end();
130}
131
132
133llxFooter();
134
135$db->close();
136?>