diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 0247514b2a4..074216dee3e 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -178,6 +178,7 @@ class DolibarrApi
unset($object->lines[$i]->cond_reglement);
unset($object->lines[$i]->fk_delivery_address);
unset($object->lines[$i]->fk_projet);
+ unset($object->lines[$i]->fk_project);
unset($object->lines[$i]->thirdparty);
unset($object->lines[$i]->user);
unset($object->lines[$i]->model_pdf);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index abd8e38ce97..838670b58c0 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1882,13 +1882,19 @@ abstract class CommonObject
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- if ($this->table_element == 'actioncomm')
+ if (! empty($this->fields['fk_project'])) // Common case
+ {
+ if ($projectid) $sql.= ' SET fk_project = '.$projectid;
+ else $sql.= ' SET fk_project = NULL';
+ $sql.= ' WHERE rowid = '.$this->id;
+ }
+ elseif ($this->table_element == 'actioncomm') // Special case for actioncomm
{
if ($projectid) $sql.= ' SET fk_project = '.$projectid;
else $sql.= ' SET fk_project = NULL';
$sql.= ' WHERE id = '.$this->id;
}
- else
+ else // Special case for old architecture objects
{
if ($projectid) $sql.= ' SET fk_projet = '.$projectid;
else $sql.= ' SET fk_projet = NULL';
diff --git a/htdocs/don/list.php b/htdocs/don/list.php
index 5728e6fc2aa..bdc6c45168d 100644
--- a/htdocs/don/list.php
+++ b/htdocs/don/list.php
@@ -211,7 +211,7 @@ if ($resql)
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
- print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "fk_projet", "", $param, "", $sortfield, $sortorder);
+ print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
}
print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "d.amount", "", $param, '', $sortfield, $sortorder, 'right ');
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.fk_statut", "", $param, '', $sortfield, $sortorder, 'right ');
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index 95b9e0cd1f5..7a62903dfe6 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -57,7 +57,7 @@ $confirm = GETPOST('confirm', 'alpha');
$date_start = dol_mktime(0, 0, 0, GETPOST('date_debutmonth', 'int'), GETPOST('date_debutday', 'int'), GETPOST('date_debutyear', 'int'));
$date_end = dol_mktime(0, 0, 0, GETPOST('date_finmonth', 'int'), GETPOST('date_finday', 'int'), GETPOST('date_finyear', 'int'));
$date = dol_mktime(0, 0, 0, GETPOST('datemonth', 'int'), GETPOST('dateday', 'int'), GETPOST('dateyear', 'int'));
-$fk_projet=GETPOST('fk_projet', 'int');
+$fk_project=GETPOST('fk_project', 'int');
$vatrate=GETPOST('vatrate', 'alpha');
$ref=GETPOST("ref", 'alpha');
$comments=GETPOST('comments', 'none');
@@ -145,7 +145,7 @@ if (empty($reshook))
}
$action='';
- $fk_projet='';
+ $fk_project='';
$date_start='';
$date_end='';
$date='';
@@ -1232,7 +1232,7 @@ if (empty($reshook))
$type = 0; // TODO What if service ? We should take the type product/service from the type of expense report llx_c_type_fees
// Insert line
- $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_projet, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
+ $result = $object->addline($qty, $value_unit, $fk_c_type_fees, $vatrate, $date, $comments, $fk_project, $fk_c_exp_tax_cat, $type, $fk_ecm_files);
if ($result > 0)
{
$ret = $object->fetch($object->id); // Reload to get new records
@@ -1257,7 +1257,7 @@ if (empty($reshook))
unset($vatrate);
unset($comments);
unset($fk_c_type_fees);
- unset($fk_projet);
+ unset($fk_project);
unset($date);
} else {
@@ -1334,7 +1334,7 @@ if (empty($reshook))
$rowid = $_POST['rowid'];
$type_fees_id = GETPOST('fk_c_type_fees', 'int');
$fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat', 'int');
- $projet_id = $fk_projet;
+ $projet_id = $fk_project;
$comments = GETPOST('comments', 'none');
$qty = GETPOST('qty', 'int');
$vatrate = GETPOST('vatrate', 'alpha');
@@ -2372,7 +2372,7 @@ else
if (! empty($conf->projet->enabled))
{
print '
';
- $formproject->select_projects(-1, $line->fk_project, 'fk_projet', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300');
+ $formproject->select_projects(-1, $line->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth300');
print ' | ';
}
@@ -2527,7 +2527,7 @@ else
if (! empty($conf->projet->enabled))
{
print '';
- $formproject->select_projects(-1, $fk_projet, 'fk_projet', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
+ $formproject->select_projects(-1, $fk_project, 'fk_project', 0, 0, 1, -1, 0, 0, 0, '', 0, 0, 'maxwidth300');
print ' | ';
}
diff --git a/htdocs/fichinter/card-rec.php b/htdocs/fichinter/card-rec.php
index fcdf155955d..caead930491 100644
--- a/htdocs/fichinter/card-rec.php
+++ b/htdocs/fichinter/card-rec.php
@@ -158,12 +158,10 @@ if ($action == 'add') {
// on récupère les enregistrements
$object->fetch($id);
-
// on transfert les données de l'un vers l'autre
if ($object->socid > 0) {
$newinter->socid=$object->socid;
- $newinter->fk_projet=$object->fk_projet;
- $newinter->fk_project=$object->fk_projet;
+ $newinter->fk_project=$object->fk_project;
$newinter->fk_contrat=$object->fk_contrat;
} else {
$newinter->socid=GETPOST("socid");
diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php
index 1a6fa3915ae..f26f44f4837 100644
--- a/htdocs/modulebuilder/template/class/myobject.class.php
+++ b/htdocs/modulebuilder/template/class/myobject.class.php
@@ -97,6 +97,7 @@ class MyObject extends CommonObject
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for amount'),
'qty' =>array('type'=>'real', 'label'=>'Qty', 'enabled'=>1, 'visible'=>1, 'default'=>'0', 'position'=>45, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text for quantity', 'css'=>'maxwidth75imp'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php:1', 'label'=>'ThirdParty', 'visible'=> 1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'help'=>'LinkToThirparty'),
+ 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>52, 'notnull'=>-1, 'index'=>1,),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>3, 'position'=>60),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index e39022814e7..c53fe528849 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -142,6 +142,18 @@ if (empty($reshook))
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.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
+
+ if ($action == 'set_thirdparty' && $permissiontoadd)
+ {
+ $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MYOBJECT_MODIFY');
+ }
+ if ($action == 'classin' && $permissiontoadd)
+ {
+ $object->setProject(GETPOST('projectid', 'int'));
+ }
+
// Actions to send emails
$trigger_name='MYOBJECT_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO';
@@ -310,7 +322,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->mymodule->creer, 'string', '', null, null, '', 1);
// Thirdparty
- $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $soc->getNomUrl(1);
+ $morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
// Project
if (! empty($conf->projet->enabled))
{
@@ -355,6 +367,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Common attributes
//$keyforbreak='fieldkeytoswitchonsecondcolumn';
+ //unset($object->fields['fk_project']); // Hide field already shown in banner
+ //unset($object->fields['fk_soc']); // Hide field already shown in banner
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
// Other attributes. Fields from hook formObjectOptions and Extrafields.
diff --git a/htdocs/mrp/lib/mrp_mo.lib.php b/htdocs/mrp/lib/mrp_mo.lib.php
index 6189761269e..fe29c774f44 100644
--- a/htdocs/mrp/lib/mrp_mo.lib.php
+++ b/htdocs/mrp/lib/mrp_mo.lib.php
@@ -36,11 +36,16 @@ function moPrepareHead($object)
$h = 0;
$head = array();
- $head[$h][0] = dol_buildpath("/mrp/mo_card.php", 1).'?id='.$object->id;
+ $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
+ $head[$h][0] = DOL_URL_ROOT.'/mrp/mo_production.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Production");
+ $head[$h][2] = 'production';
+ $h++;
+
if (isset($object->fields['note_public']) || isset($object->fields['note_private']))
{
$nbNote = 0;
diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php
index b12ee490fe7..5b67482502b 100644
--- a/htdocs/mrp/mo_card.php
+++ b/htdocs/mrp/mo_card.php
@@ -58,6 +58,7 @@ if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
dol_include_once('/mrp/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
@@ -143,6 +144,18 @@ if (empty($reshook))
// Actions when printing a doc from card
include DOL_DOCUMENT_ROOT.'/core/actions_printing.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
+
+ if ($action == 'set_thirdparty' && $permissiontoadd)
+ {
+ $object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'MO_MODIFY');
+ }
+ if ($action == 'classin' && $permissiontoadd)
+ {
+ $object->setProject(GETPOST('projectid', 'int'));
+ }
+
// Actions to send emails
$trigger_name='MO_SENTBYMAIL';
$autocopy='MAIN_MAIL_AUTOCOPY_MO_TO';
@@ -160,7 +173,7 @@ if (empty($reshook))
*/
$form=new Form($db);
-$formfile=new FormFile($db);
+$formproject=new FormProjets($db);
llxHeader('', $langs->trans('Mo'), '');
@@ -248,7 +261,7 @@ if ($action == 'create')
// Part to edit record
if (($id || $ref) && $action == 'edit')
{
- print load_fiche_titre($langs->trans("Mo"), '', 'cubes');
+ print load_fiche_titre($langs->trans("MO"), '', 'cubes');
print '