diff --git a/htdocs/mrp/mo_production.php b/htdocs/mrp/mo_production.php
index c376cc80cae..4849eacd108 100644
--- a/htdocs/mrp/mo_production.php
+++ b/htdocs/mrp/mo_production.php
@@ -90,13 +90,14 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
// Security check - Protection if external user
//if ($user->socid > 0) access_forbidden();
//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->statut == Mo::STATUS_DRAFT) ? 1 : 0);
+//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
//$result = restrictedArea($user, 'mrp', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissionnote = $user->rights->mrp->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->mrp->write; // Used by the include of actions_dellink.inc.php
$permissiontoadd = $user->rights->mrp->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
-$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && $object->status == 0);
+$permissiontodelete = $user->rights->mrp->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+$upload_dir = $conf->mrp->multidir_output[isset($object->entity)?$object->entity:1];
/*
@@ -130,7 +131,13 @@ if (empty($reshook))
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
-
+
+ // Actions to send emails
+ $trigger_name = 'MO_SENTBYMAIL';
+ $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO';
+ $trackid = 'mo'.$object->id;
+ include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
+
// Action to move up and down lines of object
//include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
@@ -142,12 +149,6 @@ if (empty($reshook))
{
$object->setProject(GETPOST('projectid', 'int'));
}
-
- // Actions to send emails
- $trigger_name = 'MO_SENTBYMAIL';
- $autocopy = 'MAIN_MAIL_AUTOCOPY_MO_TO';
- $trackid = 'mo'.$object->id;
- include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
}
@@ -158,6 +159,7 @@ if (empty($reshook))
*/
$form = new Form($db);
+$formfile = new FormFile($db);
$formproject = new FormProjets($db);
llxHeader('', $langs->trans('Mo'), '');
@@ -182,7 +184,8 @@ jQuery(document).ready(function() {
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
- $res = $object->fetch_optionals();
+ $res = $object->fetch_thirdparty();
+ $res = $object->fetch_optionals();
$head = moPrepareHead($object);
dol_fiche_head($head, 'production', $langs->trans("MO"), -1, $object->picto);
@@ -243,26 +246,26 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mrp->creer, 'string', '', null, null, '', 1);*/
// Thirdparty
- $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
+ $morehtmlref .= $langs->trans('ThirdParty').' : '.(is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '');
// Project
if (!empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref .= '
'.$langs->trans('Project').' ';
- if ($user->rights->mrp->write)
+ if ($permissiontoadd)
{
if ($action != 'classify')
$morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->fk_soc, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '