PageRenderTime 42ms CodeModel.GetById 1ms app.highlight 32ms RepoModel.GetById 2ms app.codeStats 0ms

/htdocs/fourn/commande/info.php

http://github.com/Dolibarr/dolibarr
PHP | 236 lines | 135 code | 52 blank | 49 comment | 41 complexity | 11871c040975ad3f96fd56a9406e949b MD5 | raw file
  1<?php
  2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3 * Copyright (C) 2004-2016 Laurent Destailleur  <eldy@users.sourceforge.net>
  4 * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@inodbox.com>
  5 * Copyright (C) 2017      Ferran Marcet       	 <fmarcet@2byte.es>
  6 *
  7 * This program is free software; you can redistribute it and/or modify
  8 * it under the terms of the GNU General Public License as published by
  9 * the Free Software Foundation; either version 3 of the License, or
 10 * (at your option) any later version.
 11 *
 12 * This program is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15 * GNU General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU General Public License
 18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 19 */
 20
 21/**
 22 *       \file       htdocs/fourn/commande/info.php
 23 *       \ingroup    commande
 24 *       \brief      Fiche commande
 25 */
 26
 27require '../../main.inc.php';
 28require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
 29require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 30require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
 31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
 32if (!empty($conf->projet->enabled)) {
 33	require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
 34}
 35
 36// Load translation files required by the page
 37$langs->loadLangs(array("suppliers", "orders", "companies", "stocks"));
 38
 39$id = GETPOST('id', 'int');
 40$ref = GETPOST('ref', 'alpha');
 41$action = GETPOST('action', 'alpha');
 42
 43$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 44$sortfield = GETPOST("sortfield", 'alpha');
 45$sortorder = GETPOST("sortorder", 'alpha');
 46$page = GETPOST("page", 'int');
 47if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
 48$offset = $limit * $page;
 49$pageprev = $page - 1;
 50$pagenext = $page + 1;
 51if (!$sortfield) $sortfield = 'a.datep,a.id';
 52if (!$sortorder) $sortorder = 'DESC,DESC';
 53
 54if (GETPOST('actioncode', 'array'))
 55{
 56    $actioncode = GETPOST('actioncode', 'array', 3);
 57    if (!count($actioncode)) $actioncode = '0';
 58}
 59else
 60{
 61    $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECTS));
 62}
 63$search_agenda_label = GETPOST('search_agenda_label');
 64
 65// Security check
 66$socid = 0;
 67if ($user->socid) $socid = $user->socid;
 68$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande');
 69
 70if (!$user->rights->fournisseur->commande->lire)	accessforbidden();
 71
 72
 73
 74
 75/*
 76 *	Actions
 77 */
 78
 79$parameters = array('id'=>$id);
 80$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 81if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 82
 83// Purge search criteria
 84if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 85{
 86    $actioncode = '';
 87    $search_agenda_label = '';
 88}
 89
 90
 91
 92/*
 93 * View
 94 */
 95
 96$form = new	Form($db);
 97$object = new CommandeFournisseur($db);
 98
 99if ($id > 0 || !empty($ref))
100{
101    $object->fetch($id, $ref);
102    $object->fetch_thirdparty();
103    $object->info($object->id);
104}
105
106$title = $langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name;
107if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
108$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores';
109llxHeader('', $title, $help_url);
110
111$now = dol_now();
112
113$head = ordersupplier_prepare_head($object);
114
115
116dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order');
117
118
119// Supplier order card
120
121$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
122
123$morehtmlref = '<div class="refidno">';
124// Ref supplier
125$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
126$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
127// Thirdparty
128$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
129// Project
130if (!empty($conf->projet->enabled))
131{
132    $langs->load("projects");
133    $morehtmlref .= '<br>'.$langs->trans('Project').' ';
134    if ($user->rights->fournisseur->commande->creer)
135    {
136        if ($action != 'classify') {
137            //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
138            $morehtmlref .= ' : ';
139        }
140        if ($action == 'classify') {
141            //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
142            $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
143            $morehtmlref .= '<input type="hidden" name="action" value="classin">';
144            $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
145            $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
146            $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
147            $morehtmlref .= '</form>';
148        } else {
149            $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
150        }
151    } else {
152        if (!empty($object->fk_project)) {
153            $proj = new Project($db);
154            $proj->fetch($object->fk_project);
155            $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">';
156            $morehtmlref .= $proj->ref;
157            $morehtmlref .= '</a>';
158        } else {
159            $morehtmlref .= '';
160        }
161    }
162}
163$morehtmlref .= '</div>';
164
165dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
166
167
168print '<div class="fichecenter">';
169print '<div class="underbanner clearboth"></div>';
170
171dol_print_object_info($object, 1);
172
173print '</div>';
174
175print '<div class="clearboth"></div>';
176
177dol_fiche_end();
178
179
180
181
182// Actions buttons
183
184$out = '';
185$permok = $user->rights->agenda->myactions->create;
186if ($permok)
187{
188    $out .= '&originid='.$object->id.'&origin=order_supplier';
189}
190
191
192print '<div class="tabsAction">';
193
194if (!empty($conf->agenda->enabled))
195{
196    if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
197    {
198        print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
199    }
200    else
201    {
202        print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>';
203    }
204}
205
206print '</div>';
207
208
209if (!empty($object->id))
210{
211    $param = '&id='.$object->id;
212    if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
213    if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
214
215    print load_fiche_titre($langs->trans("ActionsOnOrder"), '', '');
216
217    // List of actions on element
218    /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
219    $formactions=new FormActions($db);
220    $somethingshown = $formactions->showactions($object,'project',0);*/
221
222    // List of todo actions
223    //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode);
224
225    // List of done actions
226    //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
227
228    // List of all actions
229    $filters = array();
230    $filters['search_agenda_label'] = $search_agenda_label;
231    show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
232}
233
234// End of page
235llxFooter();
236$db->close();