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', 'aZ09'); 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} else { 59 $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)); 60} 61$search_agenda_label = GETPOST('search_agenda_label'); 62 63// Security check 64$socid = 0; 65if ($user->socid) $socid = $user->socid; 66$result = restrictedArea($user, 'fournisseur', $id, 'commande_fournisseur', 'commande'); 67 68if (!$user->rights->fournisseur->commande->lire) accessforbidden(); 69 70 71 72 73/* 74 * Actions 75 */ 76 77$parameters = array('id'=>$id); 78$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 79if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 80 81// Purge search criteria 82if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers 83{ 84 $actioncode = ''; 85 $search_agenda_label = ''; 86} 87 88 89 90/* 91 * View 92 */ 93 94$form = new Form($db); 95$object = new CommandeFournisseur($db); 96 97if ($id > 0 || !empty($ref)) 98{ 99 $object->fetch($id, $ref); 100 $object->fetch_thirdparty(); 101 $object->info($object->id); 102} 103 104$title = $langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name; 105if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); 106$help_url = 'EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; 107llxHeader('', $title, $help_url); 108 109$now = dol_now(); 110 111$head = ordersupplier_prepare_head($object); 112 113 114print dol_get_fiche_head($head, 'info', $langs->trans("SupplierOrder"), -1, 'order'); 115 116 117// Supplier order card 118 119$linkback = '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; 120 121$morehtmlref = '<div class="refidno">'; 122// Ref supplier 123$morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); 124$morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); 125// Thirdparty 126$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); 127// Project 128if (!empty($conf->projet->enabled)) 129{ 130 $langs->load("projects"); 131 $morehtmlref .= '<br>'.$langs->trans('Project').' '; 132 if ($user->rights->fournisseur->commande->creer) 133 { 134 if ($action != 'classify') { 135 //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : '; 136 $morehtmlref .= ' : '; 137 } 138 if ($action == 'classify') { 139 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 140 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; 141 $morehtmlref .= '<input type="hidden" name="action" value="classin">'; 142 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; 143 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 144 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; 145 $morehtmlref .= '</form>'; 146 } else { 147 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 148 } 149 } else { 150 if (!empty($object->fk_project)) { 151 $proj = new Project($db); 152 $proj->fetch($object->fk_project); 153 $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$object->fk_project.'" title="'.$langs->trans('ShowProject').'">'; 154 $morehtmlref .= $proj->ref; 155 $morehtmlref .= '</a>'; 156 } else { 157 $morehtmlref .= ''; 158 } 159 } 160} 161$morehtmlref .= '</div>'; 162 163dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 164 165 166print '<div class="fichecenter">'; 167print '<div class="underbanner clearboth"></div>'; 168 169dol_print_object_info($object, 1); 170 171print '</div>'; 172 173print '<div class="clearboth"></div>'; 174 175print dol_get_fiche_end(); 176 177 178 179 180// Actions buttons 181 182$out = ''; 183$permok = $user->rights->agenda->myactions->create; 184if ($permok) 185{ 186 $out .= '&originid='.$object->id.'&origin=order_supplier'; 187} 188 189 190print '<div class="tabsAction">'; 191 192if (!empty($conf->agenda->enabled)) 193{ 194 if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create)) 195 { 196 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>'; 197 } else { 198 print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddAction").'</a>'; 199 } 200} 201 202print '</div>'; 203 204 205if (!empty($object->id)) 206{ 207 $param = '&id='.$object->id; 208 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; 209 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; 210 211 print load_fiche_titre($langs->trans("ActionsOnOrder"), '', ''); 212 213 // List of actions on element 214 /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; 215 $formactions=new FormActions($db); 216 $somethingshown = $formactions->showactions($object,'project',0);*/ 217 218 // List of todo actions 219 //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); 220 221 // List of done actions 222 //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder); 223 224 // List of all actions 225 $filters = array(); 226 $filters['search_agenda_label'] = $search_agenda_label; 227 show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder); 228} 229 230// End of page 231llxFooter(); 232$db->close(); 233