PageRenderTime 29ms CodeModel.GetById 6ms app.highlight 5ms RepoModel.GetById 16ms app.codeStats 0ms

/htdocs/fourn/commande/history.php

https://github.com/Modulaweb/dolibarr
PHP | 192 lines | 109 code | 41 blank | 42 comment | 9 complexity | f7a90486f9852e3e1756124e77a420d2 MD5 | raw file
  1<?php
  2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3 * Copyright (C) 2004-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
  4 * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  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 3 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/fourn/commande/history.php
 22 *       \ingroup    commande
 23 *       \brief      Fiche commande
 24 */
 25
 26require '../../main.inc.php';
 27require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
 28require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
 29
 30$langs->load("orders");
 31$langs->load("suppliers");
 32$langs->load("companies");
 33$langs->load('stocks');
 34
 35$id=GETPOST('id','int');
 36$ref=GETPOST('ref','alpha');
 37
 38// Security check
 39$socid='';
 40if (! empty($user->societe_id)) $socid=$user->societe_id;
 41$result = restrictedArea($user, 'fournisseur', $id, '', 'commande');
 42
 43
 44/*
 45 * View
 46 */
 47
 48$form =	new	Form($db);
 49
 50$now=dol_now();
 51
 52if ($id > 0 || ! empty($ref))
 53{
 54	$soc = new Societe($db);
 55	$commande = new CommandeFournisseur($db);
 56
 57	$result=$commande->fetch($id,$ref);
 58	if ($result >= 0)
 59	{
 60		$soc->fetch($commande->socid);
 61
 62		$author = new User($db);
 63		$author->fetch($commande->user_author_id);
 64
 65		llxHeader('',$langs->trans("History"),"CommandeFournisseur");
 66
 67		$head = ordersupplier_prepare_head($commande);
 68
 69		$title=$langs->trans("SupplierOrder");
 70		dol_fiche_head($head, 'info', $title, 0, 'order');
 71
 72
 73		/*
 74		*   Commande
 75		*/
 76
 77		print '<table class="border" width="100%">';
 78
 79		$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/liste.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
 80
 81		// Ref
 82		print '<tr><td width="20%">'.$langs->trans("Ref").'</td>';
 83		print '<td colspan="2">';
 84		print $form->showrefnav($commande, 'ref', $linkback, 1, 'ref', 'ref');
 85		print '</td>';
 86		print '</tr>';
 87
 88		// Fournisseur
 89		print '<tr><td>'.$langs->trans("Supplier")."</td>";
 90		print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
 91		print '</tr>';
 92
 93		// Statut
 94		print '<tr>';
 95		print '<td>'.$langs->trans("Status").'</td>';
 96		print '<td colspan="2">';
 97		print $commande->getLibStatut(4);
 98		print "</td></tr>";
 99
100		// Date
101		if ($commande->methode_commande_id > 0)
102		{
103			print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
104			if ($commande->date_commande)
105			{
106				print dol_print_date($commande->date_commande,"dayhourtext")."\n";
107			}
108			print "</td></tr>";
109
110			if ($commande->methode_commande)
111			{
112                print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->getInputMethod().'</td></tr>';
113			}
114		}
115
116		// Auteur
117		print '<tr><td>'.$langs->trans("AuthorRequest").'</td>';
118		print '<td colspan="2">'.$author->getNomUrl(1).'</td>';
119		print '</tr>';
120
121		print "</table>\n";
122		print "<br>";
123
124		/*
125		* Suivi historique
126		* Date - Statut - Auteur
127		*/
128		print '<table class="noborder" width="100%">';
129
130		print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Date").'</td>';
131		print '<td class="liste_titre">'.$langs->trans("Status").'</td>';
132		print '<td class="liste_titre" align="center">'.$langs->trans("Author").'</td>';
133		print '<td class="liste_titre" align="left">'.$langs->trans("Comment").'</td>';
134		print '</tr>';
135
136		$sql = "SELECT l.fk_statut, l.datelog as dl, l.comment, u.rowid, u.login, u.firstname, u.lastname";
137		$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_log as l";
138		$sql.= " , ".MAIN_DB_PREFIX."user as u ";
139		$sql.= " WHERE l.fk_commande = ".$commande->id;
140		$sql.= " AND u.rowid = l.fk_user";
141		$sql.= " ORDER BY l.rowid DESC";
142
143		$resql = $db->query($sql);
144		if ($resql)
145		{
146			$num = $db->num_rows($resql);
147			$i = 0;
148
149			$var=True;
150			while ($i < $num)
151			{
152				$var=!$var;
153
154				$obj = $db->fetch_object($resql);
155				print "<tr ".$bc[$var].">";
156
157				print '<td width="20%">'.dol_print_date($db->jdate($obj->dl),"dayhour")."</td>\n";
158
159				// Statut
160				print '<td class="nowrap">'.$commande->LibStatut($obj->fk_statut,4)."</td>\n";
161
162				// User
163				print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
164				print img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'</a></td>';
165
166				// Comment
167				print '<td class="nowrap" title="'.dol_escape_htmltag($obj->comment).'">'.dol_trunc($obj->comment,48)."</td>\n";
168
169				print '</tr>';
170
171				$i++;
172			}
173			$db->free($resql);
174		}
175		else
176		{
177			dol_print_error($db);
178		}
179		print "</table>";
180
181		print '</div>';
182	}
183	else
184	{
185		/* Commande non trouvee */
186		print "Commande inexistante ou acces refuse";
187	}
188}
189
190
191llxFooter();
192$db->close();