Skip to content

Commit

Permalink
#2789 [PreventionPlan] add: can now edit project of a PP/FP
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-micka committed Dec 1, 2022
1 parent 095cee3 commit aa00c61
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
26 changes: 21 additions & 5 deletions view/firepermit/firepermit_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
if ( ! $res) die("Include of main fails");

require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/html.formprojet.class.php';

require_once __DIR__ . '/../../class/digiriskdocuments.class.php';
require_once __DIR__ . '/../../class/digiriskelement.class.php';
Expand Down Expand Up @@ -135,6 +136,7 @@
// Action to add record
if ($action == 'add' && $permissiontoadd) {
// Get parameters
$project = GETPOST('fk_project');
$maitre_oeuvre_id = GETPOST('maitre_oeuvre');
$extsociety_id = GETPOST('ext_society');
$extresponsible_id = GETPOST('ext_society_responsible');
Expand All @@ -155,7 +157,7 @@
$object->status = 1;
$object->label = $label;
$object->description = $description;
$object->fk_project = $conf->global->DIGIRISKDOLIBARR_FIREPERMIT_PROJECT;
$object->fk_project = $project;

$date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
$date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
Expand Down Expand Up @@ -242,6 +244,7 @@
// Action to update record
if ($action == 'update' && $permissiontoadd) {
// Get parameters
$project = GETPOST('fk_project');
$maitre_oeuvre_id = GETPOST('maitre_oeuvre');
$extsociety_id = GETPOST('ext_society');
$extresponsible_id = GETPOST('ext_society_responsible');
Expand All @@ -267,6 +270,8 @@
$object->fk_preventionplan = $fk_preventionplan;
$object->fk_user_creat = $user->id ? $user->id : 1;

$object->fk_project = $project;

// Check parameters
if ($maitre_oeuvre_id < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('MaitreOeuvre')), null, 'errors');
Expand Down Expand Up @@ -645,7 +650,8 @@
* View
*/

$form = new Form($db);
$form = new Form($db);
$formproject = new FormProjets($db);

$title = $langs->trans("FirePermit");
$title_create = $langs->trans("NewFirePermit");
Expand Down Expand Up @@ -673,6 +679,11 @@

print '<table class="border centpercent tableforfieldcreate firepermit-table">' . "\n";

//Project -- projet
print '<tr><td class="fieldrequired minwidth400">' . img_picto('', 'project') . ' ' . $langs->trans("Project") . '</td><td>';
print $formproject->select_projects(-1, $conf->global->DIGIRISKDOLIBARR_FIREPERMIT_PROJECT, 'fk_project', 16, 0, 0);
print '</td></tr>';

//Label -- Libellé
print '<tr><td class="minwidth400">' . $langs->trans("Label") . '</td><td>';
print '<input class="flat" type="text" size="36" name="label" id="label" value="' . GETPOST('label') . '">';
Expand Down Expand Up @@ -793,8 +804,13 @@
print $object->ref;
print '</td></tr>';

//Project -- projet
print '<tr><td class="fieldrequired minwidth400">' . img_picto('', 'project') . ' ' . $langs->trans("Project") . '</td><td>';
print $formproject->select_projects(-1, $object->fk_project, 'fk_project', 16, 0, 0);
print '</td></tr>';

//Label -- Libellé
print '<tr><td class="fieldrequired minwidth400">' . $langs->trans("Label") . '</td><td>';
print '<tr><td class="minwidth400">' . $langs->trans("Label") . '</td><td>';
print '<input class="flat" type="text" size="36" name="label" id="label" value="' . $object->label . '">';
print '</td></tr>';

Expand Down Expand Up @@ -884,7 +900,7 @@
print '</td></tr>';

//FK PREVENTION PLAN
print '<tr class="oddeven"><td>' . $langs->trans("PreventionPlanLinked") . '</td><td>';
print '<tr class="fieldrequired"><td>' . $langs->trans("PreventionPlanLinked") . '</td><td>';
print $preventionplan->select_preventionplan_list($object->fk_preventionplan);
print '</td></tr>';

Expand Down Expand Up @@ -966,7 +982,7 @@
$morehtmlref .= $langs->trans('ExtSociety') . ' : ' . $ext_society->getNomUrl(1);
// Project
$project->fetch($object->fk_project);
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank');
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1);
$morehtmlref .= '</div>';

digirisk_banner_tab($object, 'ref', '', 0, 'ref', 'ref', $morehtmlref, '', 0, '', $object->getLibStatut(5));
Expand Down
22 changes: 19 additions & 3 deletions view/preventionplan/preventionplan_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
if ( ! $res) die("Include of main fails");

require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT .'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php';

Expand Down Expand Up @@ -138,6 +139,7 @@
// Action to add record
if ($action == 'add' && $permissiontoadd) {
// Get parameters
$project = GETPOST('fk_project');
$maitre_oeuvre_id = GETPOST('maitre_oeuvre');
$extsociety_id = GETPOST('ext_society');
$extresponsible_id = GETPOST('ext_society_responsible');
Expand All @@ -157,7 +159,7 @@
$object->tms = $now;
$object->import_key = "";
$object->label = $label;
$object->fk_project = $conf->global->DIGIRISKDOLIBARR_PREVENTIONPLAN_PROJECT;
$object->fk_project = $project;

$date_start = dol_mktime(GETPOST('dateohour', 'int'), GETPOST('dateomin', 'int'), 0, GETPOST('dateomonth', 'int'), GETPOST('dateoday', 'int'), GETPOST('dateoyear', 'int'));
$date_end = dol_mktime(GETPOST('dateehour', 'int'), GETPOST('dateemin', 'int'), 0, GETPOST('dateemonth', 'int'), GETPOST('dateeday', 'int'), GETPOST('dateeyear', 'int'));
Expand Down Expand Up @@ -248,6 +250,7 @@
// Action to update record
if ($action == 'update' && $permissiontoadd) {
// Get parameters
$project = GETPOST('fk_project');
$maitre_oeuvre_id = GETPOST('maitre_oeuvre');
$extsociety_id = GETPOST('ext_society');
$extresponsible_id = GETPOST('ext_society_responsible');
Expand Down Expand Up @@ -280,6 +283,8 @@

$object->fk_user_creat = $user->id ? $user->id : 1;

$object->fk_project = $project;

// Check parameters
if ($maitre_oeuvre_id < 0) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('MaitreOeuvre')), null, 'errors');
Expand Down Expand Up @@ -653,7 +658,8 @@
* View
*/

$form = new Form($db);
$form = new Form($db);
$formproject = new FormProjets($db);

$title = $langs->trans("PreventionPlan");
$title_create = $langs->trans("NewPreventionPlan");
Expand Down Expand Up @@ -681,6 +687,11 @@

print '<table class="border centpercent tableforfieldcreate preventionplan-table">';

//Project -- projet
print '<tr><td class="fieldrequired minwidth400">' . img_picto('', 'project') . ' ' . $langs->trans("Project") . '</td><td>';
print $formproject->select_projects(-1, $conf->global->DIGIRISKDOLIBARR_PREVENTIONPLAN_PROJECT, 'fk_project', 16, 0, 0);
print '</td></tr>';

//Label -- Libellé
print '<tr><td class="minwidth400">' . $langs->trans("Label") . '</td><td>';
print '<input class="flat" type="text" size="36" name="label" id="label" value="' . GETPOST('label') . '">';
Expand Down Expand Up @@ -816,6 +827,11 @@
print $object->ref;
print '</td></tr>';

//Project -- projet
print '<tr><td class="fieldrequired minwidth400">' . img_picto('', 'project') . ' ' . $langs->trans("Project") . '</td><td>';
print $formproject->select_projects(-1, $object->fk_project, 'fk_project', 16, 0, 0);
print '</td></tr>';

//Label -- Libellé
print '<tr><td class="minwidth400">' . $langs->trans("Label") . '</td><td>';
print '<input class="flat" type="text" size="36" name="label" id="label" value="' . $object->label . '">';
Expand Down Expand Up @@ -1006,7 +1022,7 @@
$morehtmlref .= $langs->trans('ExtSociety') . ' : ' . $ext_society->getNomUrl(1);
// Project
$project->fetch($object->fk_project);
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank');
$morehtmlref .= '<br>' . $langs->trans('Project') . ' : ' . getNomUrlProject($project, 1, 'blank', 1);
$morehtmlref .= '</div>';

//$morehtmlleft = '<div class="floatleft inline-block valignmiddle divphotoref">'.digirisk_show_photos('digiriskdolibarr', $conf->digiriskdolibarr->multidir_output[$entity].'/'.$object->element_type, 'small', 5, 0, 0, 0, $width,0, 0, 0, 0, $object->element_type, $object).'</div>';
Expand Down

0 comments on commit aa00c61

Please sign in to comment.