1<?php 2/* Copyright (C) 2003-2008 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2005-2016 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> 5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> 6 * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es> 7 * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro> 8 * Copyright (C) 2013 Marcos García <marcosgdf@gmail.com> 9 * Copyright (C) 2014 Cedric GROSS <c.gross@kreiz-it.fr> 10 * Copyright (C) 2014-2017 Francis Appels <francis.appels@yahoo.com> 11 * Copyright (C) 2015 Claudio Aschieri <c.aschieri@19.coop> 12 * Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es> 13 * Copyright (C) 2016 Yasser Carreón <yacasia@gmail.com> 14 * Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr> 15 * 16 * This program is free software; you can redistribute it and/or modify 17 * it under the terms of the GNU General Public License as published by 18 * the Free Software Foundation; either version 3 of the License, or 19 * (at your option) any later version. 20 * 21 * This program is distributed in the hope that it will be useful, 22 * but WITHOUT ANY WARRANTY; without even the implied warranty of 23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 24 * GNU General Public License for more details. 25 * 26 * You should have received a copy of the GNU General Public License 27 * along with this program. If not, see <https://www.gnu.org/licenses/>. 28 */ 29 30/** 31 * \file htdocs/reception/card.php 32 * \ingroup reception 33 * \brief Card of a reception 34 */ 35 36require '../main.inc.php'; 37require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; 38require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php'; 39require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; 40require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; 41require_once DOL_DOCUMENT_ROOT.'/core/lib/reception.lib.php'; 42require_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; 43require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; 44require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; 45require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; 46require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; 47if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; 48if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; 49if (!empty($conf->fournisseur->enabled)) { 50 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; 51 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.dispatch.class.php'; 52} 53if (!empty($conf->productbatch->enabled)) require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php'; 54if (!empty($conf->projet->enabled)) { 55 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; 56 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; 57} 58 59$langs->loadLangs(array("receptions", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'sendings')); 60 61if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); 62if (!empty($conf->productbatch->enabled)) $langs->load('productbatch'); 63 64$origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'reception'; // Example: commande, propal 65$origin_id = GETPOST('id', 'int') ? GETPOST('id', 'int') : ''; 66$id = $origin_id; 67if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal 68if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal 69if (empty($origin_id)) $origin_id = GETPOST('originid', 'int'); // Id of order or propal 70$ref = GETPOST('ref', 'alpha'); 71$line_id = GETPOST('lineid', 'int') ?GETPOST('lineid', 'int') : ''; 72 73// Security check 74$socid = ''; 75if ($user->socid) $socid = $user->socid; 76 77if ($origin == 'reception') $result = restrictedArea($user, $origin, $id); 78else { 79 $result = restrictedArea($user, 'reception'); 80 if ($origin == 'supplierorder') { 81 if (empty($user->rights->fournisseur->commande->lire) && empty($user->rights->fournisseur->commande->read)) accessforbidden(); 82 } elseif (empty($user->rights->{$origin}->lire) && empty($user->rights->{$origin}->read)) accessforbidden(); 83} 84 85$action = GETPOST('action', 'alpha'); 86//Select mail models is same action as presend 87if (GETPOST('modelselected')) { 88 $action = 'presend'; 89} 90$confirm = GETPOST('confirm', 'alpha'); 91$cancel = GETPOST('cancel', 'alpha'); 92 93//PDF 94$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); 95$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); 96$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); 97 98$object = new Reception($db); 99$extrafields = new ExtraFields($db); 100 101// fetch optionals attributes and labels 102$extrafields->fetch_name_optionals_label($object->table_element); 103$extrafields->fetch_name_optionals_label($object->table_element_line); 104 105// Load object. Make an object->fetch 106include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once 107 108// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context 109$hookmanager->initHooks(array('receptioncard', 'globalcard')); 110 111$permissiondellink = $user->rights->reception->creer; // Used by the include of actions_dellink.inc.php 112//var_dump($object->lines[0]->detail_batch); 113 114$date_delivery = dol_mktime(GETPOST('date_deliveryhour', 'int'), GETPOST('date_deliverymin', 'int'), 0, GETPOST('date_deliverymonth', 'int'), GETPOST('date_deliveryday', 'int'), GETPOST('date_deliveryyear', 'int')); 115 116 117/* 118 * Actions 119 */ 120 121$parameters = array(); 122$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks 123if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); 124 125if (empty($reshook)) 126{ 127 if ($cancel) 128 { 129 $action = ''; 130 $object->fetch($id); // show reception also after canceling modification 131 } 132 133 include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once 134 135 // Reopen 136 if ($action == 'reopen' && $user->rights->reception->creer) 137 { 138 $object->fetch($id); 139 $result = $object->reOpen(); 140 } 141 142 // Confirm back to draft status 143 if ($action == 'modif' && $user->rights->reception->creer) 144 { 145 $result = $object->setDraft($user); 146 if ($result >= 0) 147 { 148 // Define output language 149 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) 150 { 151 $outputlangs = $langs; 152 $newlang = ''; 153 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); 154 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; 155 if (!empty($newlang)) { 156 $outputlangs = new Translate("", $conf); 157 $outputlangs->setDefaultLang($newlang); 158 } 159 $model = $object->model_pdf; 160 $ret = $object->fetch($id); // Reload to get new records 161 $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); 162 } 163 } 164 } 165 166 // Set incoterm 167 if ($action == 'set_incoterms' && !empty($conf->incoterm->enabled)) 168 { 169 $result = $object->setIncoterms(GETPOST('incoterm_id', 'int'), GETPOST('location_incoterms', 'alpha')); 170 } 171 172 if ($action == 'setref_supplier') 173 { 174 $result = $object->fetch($id); 175 if ($result < 0) { 176 setEventMessages($object->error, $object->errors, 'errors'); 177 } 178 179 $result = $object->setValueFrom('ref_supplier', GETPOST('ref_supplier', 'alpha'), '', null, 'text', '', $user, 'RECEPTION_MODIFY'); 180 if ($result < 0) { 181 setEventMessages($object->error, $object->errors, 'errors'); 182 $action = 'editref_supplier'; 183 } else { 184 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); 185 exit; 186 } 187 } 188 189 if ($action == 'update_extras') 190 { 191 $object->oldcopy = dol_clone($object); 192 193 // Fill array 'array_options' with data from update form 194 $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); 195 if ($ret < 0) $error++; 196 197 if (!$error) 198 { 199 // Actions on extra fields 200 $result = $object->insertExtraFields('RECEPTION_MODIFY'); 201 if ($result < 0) 202 { 203 setEventMessages($object->error, $object->errors, 'errors'); 204 $error++; 205 } 206 } 207 208 if ($error) 209 $action = 'edit_extras'; 210 } 211 212 // Create reception 213 if ($action == 'add' && $user->rights->reception->creer) 214 { 215 $error = 0; 216 $predef = ''; 217 218 $db->begin(); 219 220 $object->note = GETPOST('note', 'alpha'); 221 $object->origin = $origin; 222 $object->origin_id = $origin_id; 223 $object->fk_project = GETPOST('projectid', 'int'); 224 $object->weight = GETPOST('weight', 'int') == '' ? "NULL" : GETPOST('weight', 'int'); 225 $object->sizeH = GETPOST('sizeH', 'int') == '' ? "NULL" : GETPOST('sizeH', 'int'); 226 $object->sizeW = GETPOST('sizeW', 'int') == '' ? "NULL" : GETPOST('sizeW', 'int'); 227 $object->sizeS = GETPOST('sizeS', 'int') == '' ? "NULL" : GETPOST('sizeS', 'int'); 228 $object->size_units = GETPOST('size_units', 'int'); 229 $object->weight_units = GETPOST('weight_units', 'int'); 230 231 // On va boucler sur chaque ligne du document d'origine pour completer objet reception 232 // avec info diverses + qte a livrer 233 234 if ($object->origin == "supplierorder") 235 $classname = 'CommandeFournisseur'; 236 else $classname = ucfirst($object->origin); 237 $objectsrc = new $classname($db); 238 $objectsrc->fetch($object->origin_id); 239 240 $object->socid = $objectsrc->socid; 241 $object->ref_supplier = GETPOST('ref_supplier', 'alpha'); 242 $object->model_pdf = GETPOST('model'); 243 $object->date_delivery = $date_delivery; // Date delivery planed 244 $object->fk_delivery_address = $objectsrc->fk_delivery_address; 245 $object->shipping_method_id = GETPOST('shipping_method_id', 'int'); 246 $object->tracking_number = GETPOST('tracking_number', 'alpha'); 247 $object->note_private = GETPOST('note_private', 'restricthtml'); 248 $object->note_public = GETPOST('note_public', 'restricthtml'); 249 $object->fk_incoterms = GETPOST('incoterm_id', 'int'); 250 $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); 251 252 $batch_line = array(); 253 $stockLine = array(); 254 $array_options = array(); 255 256 $totalqty = 0; 257 258 $num = 0; 259 foreach ($_POST as $key => $value) 260 { 261 // without batch module enabled 262 263 if (strpos($key, 'qtyasked') !== false) 264 { 265 $num++; 266 } 267 } 268 269 for ($i = 1; $i <= $num; $i++) 270 { 271 $idl = "idl".$i; 272 273 $sub_qty = array(); 274 $subtotalqty = 0; 275 276 $j = 0; 277 $batch = "batchl".$i."_0"; 278 $stockLocation = "ent1".$i."_0"; 279 $qty = "qtyl".$i; 280 281 //var_dump(GETPOST($qty,'int')); var_dump($_POST); var_dump($batch);exit; 282 //reception line for product with no batch management and no multiple stock location 283 if (GETPOST($qty, 'int') > 0) 284 $totalqty += GETPOST($qty, 'int'); 285 286 287 // Extrafields 288 $array_options[$i] = $extrafields->getOptionalsFromPost($object->table_element_line, $i); 289 } 290 291 292 if ($totalqty > 0) // There is at least one thing to ship 293 { 294 //var_dump($_POST);exit; 295 for ($i = 1; $i <= $num; $i++) 296 { 297 $lineToTest = ''; 298 foreach ($objectsrc->lines as $linesrc) { 299 if ($linesrc->id == GETPOST($idl, 'int')) $lineToTest = $linesrc; 300 } 301 $qty = "qtyl".$i; 302 $comment = "comment".$i; 303 $eatby = "dlc".$i; 304 $sellby = "dluo".$i; 305 $batch = "batch".$i; 306 307 $timeFormat = '%d/%m/%Y'; 308 309 if (GETPOST($qty, 'int') > 0 || (GETPOST($qty, 'int') == 0 && $conf->global->RECEPTION_GETS_ALL_ORDER_PRODUCTS)) 310 { 311 $ent = "entl".$i; 312 313 $idl = "idl".$i; 314 315 $entrepot_id = is_numeric(GETPOST($ent, 'int')) ? GETPOST($ent, 'int') : GETPOST('entrepot_id', 'int'); 316 317 if (!empty($lineToTest)) { 318 $fk_product = $lineToTest->fk_product; 319 } else { 320 $fk_product = $linesrc->fk_product; 321 } 322 323 if ($entrepot_id < 0) 324 $entrepot_id = ''; 325 if (!($fk_product > 0) && empty($conf->global->STOCK_SUPPORTS_SERVICES)) 326 $entrepot_id = 0; 327 $eatby = GETPOST($eatby, 'alpha'); 328 $sellby = GETPOST($sellby, 'alpha'); 329 $eatbydate = str_replace('/', '-', $eatby); 330 $sellbydate = str_replace('/', '-', $sellby); 331 332 333 $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i], GETPOST($comment, 'alpha'), strtotime($eatbydate), strtotime($sellbydate), GETPOST($batch, 'alpha')); 334 if ($ret < 0) 335 { 336 setEventMessages($object->error, $object->errors, 'errors'); 337 $error++; 338 } 339 } 340 } 341 342 343 // Fill array 'array_options' with data from add form 344 $ret = $extrafields->setOptionalsFromPost(null, $object); 345 if ($ret < 0) $error++; 346 if (!$error) 347 { 348 $ret = $object->create($user); // This create reception (like Odoo picking) and line of receptions. Stock movement will when validating reception. 349 350 if ($ret <= 0) 351 { 352 setEventMessages($object->error, $object->errors, 'errors'); 353 $error++; 354 } 355 } 356 } else { 357 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("QtyToReceive").'/'.$langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); 358 $error++; 359 } 360 361 if (!$error) 362 { 363 $db->commit(); 364 header("Location: card.php?id=".$object->id); 365 exit; 366 } else { 367 $db->rollback(); 368 $_GET["commande_id"] = GETPOST('commande_id', 'int'); 369 $action = 'create'; 370 } 371 } elseif ($action == 'confirm_valid' && $confirm == 'yes' && 372 ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) 373 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) 374 ) 375 { 376 $object->fetch_thirdparty(); 377 378 $result = $object->valid($user); 379 380 if ($result < 0) 381 { 382 $langs->load("errors"); 383 setEventMessages($langs->trans($object->error), null, 'errors'); 384 } else { 385 // Define output language 386 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) 387 { 388 $outputlangs = $langs; 389 $newlang = ''; 390 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); 391 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang; 392 if (!empty($newlang)) { 393 $outputlangs = new Translate("", $conf); 394 $outputlangs->setDefaultLang($newlang); 395 } 396 $model = $object->model_pdf; 397 $ret = $object->fetch($id); // Reload to get new records 398 399 $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); 400 if ($result < 0) dol_print_error($db, $result); 401 } 402 } 403 } elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->reception->supprimer) 404 { 405 $result = $object->delete($user); 406 if ($result > 0) 407 { 408 header("Location: ".DOL_URL_ROOT.'/reception/index.php'); 409 exit; 410 } else { 411 setEventMessages($object->error, $object->errors, 'errors'); 412 } 413 } 414 // TODO add alternative status 415 /*elseif ($action == 'reopen' && (! empty($user->rights->reception->creer) || ! empty($user->rights->reception->reception_advance->validate))) 416 { 417 $result = $object->setStatut(0); 418 if ($result < 0) 419 { 420 setEventMessages($object->error, $object->errors, 'errors'); 421 } 422 }*/ 423 424 elseif ($action == 'setdate_livraison' && $user->rights->reception->creer) 425 { 426 //print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year']; 427 $datedelivery = dol_mktime(GETPOST('liv_hour', 'int'), GETPOST('liv_min', 'int'), 0, GETPOST('liv_month', 'int'), GETPOST('liv_day', 'int'), GETPOST('liv_year', 'int')); 428 429 $object->fetch($id); 430 $result = $object->setDeliveryDate($user, $datedelivery); 431 if ($result < 0) 432 { 433 setEventMessages($object->error, $object->errors, 'errors'); 434 } 435 } 436 437 // Action update 438 elseif ($action == 'settracking_number' || $action == 'settracking_url' 439 || $action == 'settrueWeight' 440 || $action == 'settrueWidth' 441 || $action == 'settrueHeight' 442 || $action == 'settrueDepth' 443 || $action == 'setshipping_method_id') 444 { 445 $error = 0; 446 447 if ($action == 'settracking_number') $object->tracking_number = trim(GETPOST('tracking_number', 'alpha')); 448 if ($action == 'settracking_url') $object->tracking_url = trim(GETPOST('tracking_url', 'int')); 449 if ($action == 'settrueWeight') { 450 $object->trueWeight = trim(GETPOST('trueWeight', 'int')); 451 $object->weight_units = GETPOST('weight_units', 'int'); 452 } 453 if ($action == 'settrueWidth') $object->trueWidth = trim(GETPOST('trueWidth', 'int')); 454 if ($action == 'settrueHeight') { 455 $object->trueHeight = trim(GETPOST('trueHeight', 'int')); 456 $object->size_units = GETPOST('size_units', 'int'); 457 } 458 if ($action == 'settrueDepth') $object->trueDepth = trim(GETPOST('trueDepth', 'int')); 459 if ($action == 'setshipping_method_id') $object->shipping_method_id = trim(GETPOST('shipping_method_id', 'int')); 460 461 if (!$error) 462 { 463 if ($object->update($user) >= 0) 464 { 465 header("Location: card.php?id=".$object->id); 466 exit; 467 } 468 setEventMessages($object->error, $object->errors, 'errors'); 469 } 470 471 $action = ""; 472 } 473 474 // Build document 475 elseif ($action == 'builddoc') // En get ou en post 476 { 477 // Save last template used to generate document 478 if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); 479 480 // Define output language 481 $outputlangs = $langs; 482 $newlang = ''; 483 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); 484 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $reception->thirdparty->default_lang; 485 if (!empty($newlang)) 486 { 487 $outputlangs = new Translate("", $conf); 488 $outputlangs->setDefaultLang($newlang); 489 } 490 $result = $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); 491 if ($result <= 0) 492 { 493 setEventMessages($object->error, $object->errors, 'errors'); 494 $action = ''; 495 } 496 } 497 498 // Delete file in doc form 499 elseif ($action == 'remove_file') 500 { 501 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; 502 503 $upload_dir = $conf->reception->dir_output; 504 $file = $upload_dir.'/'.GETPOST('file'); 505 $ret = dol_delete_file($file, 0, 0, 0, $object); 506 if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); 507 else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); 508 } elseif ($action == 'classifybilled') 509 { 510 $object->fetch($id); 511 $result = $object->set_billed(); 512 if ($result >= 0) { 513 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); 514 exit(); 515 } 516 } elseif ($action == 'classifyclosed') 517 { 518 $object->fetch($id); 519 $result = $object->setClosed(); 520 if ($result >= 0) { 521 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); 522 exit(); 523 } 524 } 525 526 /* 527 * delete a line 528 */ 529 elseif ($action == 'deleteline' && !empty($line_id)) 530 { 531 $object->fetch($id); 532 $lines = $object->lines; 533 $line = new CommandeFournisseurDispatch($db); 534 535 $num_prod = count($lines); 536 for ($i = 0; $i < $num_prod; $i++) 537 { 538 if ($lines[$i]->id == $line_id) 539 { 540 // delete single warehouse line 541 $line->id = $line_id; 542 if (!$error && $line->delete($user) < 0) 543 { 544 $error++; 545 } 546 } 547 unset($_POST["lineid"]); 548 } 549 550 if (!$error) { 551 header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); 552 exit(); 553 } else { 554 setEventMessages($line->error, $line->errors, 'errors'); 555 } 556 } 557 558 /* 559 * Update a line 560 */ 561 elseif ($action == 'updateline' && $user->rights->reception->creer && GETPOST('save')) 562 { 563 // Clean parameters 564 $qty = 0; 565 $entrepot_id = 0; 566 $batch_id = 0; 567 568 $lines = $object->lines; 569 $num_prod = count($lines); 570 for ($i = 0; $i < $num_prod; $i++) 571 { 572 if ($lines[$i]->id == $line_id) // we have found line to update 573 { 574 $line = new CommandeFournisseurDispatch($db); 575 $line->fetch($line_id); 576 // Extrafields Lines 577 $extrafields->fetch_name_optionals_label($object->table_element_line); 578 $line->array_options = $extrafields->getOptionalsFromPost($object->table_element_line); 579 580 581 $line->fk_product = $lines[$i]->fk_product; 582 583 584 if ($lines[$i]->fk_product > 0) 585 { 586 // single warehouse reception line 587 $stockLocation = "entl".$line_id; 588 $qty = "qtyl".$line_id; 589 $comment = "comment".$line_id; 590 591 592 $line->id = $line_id; 593 $line->fk_entrepot = GETPOST($stockLocation, 'int'); 594 $line->qty = GETPOST($qty, 'int'); 595 $line->comment = GETPOST($comment, 'alpha'); 596 597 if (!empty($conf->productbatch->enabled)) { 598 $batch = "batch".$line_id; 599 $dlc = "dlc".$line_id; 600 $dluo = "dluo".$line_id; 601 $eatby = GETPOST($dlc, 'alpha'); 602 $eatbydate = str_replace('/', '-', $eatby); 603 $sellby = GETPOST($dluo, 'alpha'); 604 $sellbydate = str_replace('/', '-', $sellby); 605 $line->batch = GETPOST($batch, 'alpha'); 606 $line->eatby = strtotime($eatbydate); 607 $line->sellby = strtotime($sellbydate); 608 } 609 610 if ($line->update($user) < 0) 611 { 612 setEventMessages($line->error, $line->errors, 'errors'); 613 $error++; 614 } 615 } else // Product no predefined 616 { 617 $qty = "qtyl".$line_id; 618 $line->id = $line_id; 619 $line->qty = GETPOST($qty, 'int'); 620 $line->fk_entrepot = 0; 621 if ($line->update($user) < 0) 622 { 623 setEventMessages($line->error, $line->errors, 'errors'); 624 $error++; 625 } 626 unset($_POST[$qty]); 627 } 628 } 629 } 630 631 unset($_POST["lineid"]); 632 633 if (!$error) { 634 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { 635 // Define output language 636 $outputlangs = $langs; 637 $newlang = ''; 638 if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) 639 $newlang = GETPOST('lang_id', 'aZ09'); 640 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) 641 $newlang = $object->thirdparty->default_lang; 642 if (!empty($newlang)) { 643 $outputlangs = new Translate("", $conf); 644 $outputlangs->setDefaultLang($newlang); 645 } 646 647 $ret = $object->fetch($object->id); // Reload to get new records 648 $object->generateDocument($object->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref); 649 } 650 } else { 651 header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition 652 exit(); 653 } 654 } elseif ($action == 'updateline' && $user->rights->reception->creer && GETPOST('cancel', 'alpha') == $langs->trans("Cancel")) { 655 header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition 656 exit(); 657 } 658 659 include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; 660 661 // Actions to send emails 662 if (empty($id)) $id = $facid; 663 $triggersendname = 'RECEPTION_SENTBYMAIL'; 664 $paramname = 'id'; 665 $mode = 'emailfromreception'; 666 $trackid = 'shi'.$object->id; 667 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; 668} 669 670 671/* 672 * View 673 */ 674 675llxHeader('', $langs->trans('Reception'), 'Reception'); 676 677$form = new Form($db); 678$formfile = new FormFile($db); 679$formproduct = new FormProduct($db); 680if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } 681 682$product_static = new Product($db); 683$reception_static = new Reception($db); 684$warehousestatic = new Entrepot($db); 685 686if ($action == 'create2') 687{ 688 print load_fiche_titre($langs->trans("CreateReception"), '', 'dollyrevert'); 689 690 print '<br>'.$langs->trans("ReceptionCreationIsDoneFromOrder"); 691 $action = ''; $id = ''; $ref = ''; 692} 693 694// Mode creation. 695if ($action == 'create') 696{ 697 $recept = new Reception($db); 698 699 print load_fiche_titre($langs->trans("CreateReception")); 700 if (!$origin) 701 { 702 setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors'); 703 } 704 705 if ($origin) 706 { 707 if ($origin == 'supplierorder')$classname = 'CommandeFournisseur'; 708 else $classname = ucfirst($origin); 709 710 $objectsrc = new $classname($db); 711 if ($objectsrc->fetch($origin_id)) { // This include the fetch_lines 712 $soc = new Societe($db); 713 $soc->fetch($objectsrc->socid); 714 715 $author = new User($db); 716 $author->fetch($objectsrc->user_author_id); 717 718 if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); 719 720 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">'; 721 print '<input type="hidden" name="token" value="'.newToken().'">'; 722 print '<input type="hidden" name="action" value="add">'; 723 print '<input type="hidden" name="origin" value="'.$origin.'">'; 724 print '<input type="hidden" name="origin_id" value="'.$objectsrc->id.'">'; 725 if (GETPOST('entrepot_id', 'int')) { 726 print '<input type="hidden" name="entrepot_id" value="'.GETPOST('entrepot_id', 'int').'">'; 727 } 728 729 print dol_get_fiche_head(''); 730 731 print '<table class="border centpercent">'; 732 733 // Ref 734 print '<tr><td class="titlefieldcreate fieldrequired">'; 735 if ($origin == 'supplierorder' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) { 736 print $langs->trans("RefOrder").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/fourn/commande/card.php?id='.$objectsrc->id.'">'.img_object($langs->trans("ShowOrder"), 'order').' '.$objectsrc->ref; 737 } 738 if ($origin == 'propal' && !empty($conf->propal->enabled)) { 739 print $langs->trans("RefProposal").'</td><td colspan="3"><a href="'.DOL_URL_ROOT.'/comm/card.php?id='.$objectsrc->id.'">'.img_object($langs->trans("ShowProposal"), 'propal').' '.$objectsrc->ref; 740 } 741 print '</a></td>'; 742 print "</tr>\n"; 743 744 // Ref client 745 print '<tr><td>'; 746 if ($origin == 'supplier_order') print $langs->trans('SupplierOrder'); 747 else print $langs->trans('RefSupplier'); 748 print '</td><td colspan="3">'; 749 print '<input type="text" name="ref_supplier" value="'.$objectsrc->ref_supplier.'" />'; 750 print '</td>'; 751 print '</tr>'; 752 753 // Tiers 754 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Company').'</td>'; 755 print '<td colspan="3">'.$soc->getNomUrl(1).'</td>'; 756 print '</tr>'; 757 758 // Project 759 if (!empty($conf->projet->enabled)) 760 { 761 $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; 762 if (empty($projectid) && !empty($objectsrc->fk_project)) { 763 $projectid = $objectsrc->fk_project; 764 } 765 if ($origin == 'project') { 766 $projectid = ($originid ? $originid : 0); 767 } 768 769 $langs->load("projects"); 770 print '<tr>'; 771 print '<td>'.$langs->trans("Project").'</td><td colspan="2">'; 772 print $formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $soc->id : -1), $projectid, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); 773 print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>'; 774 print '</td>'; 775 print '</tr>'; 776 } 777 778 // Date delivery planned 779 print '<tr><td>'.$langs->trans("DateDeliveryPlanned").'</td>'; 780 print '<td colspan="3">'; 781 $date_delivery = ($date_delivery ? $date_delivery : $objectsrc->delivery_date); // $date_delivery comes from GETPOST 782 print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); 783 print "</td>\n"; 784 print '</tr>'; 785 786 // Note Public 787 print '<tr><td>'.$langs->trans("NotePublic").'</td>'; 788 print '<td colspan="3">'; 789 $doleditor = new DolEditor('note_public', $objectsrc->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); 790 print $doleditor->Create(1); 791 print "</td></tr>"; 792 793 // Note Private 794 if ($objectsrc->note_private && !$user->socid) { 795 print '<tr><td>'.$langs->trans("NotePrivate").'</td>'; 796 print '<td colspan="3">'; 797 $doleditor = new DolEditor('note_private', $objectsrc->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); 798 print $doleditor->Create(1); 799 print "</td></tr>"; 800 } 801 802 // Weight 803 print '<tr><td>'; 804 print $langs->trans("Weight"); 805 print '</td><td colspan="3"><input name="weight" size="4" value="'.GETPOST('weight', 'int').'"> '; 806 $text = $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOST('weight_units', 'int'), 0, 2); 807 $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); 808 print $form->textwithpicto($text, $htmltext); 809 print '</td></tr>'; 810 // Dim 811 print '<tr><td>'; 812 print $langs->trans("Width").' x '.$langs->trans("Height").' x '.$langs->trans("Depth"); 813 print ' </td><td colspan="3"><input name="sizeW" size="4" value="'.GETPOST('sizeW', 'int').'">'; 814 print ' x <input name="sizeH" size="4" value="'.GETPOST('sizeH', 'int').'">'; 815 print ' x <input name="sizeS" size="4" value="'.GETPOST('sizeS', 'int').'">'; 816 print ' '; 817 $text = $formproduct->selectMeasuringUnits("size_units", "size", GETPOST('size_units', 'int'), 0, 2); 818 $htmltext = $langs->trans("KeepEmptyForAutoCalculation"); 819 print $form->textwithpicto($text, $htmltext); 820 print '</td></tr>'; 821 822 // Delivery method 823 print "<tr><td>".$langs->trans("ReceptionMethod")."</td>"; 824 print '<td colspan="3">'; 825 $recept->fetch_delivery_methods(); 826 print $form->selectarray("shipping_method_id", $recept->meths, GETPOST('shipping_method_id', 'int'), 1, 0, 0, "", 1); 827 if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); 828 print "</td></tr>\n"; 829 830 // Tracking number 831 print "<tr><td>".$langs->trans("TrackingNumber")."</td>"; 832 print '<td colspan="3">'; 833 print '<input name="tracking_number" size="20" value="'.GETPOST('tracking_number', 'alpha').'">'; 834 print "</td></tr>\n"; 835 836 // Other attributes 837 $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid); 838 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $objectsrc may have been modified by hook 839 print $hookmanager->resPrint; 840 841 // Here $object can be of an object Reception 842 $extrafields->fetch_name_optionals_label($object->table_element); 843 if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { 844 // copy from order 845 if ($objectsrc->fetch_optionals() > 0) { 846 $recept->array_options = array_merge($recept->array_options, $objectsrc->array_options); 847 } 848 print $object->showOptionals($extrafields, 'edit', $parameters); 849 } 850 851 // Incoterms 852 if (!empty($conf->incoterm->enabled)) 853 { 854 print '<tr>'; 855 print '<td><label for="incoterm_id">'.$form->textwithpicto($langs->trans("IncotermLabel"), $objectsrc->label_incoterms, 1).'</label></td>'; 856 print '<td colspan="3" class="maxwidthonsmartphone">'; 857 print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : '')); 858 print '</td></tr>'; 859 } 860 861 // Document model 862 include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php'; 863 $liste = ModelePdfReception::liste_modeles($db); 864 865 if (count($liste) > 1) 866 { 867 print "<tr><td>".$langs->trans("DefaultModel")."</td>"; 868 print '<td colspan="3">'; 869 print $form->selectarray('model', $liste, $conf->global->RECEPTION_ADDON_PDF); 870 print "</td></tr>\n"; 871 } 872 873 print "</table>"; 874 875 print dol_get_fiche_end(); 876 877 // Reception lines 878 $numAsked = 0; 879 $dispatchLines = array(); 880 foreach ($_POST as $key => $value) { 881 // If create form is coming from the button "Create Reception" of previous page 882 883 // without batch module enabled 884 $reg = array(); 885 if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { 886 $numAsked++; 887 888 // $numline=$reg[2] + 1; // line of product 889 $numline = $numAsked; 890 $prod = "product_".$reg[1].'_'.$reg[2]; 891 $qty = "qty_".$reg[1].'_'.$reg[2]; 892 $ent = "entrepot_".$reg[1].'_'.$reg[2]; 893 $pu = "pu_".$reg[1].'_'.$reg[2]; // This is unit price including discount 894 $fk_commandefourndet = "fk_commandefourndet_".$reg[1].'_'.$reg[2]; 895 $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int')); 896 } 897 898 // with batch module enabled 899 if (preg_match('/^product_batch_([0-9]+)_([0-9]+)$/i', $key, $reg)) 900 { 901 $numAsked++; 902 903 // eat-by date dispatch 904 // $numline=$reg[2] + 1; // line of product 905 $numline = $numAsked; 906 $prod = 'product_batch_'.$reg[1].'_'.$reg[2]; 907 $qty = 'qty_'.$reg[1].'_'.$reg[2]; 908 $ent = 'entrepot_'.$reg[1].'_'.$reg[2]; 909 $pu = 'pu_'.$reg[1].'_'.$reg[2]; 910 $lot = 'lot_number_'.$reg[1].'_'.$reg[2]; 911 $dDLUO = dol_mktime(12, 0, 0, $_POST['dluo_'.$reg[1].'_'.$reg[2].'month'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'day'], $_POST['dluo_'.$reg[1].'_'.$reg[2].'year']); 912 $dDLC = dol_mktime(12, 0, 0, $_POST['dlc_'.$reg[1].'_'.$reg[2].'month'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'day'], $_POST['dlc_'.$reg[1].'_'.$reg[2].'year']); 913 $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; 914 $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); 915 } 916 917 // If create form is coming from same page post was sent but an error occured 918 if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) { 919 $numAsked++; 920 921 // eat-by date dispatch 922 // $numline=$reg[2] + 1; // line of product 923 $numline = $numAsked; 924 $prod = 'productid'.$reg[1]; 925 $comment = 'comment'.$reg[1]; 926 $qty = 'qtyl'.$reg[1]; 927 $ent = 'entl'.$reg[1]; 928 $pu = 'pul'.$reg[1]; 929 $lot = 'batch'.$reg[1]; 930 $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int')); 931 $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int')); 932 $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1]; 933 $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); 934 } 935 } 936 937 938 print '<script type="text/javascript" language="javascript"> 939 jQuery(document).ready(function() { 940 jQuery("#autofill").click(function() {'; 941 $i = 1; 942 while ($i <= $numAsked) 943 { 944 print 'jQuery("#qtyl'.$i.'").val(jQuery("#qtyasked'.$i.'").val() - jQuery("#qtydelivered'.$i.'").val());'."\n"; 945 $i++; 946 } 947 print '}); 948 jQuery("#autoreset").click(function() {'; 949 $i = 1; 950 while ($i <= $numAsked) 951 { 952 print 'jQuery("#qtyl'.$i.'").val(0);'."\n"; 953 $i++; 954 } 955 print '}); 956 }); 957 </script>'; 958 959 print '<br>'; 960 961 print '<table class="noborder centpercent">'; 962 963 // Load receptions already done for same order 964 $objectsrc->loadReceptions(); 965 966 if ($numAsked) 967 { 968 print '<tr class="liste_titre">'; 969 print '<td>'.$langs->trans("Description").'</td>'; 970 print '<td class="center">'.$langs->trans("QtyOrdered").'</td>'; 971 print '<td class="center">'.$langs->trans("QtyReceived").'</td>'; 972 print '<td class="center">'.$langs->trans("QtyToReceive"); 973 if (empty($conf->productbatch->enabled)) 974 { 975 print ' <br>(<a href="#" id="autofill">'.$langs->trans("Fill").'</a>'; 976 print ' / <a href="#" id="autoreset">'.$langs->trans("Reset").'</a>)'; 977 } 978 print '</td>'; 979 if (!empty($conf->stock->enabled)) 980 { 981 print '<td class="left">'.$langs->trans("Warehouse").' ('.$langs->trans("Stock").')</td>'; 982 } 983 if (!empty($conf->productbatch->enabled)) 984 { 985 print '<td class="left">'.$langs->trans("batch_number").'</td>'; 986 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { 987 print '<td class="left">'.$langs->trans("SellByDate").'</td>'; 988 } 989 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { 990 print '<td class="left">'.$langs->trans("EatByDate").'</td>'; 991 } 992 } 993 print "</tr>\n"; 994 } 995 996 $indiceAsked = 1; 997 while ($indiceAsked <= $numAsked) 998 { 999 $product = new Product($db); 1000 foreach ($objectsrc->lines as $supplierLine) { 1001 if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { 1002 $line = $supplierLine; 1003 break; 1004 } 1005 } 1006 1007 // Show product and description 1008 $type = $line->product_type ? $line->product_type : $line->fk_product_type; 1009 // Try to enhance type detection using date_start and date_end for free lines where type 1010 // was not saved. 1011 if (!empty($line->date_start)) $type = 1; 1012 if (!empty($line->date_end)) $type = 1; 1013 1014 print '<!-- line fk_commandefourndet='.$line->id.' for product='.$line->fk_product.' -->'."\n"; 1015 print '<tr class="oddeven">'."\n"; 1016 1017 1018 // Product label 1019 if ($line->fk_product > 0) // If predefined product 1020 { 1021 $product->fetch($line->fk_product); 1022 $product->load_stock('warehouseopen'); // Load all $product->stock_warehouse[idwarehouse]->detail_batch 1023 //var_dump($product->stock_warehouse[1]); 1024 1025 print '<td>'; 1026 print '<a name="'.$line->id.'"></a>'; // ancre pour retourner sur la ligne 1027 print '<input type="hidden" name="productid'.$indiceAsked.'" value="'.$line->fk_product.'">'; 1028 1029 // Show product and description 1030 $product_static = $product; 1031 1032 $text = $product_static->getNomUrl(1); 1033 $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); 1034 $description = ($conf->global->PRODUIT_DESC_IN_FORM ? '' : dol_htmlentitiesbr($line->desc)); 1035 print $form->textwithtooltip($text, $description, 3, '', '', $i); 1036 1037 // Show range 1038 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); 1039 1040 // Add description in form 1041 if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) 1042 { 1043 print ($line->desc && $line->desc != $line->product_label) ? '<br>'.dol_htmlentitiesbr($line->desc) : ''; 1044 } 1045 1046 print '</td>'; 1047 } else { 1048 print "<td>"; 1049 if ($type == 1) $text = img_object($langs->trans('Service'), 'service'); 1050 else $text = img_object($langs->trans('Product'), 'product'); 1051 1052 if (!empty($line->label)) { 1053 $text .= ' <strong>'.$line->label.'</strong>'; 1054 print $form->textwithtooltip($text, $line->desc, 3, '', '', $i); 1055 } else { 1056 print $text.' '.nl2br($line->desc); 1057 } 1058 1059 // Show range 1060 print_date_range($db->jdate($line->date_start), $db->jdate($line->date_end)); 1061 print "</td>\n"; 1062 } 1063 1064 // Qty 1065 print '<td class="center">'.$line->qty; 1066 print '<input type="hidden" name="fk_commandefournisseurdet'.$indiceAsked.'" value="'.$line->id.'">'; 1067 print '<input type="hidden" name="pul'.$indiceAsked.'" value="'.$line->pu_ht.'">'; 1068 print '<input name="qtyasked'.$indiceAsked.'" id="qtyasked'.$indiceAsked.'" type="hidden" value="'.$line->qty.'">'; 1069 print '</td>'; 1070 $qtyProdCom = $line->qty; 1071 1072 // Qty already received 1073 print '<td class="center">'; 1074 $quantityDelivered = $objectsrc->receptions[$line->id]; 1075 print $quantityDelivered; 1076 print '<input name="qtydelivered'.$indiceAsked.'" id="qtydelivered'.$indiceAsked.'" type="hidden" value="'.$quantityDelivered.'">'; 1077 print '</td>'; 1078 1079 1080 if ($line->product_type == 1 && empty($conf->global->STOCK_SUPPORTS_SERVICES)) { 1081 $quantityToBeDelivered = 0; 1082 } else { 1083 $quantityToBeDelivered = $dispatchLines[$indiceAsked]['qty']; 1084 } 1085 $warehouse_id = $dispatchLines[$indiceAsked]['ent']; 1086 1087 1088 $warehouseObject = null; 1089 if (!empty($conf->stock->enabled)) // If warehouse was already selected or if product is not a predefined, we go into this part with no multiwarehouse selection 1090 { 1091 print '<!-- Case warehouse already known or product not a predefined product -->'; 1092 1093 $stock = + $product->stock_warehouse[$dispatchLines[$indiceAsked]['ent']]->real; // Convert to number 1094 $deliverableQty = $dispatchLines[$indiceAsked]['qty']; 1095 1096 // Quantity to send 1097 print '<td class="center">'; 1098 if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) 1099 { 1100 if (GETPOST('qtyl'.$indiceAsked, 'int')) $defaultqty = GETPOST('qtyl'.$indiceAsked, 'int'); 1101 print '<input name="idl'.$indiceAsked.'" type="hidden" value="'.$line->id.'">'; 1102 print '<input name="qtyl'.$indiceAsked.'" id="qtyl'.$indiceAsked.'" type="text" size="4" value="'.$deliverableQty.'">'; 1103 } else print $langs->trans("NA"); 1104 print '</td>'; 1105 1106 // Stock 1107 if (!empty($conf->stock->enabled)) 1108 { 1109 print '<td class="left">'; 1110 if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Type of product need stock change ? 1111 { 1112 // Show warehouse combo list 1113 $ent = "entl".$indiceAsked; 1114 $idl = "idl".$indiceAsked; 1115 $tmpentrepot_id = is_numeric(GETPOST($ent, 'int')) ?GETPOST($ent, 'int') : $warehouse_id; 1116 if ($line->fk_product > 0) 1117 { 1118 print '<!-- Show warehouse selection -->'; 1119 print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 0, 0, $line->fk_product, '', 1); 1120 } 1121 } else { 1122 print $langs->trans("Service"); 1123 } 1124 print '</td>'; 1125 } 1126 1127 if (!empty($conf->productbatch->enabled)) 1128 { 1129 if (!empty($product->status_batch)) 1130 { 1131 print '<td><input name="batch'.$indiceAsked.'" value="'.$dispatchLines[$indiceAsked]['lot'].'"></td>'; 1132 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { 1133 print '<td>'; 1134 print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); 1135 print '</td>'; 1136 } 1137 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { 1138 print '<td>'; 1139 print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); 1140 print '</td>'; 1141 } 1142 } else { 1143 print '<td colspan="3"></td>'; 1144 } 1145 } 1146 print "</tr>\n"; 1147 } 1148 1149 //Display lines extrafields 1150 if (is_array($extralabelslines) && count($extralabelslines) > 0) 1151 { 1152 $colspan = 5; 1153 if ($conf->productbatch->enabled) $colspan += 3; 1154 1155 $srcLine = new CommandeFournisseurLigne($db); 1156 $line = new CommandeFournisseurDispatch($db); 1157 1158 $extrafields->fetch_name_optionals_label($srcLine->table_element); 1159 $extrafields->fetch_name_optionals_label($line->table_element); 1160 1161 $srcLine->id = $line->id; 1162 $srcLine->fetch_optionals(); // fetch extrafields also available in orderline 1163 $line->fetch_optionals(); 1164 1165 $line->array_options = array_merge($line->array_options, $srcLine->array_options); 1166 1167 print $line->showOptionals($extrafields, 'edit', array('style'=>'class="oddeven"', 'colspan'=>$colspan), $indiceAsked); 1168 } 1169 1170 $indiceAsked++; 1171 } 1172 1173 print "</table>"; 1174 1175 print '<br>'; 1176 1177 print '<div class="center">'; 1178 print '<input type="submit" class="button" name="add" value="'.dol_escape_htmltag($langs->trans("Create")).'">'; 1179 print ' '; 1180 print '<input type="'.($backtopage ? "submit" : "button").'" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'"'.($backtopage ? '' : ' onclick="javascript:history.go(-1)"').'>'; // Cancel for create does not post form if we don't know the backtopage 1181 print '</div>'; 1182 1183 print '</form>'; 1184 1185 print '<br>'; 1186 } else { 1187 dol_print_error($db); 1188 } 1189 } 1190} elseif ($id || $ref) 1191/* *************************************************************************** */ 1192/* */ 1193/* Edit and view mode */ 1194/* */ 1195/* *************************************************************************** */ 1196{ 1197 $lines = $object->lines; 1198 1199 $num_prod = count($lines); 1200 1201 if ($object->id > 0) 1202 { 1203 if (!empty($object->origin) && $object->origin_id > 0) 1204 { 1205 $object->origin = 'CommandeFournisseur'; 1206 $typeobject = $object->origin; 1207 $origin = $object->origin; 1208 $origin_id = $object->origin_id; 1209 $object->fetch_origin(); // Load property $object->commande, $object->propal, ... 1210 } 1211 1212 $soc = new Societe($db); 1213 $soc->fetch($object->socid); 1214 1215 $res = $object->fetch_optionals(); 1216 1217 $head = reception_prepare_head($object); 1218 print dol_get_fiche_head($head, 'reception', $langs->trans("Reception"), -1, 'dollyrevert'); 1219 1220 $formconfirm = ''; 1221 1222 // Confirm deleteion 1223 if ($action == 'delete') 1224 { 1225 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteReception'), $langs->trans("ConfirmDeleteReception", $object->ref), 'confirm_delete', '', 0, 1); 1226 } 1227 1228 // Confirmation validation 1229 if ($action == 'valid') 1230 { 1231 $objectref = substr($object->ref, 1, 4); 1232 if ($objectref == 'PROV') 1233 { 1234 $numref = $object->getNextNumRef($soc); 1235 } else { 1236 $numref = $object->ref; 1237 } 1238 1239 $text = $langs->trans("ConfirmValidateReception", $numref); 1240 1241 if (!empty($conf->notification->enabled)) 1242 { 1243 require_once DOL_DOCUMENT_ROOT.'/core/class/notify.class.php'; 1244 $notify = new Notify($db); 1245 $text .= '<br>'; 1246 $text .= $notify->confirmMessage('RECEPTION_VALIDATE', $object->socid, $object); 1247 } 1248 1249 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('ValidateReception'), $text, 'confirm_valid', '', 0, 1); 1250 } 1251 1252 // Confirm cancelation 1253 if ($action == 'annuler') 1254 { 1255 $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('CancelReception'), $langs->trans("ConfirmCancelReception", $object->ref), 'confirm_cancel', '', 0, 1); 1256 } 1257 1258 if (!$formconfirm) { 1259 $parameters = array('formConfirm' => $formconfirm); 1260 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook 1261 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; 1262 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; 1263 } 1264 1265 // Print form confirm 1266 print $formconfirm; 1267 1268 1269 // Calculate totalWeight and totalVolume for all products 1270 // by adding weight and volume of each product line. 1271 $tmparray = $object->getTotalWeightVolume(); 1272 $totalWeight = $tmparray['weight']; 1273 $totalVolume = $tmparray['volume']; 1274 1275 1276 if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) 1277 { 1278 $objectsrc = new Commande($db); 1279 $objectsrc->fetch($object->$typeobject->id); 1280 } 1281 if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) 1282 { 1283 $objectsrc = new Propal($db); 1284 $objectsrc->fetch($object->$typeobject->id); 1285 } 1286 if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && !empty($conf->fournisseur->enabled)) 1287 { 1288 $objectsrc = new CommandeFournisseur($db); 1289 $objectsrc->fetch($object->$typeobject->id); 1290 } 1291 // Reception card 1292 $linkback = '<a href="'.DOL_URL_ROOT.'/reception/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; 1293 $morehtmlref = '<div class="refidno">'; 1294 // Ref customer reception 1295 1296 $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', 0, 1); 1297 $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, $user->rights->reception->creer, 'string', '', null, null, '', 1); 1298 1299 // Thirdparty 1300 $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); 1301 // Project 1302 if (!empty($conf->projet->enabled)) 1303 { 1304 $langs->load("projects"); 1305 $morehtmlref .= '<br>'.$langs->trans('Project').' '; 1306 if (0) { // Do not change on reception 1307 if ($action != 'classify') { 1308 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : '; 1309 } 1310 if ($action == 'classify') { 1311 // $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); 1312 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; 1313 $morehtmlref .= '<input type="hidden" name="action" value="classin">'; 1314 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; 1315 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); 1316 $morehtmlref .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'">'; 1317 $morehtmlref .= '</form>'; 1318 } else { 1319 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); 1320 } 1321 } else { 1322 // We don't have project on reception, so we will use the project or source object instead 1323 // TODO Add project on reception 1324 $morehtmlref .= ' : '; 1325 if (!empty($objectsrc->fk_project)) { 1326 $proj = new Project($db); 1327 $proj->fetch($objectsrc->fk_project); 1328 $morehtmlref .= '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$objectsrc->fk_project.'" title="'.$langs->trans('ShowProject').'">'; 1329 $morehtmlref .= $proj->ref; 1330 $morehtmlref .= '</a>'; 1331 } else { 1332 $morehtmlref .= ''; 1333 } 1334 } 1335 } 1336 $morehtmlref .= '</div>'; 1337 1338 $object->picto = 'sending'; 1339 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); 1340 1341 1342 print '<div class="fichecenter">'; 1343 print '<div class="fichehalfleft">'; 1344 print '<div class="underbanner clearboth"></div>'; 1345 1346 print '<table class="border centpercent">'; 1347 1348 // Linked documents 1349 if ($typeobject == 'commande' && $object->$typeobject->id && !empty($conf->commande->enabled)) 1350 { 1351 print '<tr><td>'; 1352 print $langs->trans("RefOrder").'</td>'; 1353 print '<td colspan="3">'; 1354 print $objectsrc->getNomUrl(1, 'commande'); 1355 print "</td>\n"; 1356 print '</tr>'; 1357 } 1358 if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) 1359 { 1360 print '<tr><td>'; 1361 print $langs->trans("RefProposal").'</td>'; 1362 print '<td colspan="3">'; 1363 print $objectsrc->getNomUrl(1, 'reception'); 1364 print "</td>\n"; 1365 print '</tr>'; 1366 } 1367 if ($typeobject == 'CommandeFournisseur' && $object->$typeobject->id && !empty($conf->propal->enabled)) 1368 { 1369 print '<tr><td>'; 1370 print $langs->trans("SupplierOrder").'</td>'; 1371 print '<td colspan="3">'; 1372 print $objectsrc->getNomUrl(1, 'reception'); 1373 print "</td>\n"; 1374 print '</tr>'; 1375 } 1376 1377 // Date creation 1378 print '<tr><td class="titlefield">'.$langs->trans("DateCreation").'</td>'; 1379 print '<td colspan="3">'.dol_print_date($object->date_creation, "dayhour")."</td>\n"; 1380 print '</tr>'; 1381 1382 // Delivery date planned 1383 print '<tr><td height="10">'; 1384 print '<table class="nobordernopadding" width="100%"><tr><td>'; 1385 print $langs->trans('DateDeliveryPlanned'); 1386 print '</td>'; 1387 1388 if ($action != 'editdate_livraison') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&id='.$object->id.'">'.img_edit($langs->trans('SetDeliveryDate'), 1).'</a></td>'; 1389 print '</tr></table>'; 1390 print '</td><td colspan="2">'; 1391 if ($action == 'editdate_livraison') 1392 { 1393 print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; 1394 print '<input type="hidden" name="token" value="'.newToken().'">'; 1395 print '<input type="hidden" name="action" value="setdate_livraison">'; 1396 print $form->selectDate($object->date_delivery ? $object->date_delivery : -1, 'liv_', 1, 1, '', "setdate_livraison", 1, 0); 1397 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 1398 print '</form>'; 1399 } else { 1400 print $object->date_delivery ? dol_print_date($object->date_delivery, 'dayhour') : ' '; 1401 } 1402 print '</td>'; 1403 print '</tr>'; 1404 1405 // Weight 1406 print '<tr><td>'; 1407 print $form->editfieldkey("Weight", 'trueWeight', $object->trueWeight, $object, $user->rights->reception->creer); 1408 print '</td><td colspan="3">'; 1409 1410 if ($action == 'edittrueWeight') 1411 { 1412 print '<form name="settrueweight" action="'.$_SERVER["PHP_SELF"].'" method="post">'; 1413 print '<input name="action" value="settrueWeight" type="hidden">'; 1414 print '<input name="id" value="'.$object->id.'" type="hidden">'; 1415 print '<input type="hidden" name="token" value="'.newToken().'">'; 1416 print '<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.'" type="text">'; 1417 print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); 1418 print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; 1419 print ' <input class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; 1420 print '</form>'; 1421 } else { 1422 print $object->trueWeight; 1423 print ($object->trueWeight && $object->weight_units != '') ? ' '.measuringUnitString(0, "weight", $object->weight_units) : ''; 1424 } 1425 1426 // Calculated 1427 if ($totalWeight > 0) 1428 { 1429 if (!empty($object->trueWeight)) print ' ('.$langs->trans("SumOfProductWeights").': '; 1430 print showDimensionInBestUnit($totalWeight, 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND) ? $conf->global->MAIN_WEIGHT_DEFAULT_ROUND : -1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? $conf->global->MAIN_WEIGHT_DEFAULT_UNIT : 'no'); 1431 if (!empty($object->trueWeight)) print ')'; 1432 } 1433 print '</td></tr>'; 1434 1435 // Width 1436 print '<tr><td>'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer).'</td><td colspan="3">'; 1437 print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->reception->creer); 1438 print ($object->trueWidth && $object->width_units != '') ? ' '.measuringUnitString(0, "size", $object->width_units) : ''; 1439 print '</td></tr>'; 1440 1441 // Height 1442 print '<tr><td>'.$form->editfieldkey("Height", 'trueHeight', $object->trueHeight, $object, $user->rights->reception->creer).'</td><td colspan="3">'; 1443 if ($action == 'edittrueHeight') 1444 { 1445 print '<form name="settrueHeight" action="'.$_SERVER["PHP_SELF"].'" method="post">'; 1446 print '<input name="action" value="settrueHeight" type="hidden">'; 1447 print '<input name="id" value="'.$object->id.'" type="hidden">'; 1448 print '<input type="hidden" name="token" value="'.newToken().'">'; 1449 print '<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.'" type="text">'; 1450 print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); 1451 print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; 1452 print ' <input class="button button-cancel" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; 1453 print '</form>'; 1454 } else { 1455 print $object->trueHeight; 1456 print ($object->trueHeight && $object->height_units != '') ? ' '.measuringUnitString(0, "size", $object->height_units) : ''; 1457 } 1458 1459 print '</td></tr>'; 1460 1461 // Depth 1462 print '<tr><td>'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer).'</td><td colspan="3">'; 1463 print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->reception->creer); 1464 print ($object->trueDepth && $object->depth_units != '') ? ' '.measuringUnitString(0, "size", $object->depth_units) : ''; 1465 print '</td></tr>'; 1466 1467 // Volume 1468 print '<tr><td>'; 1469 print $langs->trans("Volume"); 1470 print '</td>'; 1471 print '<td colspan="3">'; 1472 $calculatedVolume = 0; 1473 $volumeUnit = 0; 1474 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) 1475 { 1476 $calculatedVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth); 1477 $volumeUnit = $object->size_units * 3; 1478 } 1479 // If reception volume not defined we use sum of products 1480 if ($calculatedVolume > 0) 1481 { 1482 if ($volumeUnit < 50) 1483 { 1484 print showDimensionInBestUnit($calculatedVolume, $volumeUnit, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); 1485 } else print $calculatedVolume.' '.measuringUnitString(0, "volume", $volumeUnit); 1486 } 1487 if ($totalVolume > 0) 1488 { 1489 if ($calculatedVolume) print ' ('.$langs->trans("SumOfProductVolumes").': '; 1490 print showDimensionInBestUnit($totalVolume, 0, "volume", $langs, isset($conf->global->MAIN_VOLUME_DEFAULT_ROUND) ? $conf->global->MAIN_VOLUME_DEFAULT_ROUND : -1, isset($conf->global->MAIN_VOLUME_DEFAULT_UNIT) ? $conf->global->MAIN_VOLUME_DEFAULT_UNIT : 'no'); 1491 //if (empty($calculatedVolume)) print ' ('.$langs->trans("Calculated").')'; 1492 if ($calculatedVolume) print ')'; 1493 } 1494 print "</td>\n"; 1495 print '</tr>'; 1496 1497 // Other attributes 1498 $cols = 2; 1499 1500 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; 1501 1502 print '</table>'; 1503 1504 print '</div>'; 1505 print '<div class="fichehalfright">'; 1506 print '<div class="ficheaddleft">'; 1507 print '<div class="underbanner clearboth"></div>'; 1508 1509 print '<table class="border centpercent">'; 1510 1511 // Reception method 1512 print '<tr><td height="10">'; 1513 print '<table class="nobordernopadding" width="100%"><tr><td>'; 1514 print $langs->trans('ReceptionMethod'); 1515 print '</td>'; 1516 1517 if ($action != 'editshipping_method_id') print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editshipping_method_id&id='.$object->id.'">'.img_edit($langs->trans('SetReceptionMethod'), 1).'</a></td>'; 1518 print '</tr></table>'; 1519 print '</td><td colspan="2">'; 1520 if ($action == 'editshipping_method_id') 1521 { 1522 print '<form name="setshipping_method_id" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="post">'; 1523 print '<input type="hidden" name="token" value="'.newToken().'">'; 1524 print '<input type="hidden" name="action" value="setshipping_method_id">'; 1525 $object->fetch_delivery_methods(); 1526 print $form->selectarray("shipping_method_id", $object->meths, $object->shipping_method_id, 1, 0, 0, "", 1); 1527 if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); 1528 print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">'; 1529 print '</form>'; 1530 } else { 1531 if ($object->shipping_method_id > 0) 1532 { 1533 // Get code using getLabelFromKey 1534 $code = $langs->getLabelFromKey($db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); 1535 print $langs->trans("SendingMethod".strtoupper($code)); 1536 } 1537 } 1538 print '</td>'; 1539 print '</tr>'; 1540 1541 // Tracking Number 1542 1543 print '<tr><td class="titlefield">'.$form->editfieldkey("TrackingNumber", 'tracking_number', $object->tracking_number, $object, $user->rights->reception->creer).'</td><td colspan="3">'; 1544 print $form->editfieldval("TrackingNumber", 'tracking_number', $object->tracking_url, $object, $user->rights->reception->creer, 'string', $object->tracking_number); 1545 print '</td></tr>'; 1546 1547 // Incoterms 1548 if (!empty($conf->incoterm->enabled)) 1549 { 1550 print '<tr><td>'; 1551 print '<table width="100%" class="nobordernopadding"><tr><td>'; 1552 print $langs->trans('IncotermLabel'); 1553 print '<td><td class="right">'; 1554 if ($user->rights->reception->creer) print '<a class="editfielda" href="'.DOL_URL_ROOT.'/reception/card.php?id='.$object->id.'&action=editincoterm">'.img_edit().'</a>'; 1555 else print ' '; 1556 print '</td></tr></table>'; 1557 print '</td>'; 1558 print '<td colspan="3">'; 1559 if ($action != 'editincoterm') 1560 { 1561 print $form->textwithpicto($object->display_incoterms(), $object->label_incoterms, 1); 1562 } else { 1563 print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : ''), $_SERVER['PHP_SELF'].'?id='.$object->id); 1564 } 1565 print '</td></tr>'; 1566 } 1567 1568 print "</table>"; 1569 1570 print '</div>'; 1571 print '</div>'; 1572 print '</div>'; 1573 1574 print '<div class="clearboth"></div>'; 1575 1576 1577 // Lines of products 1578 if ($action == 'editline') 1579 { 1580 print '<form name="updateline" id="updateline" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$line_id.'" method="POST"> 1581 <input type="hidden" name="token" value="' . newToken().'"> 1582 <input type="hidden" name="action" value="updateline"> 1583 <input type="hidden" name="mode" value=""> 1584 <input type="hidden" name="id" value="' . $object->id.'">'; 1585 } 1586 print '<br>'; 1587 1588 print '<div class="div-table-responsive-no-min">'; 1589 print '<table class="noborder centpercent">'; 1590 print '<tr class="liste_titre">'; 1591 // # 1592 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) 1593 { 1594 print '<td width="5" class="center"> </td>'; 1595 } 1596 // Product/Service 1597 print '<td>'.$langs->trans("Products").'</td>'; 1598 // Comment 1599 print '<td>'.$langs->trans("Description").'</td>'; 1600 // Qty 1601 print '<td class="center">'.$langs->trans("QtyOrdered").'</td>'; 1602 if ($origin && $origin_id > 0) 1603 { 1604 print '<td class="center">'.$langs->trans("QtyInOtherReceptions").'</td>'; 1605 } 1606 if ($action == 'editline') 1607 { 1608 $editColspan = 3; 1609 if (empty($conf->stock->enabled)) $editColspan--; 1610 if (empty($conf->productbatch->enabled)) $editColspan--; 1611 print '<td class="center" colspan="'.$editColspan.'">'; 1612 if ($object->statut <= 1) 1613 { 1614 print $langs->trans("QtyToReceive").' - '; 1615 } else { 1616 print $langs->trans("QtyReceived").' - '; 1617 } 1618 if (!empty($conf->stock->enabled)) 1619 { 1620 print $langs->trans("WarehouseSource").' - '; 1621 } 1622 if (!empty($conf->productbatch->enabled)) 1623 { 1624 print $langs->trans("Batch"); 1625 } 1626 print '</td>'; 1627 } else { 1628 if ($object->statut <= 1) 1629 { 1630 print '<td class="center">'.$langs->trans("QtyToReceive").'</td>'; 1631 } else { 1632 print '<td class="center">'.$langs->trans("QtyReceived").'</td>'; 1633 } 1634 if (!empty($conf->stock->enabled)) 1635 { 1636 print '<td class="left">'.$langs->trans("WarehouseSource").'</td>'; 1637 } 1638 1639 if (!empty($conf->productbatch->enabled)) 1640 { 1641 print '<td class="left">'.$langs->trans("Batch").'</td>'; 1642 } 1643 } 1644 print '<td class="center">'.$langs->trans("CalculatedWeight").'</td>'; 1645 print '<td class="center">'.$langs->trans("CalculatedVolume").'</td>'; 1646 //print '<td class="center">'.$langs->trans("Size").'</td>'; 1647 if ($object->statut == 0) 1648 { 1649 print '<td class="linecoledit"></td>'; 1650 print '<td class="linecoldelete" width="10"></td>'; 1651 } 1652 print "</tr>\n"; 1653 1654 $var = false; 1655 1656 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) 1657 { 1658 $object->fetch_thirdparty(); 1659 $outputlangs = $langs; 1660 $newlang = ''; 1661 if (empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); 1662 if (empty($newlang)) $newlang = $object->thirdparty->default_lang; 1663 if (!empty($newlang)) 1664 { 1665 $outputlangs = new Translate("", $conf); 1666 $outputlangs->setDefaultLang($newlang); 1667 } 1668 } 1669 1670 // Get list of products already sent for same source object into $alreadysent 1671 $alreadysent = array(); 1672 1673 $origin = 'commande_fournisseur'; 1674 1675 if ($origin && $origin_id > 0) 1676 { 1677 $sql = "SELECT obj.rowid, obj.fk_product, obj.label, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked, obj.date_start, obj.date_end"; 1678 $sql .= ", ed.rowid as receptionline_id, ed.qty, ed.fk_reception as reception_id, ed.fk_entrepot"; 1679 $sql .= ", e.rowid as reception_id, e.ref as reception_ref, e.date_creation, e.date_valid, e.date_delivery, e.date_reception"; 1680 //if ($conf->delivery_note->enabled) $sql .= ", l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received"; 1681 $sql .= ', p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid, p.tobatch as product_tobatch'; 1682 $sql .= ', p.description as product_desc'; 1683 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; 1684 $sql .= ", ".MAIN_DB_PREFIX."reception as e"; 1685 $sql .= ", ".MAIN_DB_PREFIX.$origin."det as obj"; 1686 //if ($conf->delivery_note->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."delivery as l ON l.fk_reception = e.rowid LEFT JOIN ".MAIN_DB_PREFIX."deliverydet as ld ON ld.fk_delivery = l.rowid AND obj.rowid = ld.fk_origin_line"; 1687 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON obj.fk_product = p.rowid"; 1688 $sql .= " WHERE e.entity IN (".getEntity('reception').")"; 1689 $sql .= " AND obj.fk_commande = ".$origin_id; 1690 $sql .= " AND obj.rowid = ed.fk_commandefourndet"; 1691 $sql .= " AND ed.fk_reception = e.rowid"; 1692 $sql .= " AND ed.fk_reception !=".$object->id; 1693 //if ($filter) $sql.= $filter; 1694 $sql .= " ORDER BY obj.fk_product"; 1695 1696 dol_syslog("get list of reception lines", LOG_DEBUG); 1697 $resql = $db->query($sql); 1698 if ($resql) 1699 { 1700 $num = $db->num_rows($resql); 1701 $i = 0; 1702 1703 while ($i < $num) 1704 { 1705 $obj = $db->fetch_object($resql); 1706 if ($obj) 1707 { 1708 // $obj->rowid is rowid in $origin."det" table 1709 $alreadysent[$obj->rowid][$obj->receptionline_id] = array('reception_ref'=>$obj->reception_ref, 'reception_id'=>$obj->reception_id, 'warehouse'=>$obj->fk_entrepot, 'qty'=>$obj->qty, 'date_valid'=>$obj->date_valid, 'date_delivery'=>$obj->date_delivery); 1710 } 1711 $i++; 1712 } 1713 } 1714 //var_dump($alreadysent); 1715 } 1716 1717 // Loop on each product to send/sent 1718 for ($i = 0; $i < $num_prod; $i++) 1719 { 1720 print '<!-- origin line id = '.$lines[$i]->origin_line_id.' -->'; // id of order line 1721 print '<tr class="oddeven">'; 1722 1723 // # 1724 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) 1725 { 1726 print '<td class="center">'.($i + 1).'</td>'; 1727 } 1728 1729 // Predefined product or service 1730 if ($lines[$i]->fk_product > 0) 1731 { 1732 // Define output language 1733 if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) 1734 { 1735 $prod = new Product($db); 1736 $prod->fetch($lines[$i]->fk_product); 1737 $label = (!empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $lines[$i]->product->label; 1738 } else $label = (!empty($lines[$i]->product->label) ? $lines[$i]->product->label : $lines[$i]->product->product_label); 1739 1740 print '<td>'; 1741 1742 $text = $lines[$i]->product->getNomUrl(1); 1743 $text .= ' - '.$label; 1744 $description = (!empty($conf->global->PRODUIT_DESC_IN_FORM) ? '' : dol_htmlentitiesbr($lines[$i]->product->description)); 1745 print $form->textwithtooltip($text, $description, 3, '', '', $i); 1746 print_date_range($lines[$i]->date_start, $lines[$i]->date_end); 1747 if (!empty($conf->global->PRODUIT_DESC_IN_FORM)) 1748 { 1749 print (!empty($lines[$i]->product->description) && $lines[$i]->description != $lines[$i]->product->description) ? '<br>'.dol_htmlentitiesbr($lines[$i]->description) : ''; 1750 } 1751 print "</td>\n"; 1752 } else { 1753 print "<td>"; 1754 if ($lines[$i]->product_type == Product::TYPE_SERVICE) $text = img_object($langs->trans('Service'), 'service'); 1755 else $text = img_object($langs->trans('Product'), 'product'); 1756 1757 if (!empty($lines[$i]->label)) { 1758 $text .= ' <strong>'.$lines[$i]->label.'</strong>'; 1759 print $form->textwithtooltip($text, $lines[$i]->description, 3, '', '', $i); 1760 } else { 1761 print $text.' '.nl2br($lines[$i]->description); 1762 } 1763 1764 print_date_range($lines[$i]->date_start, $lines[$i]->date_end); 1765 print "</td>\n"; 1766 } 1767 1768 if ($action == 'editline' && $lines[$i]->id == $line_id) 1769 { 1770 print '<td><textarea name="comment'.$line_id.'" id="comment'.$line_id.'" /> '.$lines[$i]->comment.'</textarea></td>'; 1771 } else { 1772 print '<td style="white-space: pre-wrap;max-width: 200px;" >'.$lines[$i]->comment.'</td>'; 1773 } 1774 1775 1776 // Qty ordered 1777 print '<td class="center">'.$lines[$i]->qty_asked.'</td>'; 1778 1779 // Qty in other receptions (with reception and warehouse used) 1780 if ($origin && $origin_id > 0) 1781 { 1782 print '<td class="center nowrap">'; 1783 foreach ($alreadysent as $key => $val) 1784 { 1785 if ($lines[$i]->fk_commandefourndet == $key) 1786 { 1787 $j = 0; 1788 foreach ($val as $receptionline_id=> $receptionline_var) 1789 { 1790 if ($receptionline_var['reception_id'] == $lines[$i]->fk_reception) continue; // We want to show only "other receptions" 1791 1792 $j++; 1793 if ($j > 1) print '<br>'; 1794 $reception_static->fetch($receptionline_var['reception_id']); 1795 print $reception_static->getNomUrl(1); 1796 print ' - '.$receptionline_var['qty']; 1797 1798 $htmltext = $langs->trans("DateValidation").' : '.(empty($receptionline_var['date_valid']) ? $langs->trans("Draft") : dol_print_date($receptionline_var['date_valid'], 'dayhour')); 1799 if (!empty($conf->stock->enabled) && $receptionline_var['warehouse'] > 0) 1800 { 1801 $warehousestatic->fetch($receptionline_var['warehouse']); 1802 $htmltext .= '<br>'.$langs->trans("From").' : '.$warehousestatic->getNomUrl(1); 1803 } 1804 print ' '.$form->textwithpicto('', $htmltext, 1); 1805 } 1806 } 1807 } 1808 } 1809 print '</td>'; 1810 1811 if ($action == 'editline' && $lines[$i]->id == $line_id) 1812 { 1813 // edit mode 1814 print '<td colspan="'.$editColspan.'" class="center"><table class="nobordernopadding">'; 1815 if (!empty($conf->stock->enabled)) 1816 { 1817 if ($lines[$i]->fk_product > 0) 1818 { 1819 print '<!-- case edit 1 -->'; 1820 print '<tr>'; 1821 // Qty to receive or received 1822 print '<td><input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty.'"></td>'; 1823 // Warehouse source 1824 print '<td>'.$formproduct->selectWarehouses($lines[$i]->fk_entrepot, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).'</td>'; 1825 // Batch number managment 1826 if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) 1827 { 1828 print '<td> <input name="batch'.$line_id.'" id="batch'.$line_id.'" type="text" value="'.$lines[$i]->batch.'"> </br>'; 1829 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { 1830 print $langs->trans('SellByDate').' : '; 1831 print $form->selectDate($lines[$i]->sellby, 'dlc'.$line_id, '', '', 1, "").'</br>'; 1832 } 1833 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { 1834 print $langs->trans('EatByDate').' : '; 1835 print $form->selectDate($lines[$i]->eatby, 'dluo'.$line_id, '', '', 1, ""); 1836 } 1837 print '</td>'; 1838 } 1839 print '</tr>'; 1840 } else { 1841 print '<!-- case edit 2 -->'; 1842 print '<tr>'; 1843 // Qty to receive or received 1844 print '<td><input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty.'"></td>'; 1845 // Warehouse source 1846 print '<td></td>'; 1847 // Batch number managment 1848 print '<td></td>'; 1849 print '</tr>'; 1850 } 1851 } 1852 print '</table></td>'; 1853 } else { 1854 // Qty to receive or received 1855 print '<td class="center">'.$lines[$i]->qty.'</td>'; 1856 1857 // Warehouse source 1858 if (!empty($conf->stock->enabled)) 1859 { 1860 print '<td class="left">'; 1861 1862 if ($lines[$i]->fk_entrepot > 0) 1863 { 1864 $entrepot = new Entrepot($db); 1865 $entrepot->fetch($lines[$i]->fk_entrepot); 1866 print $entrepot->getNomUrl(1); 1867 } 1868 1869 print '</td>'; 1870 } 1871 1872 // Batch number managment 1873 if (!empty($conf->productbatch->enabled)) 1874 { 1875 if (isset($lines[$i]->batch)) 1876 { 1877 print '<!-- Detail of lot -->'; 1878 print '<td>'; 1879 $detail = ''; 1880 if ($lines[$i]->product->status_batch) 1881 { 1882 $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; 1883 if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { 1884 $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); 1885 } 1886 if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { 1887 $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); 1888 } 1889 $detail .= '<br>'; 1890 1891 print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); 1892 } else { 1893 print $langs->trans("NA"); 1894 } 1895 print '</td>'; 1896 } else { 1897 print '<td></td>'; 1898 } 1899 } 1900 } 1901 1902 // Weight 1903 print '<td class="center">'; 1904 if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->weight * $lines[$i]->qty.' '.measuringUnitString(0, "weight", $lines[$i]->product->weight_units); 1905 else print ' '; 1906 print '</td>'; 1907 1908 // Volume 1909 print '<td class="center">'; 1910 if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->product->volume * $lines[$i]->qty.' '.measuringUnitString(0, "volume", $lines[$i]->product->volume_units); 1911 else print ' '; 1912 print '</td>'; 1913 1914 1915 if ($action == 'editline' && $lines[$i]->id == $line_id) 1916 { 1917 print '<td class="center" colspan="2" valign="middle">'; 1918 print '<input type="submit" class="button button-save" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans("Save").'"><br>'; 1919 print '<input type="submit" class="button button-cancel" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'"><br>'; 1920 } elseif ($object->statut == Reception::STATUS_DRAFT) 1921 { 1922 // edit-delete buttons 1923 print '<td class="linecoledit center">'; 1924 print '<a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=editline&token='.newToken().'&lineid='.$lines[$i]->id.'">'.img_edit().'</a>'; 1925 print '</td>'; 1926 print '<td class="linecoldelete" width="10">'; 1927 print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=deleteline&token='.newToken().'&lineid='.$lines[$i]->id.'">'.img_delete().'</a>'; 1928 print '</td>'; 1929 1930 // Display lines extrafields 1931 if (!empty($rowExtrafieldsStart)) 1932 { 1933 print $rowExtrafieldsStart; 1934 print $rowExtrafieldsView; 1935 print $rowEnd; 1936 } 1937 } 1938 print "</tr>"; 1939 1940 // Display lines extrafields 1941 if (is_array($extralabelslines) && count($extralabelslines) > 0) 1942 { 1943 $colspan = empty($conf->productbatch->enabled) ? 8 : 9; 1944 $line = new CommandeFournisseurDispatch($db); 1945 $line->id = $lines[$i]->id; 1946 $line->fetch_optionals(); 1947 1948 if ($action == 'editline' && $lines[$i]->id == $line_id) 1949 { 1950 print $line->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked); 1951 } else { 1952 print $line->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked); 1953 } 1954 } 1955 } 1956 1957 // TODO Show also lines ordered but not delivered 1958 1959 print "</table>\n"; 1960 print '</div>'; 1961 } 1962 1963 1964 print dol_get_fiche_end(); 1965 1966 1967 $object->fetchObjectLinked($object->id, $object->element); 1968 1969 1970 /* 1971 * Boutons actions 1972 */ 1973 1974 if (($user->socid == 0) && ($action != 'presend')) 1975 { 1976 print '<div class="tabsAction">'; 1977 1978 $parameters = array(); 1979 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook 1980 if (empty($reshook)) 1981 { 1982 if ($object->statut == Reception::STATUS_DRAFT && $num_prod > 0) 1983 { 1984 if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->creer)) 1985 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->reception->reception_advance->validate))) 1986 { 1987 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>'; 1988 } else { 1989 print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("Validate").'</a>'; 1990 } 1991 } 1992 // Edit 1993 if ($object->statut == Reception::STATUS_VALIDATED && $user->rights->reception->creer) { 1994 print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modif">'.$langs->trans('Modify').'</a></div>'; 1995 } 1996 1997 // TODO add alternative status 1998 // 0=draft, 1=validated, 2=billed, we miss a status "delivered" (only available on order) 1999 if ($object->statut == Reception::STATUS_CLOSED && $user->rights->reception->creer) 2000 { 2001 if (!empty($conf->facture->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? 2002 { 2003 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ClassifyUnbilled").'</a>'; 2004 } else { 2005 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>'; 2006 } 2007 } 2008 2009 // Send 2010 if (empty($user->socid)) { 2011 if ($object->statut > 0) 2012 { 2013 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->reception->reception_advance->send) 2014 { 2015 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendByMail').'</a>'; 2016 } else print '<a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a>'; 2017 } 2018 } 2019 2020 // Create bill 2021 if (!empty($conf->fournisseur->enabled) && ($object->statut == Reception::STATUS_VALIDATED || $object->statut == Reception::STATUS_CLOSED)) 2022 { 2023 if ($user->rights->fournisseur->facture->creer) 2024 { 2025 // TODO show button only if (! empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) 2026 // If we do that, we must also make this option official. 2027 print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>'; 2028 } 2029 } 2030 2031 2032 // Close 2033 if ($object->statut == Reception::STATUS_VALIDATED) 2034 { 2035 if ($user->rights->reception->creer && $object->statut > 0 && !$object->billed) 2036 { 2037 $label = "Close"; $paramaction = 'classifyclosed'; // = Transferred/Received 2038 // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on receptions instead of orders 2039 if (!empty($conf->fournisseur->enabled) && !empty($conf->global->WORKFLOW_BILL_ON_RECEPTION)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? 2040 { 2041 $label = "ClassifyBilled"; 2042 $paramaction = 'classifybilled'; 2043 } 2044 print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action='.$paramaction.'">'.$langs->trans($label).'</a>'; 2045 } 2046 } 2047 2048 if ($user->rights->reception->supprimer) 2049 { 2050 print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a>'; 2051 } 2052 } 2053 2054 print '</div>'; 2055 } 2056 2057 2058 /* 2059 * Documents generated 2060 */ 2061 2062 if ($action != 'presend' && $action != 'editline') 2063 { 2064 print '<div class="fichecenter"><div class="fichehalfleft">'; 2065 2066 $objectref = dol_sanitizeFileName($object->ref); 2067 $filedir = $conf->reception->dir_output."/".$objectref; 2068 2069 $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; 2070 2071 $genallowed = $user->rights->reception->lire; 2072 $delallowed = $user->rights->reception->creer; 2073 2074 print $formfile->showdocuments('reception', $objectref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); 2075 2076 // Show links to link elements 2077 //$linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); 2078 $somethingshown = $form->showLinkedObjectBlock($object, ''); 2079 2080 print '</div><div class="fichehalfright"><div class="ficheaddleft">'; 2081 } 2082 2083 // Presend form 2084 $modelmail = 'shipping_send'; 2085 $defaulttopic = 'SendReceptionRef'; 2086 $diroutput = $conf->reception->dir_output; 2087 $trackid = 'rec'.$object->id; 2088 2089 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; 2090} 2091 2092 2093llxFooter(); 2094 2095$db->close(); 2096