Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
}

if ($action == 'set_satisfaction_survey') {
$satisfactionSurveys = ['billing', 'trainee', 'sessiontrainer', 'opco'];
$satisfactionSurveys = ['billing', 'customer', 'trainee', 'sessiontrainer'];
foreach ($satisfactionSurveys as $satisfactionSurvey) {
$satisfactionSurveyID = GETPOST($satisfactionSurvey . '_satisfaction_survey_model');
$confName = 'DOLIMEET_' . dol_strtoupper($satisfactionSurvey) . '_SATISFACTION_SURVEY_SHEET';
Expand Down Expand Up @@ -307,7 +307,7 @@
print '<td>' . $langs->trans('Value') . '</td>';
print '</tr>';

$satisfactionSurveys = ['billing', 'trainee', 'sessiontrainer', 'opco'];
$satisfactionSurveys = ['billing', 'customer', 'trainee', 'sessiontrainer'];
foreach ($satisfactionSurveys as $satisfactionSurvey) {
print '<tr class="oddeven"><td>';
print $langs->trans(ucfirst($satisfactionSurvey) . 'SatisfactionSurvey');
Expand Down
39 changes: 32 additions & 7 deletions class/actions_dolimeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function addHtmlHeader(array $parameters): int
*/
public function formObjectOptions(array $parameters, $object, $action): int
{
global $extrafields, $langs;
global $conf, $extrafields, $form, $langs;

if (preg_match('/projectcard|propalcard|contractcard|productcard/', $parameters['context'])) {
$pictoPath = dol_buildpath('/dolimeet/img/dolimeet_color.png', 1);
Expand All @@ -159,13 +159,18 @@ public function formObjectOptions(array $parameters, $object, $action): int
$extrafields->attributes['product']['label']['syllabus'] = $picto . $langs->transnoentities($extrafields->attributes['product']['label']['syllabus']);

// Initialize the param attribute for trainingsession_service
if (isset($extrafields->attributes['propal']['param']['trainingsession_service']) || isset($extrafields->attributes['projet']['param']['trainingsession_service'])) {
$filter = 'product as p:label:rowid::fk_product_type = 1 AND entity = $ENTITY$';
$filter .= ' AND rowid IN (SELECT cp.fk_product FROM ' . MAIN_DB_PREFIX . 'categorie_product cp LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie c ON cp.fk_categorie = c.rowid WHERE cp.fk_categorie = ' . getDolGlobalInt('DOLIMEET_FORMATION_MAIN_CATEGORY') . ')';
$filter .= ' AND EXISTS (SELECT 1 FROM ' . MAIN_DB_PREFIX . 'dolimeet_session ds WHERE ds.fk_element = p.rowid AND ds.model = 1 AND ds.element_type = "service" AND ds.date_start IS NOT NULL AND ds.date_end IS NOT NULL AND ds.fk_project = ' . getDolGlobalInt('DOLIMEET_TRAININGSESSION_TEMPLATES_PROJECT') . ' GROUP BY ds.fk_element HAVING SUM(ds.duration) = p.duration * 3600)';

$filter = '';
if (DOL_VERSION >= '20.0.0') { // @TODO Bon courage a celui qui devra maintenir ce code
if (isset($extrafields->attributes['propal']['param']['trainingsession_service']) || isset($extrafields->attributes['projet']['param']['trainingsession_service'])) {
$filter = 'product as p:label:rowid::(fk_product_type:=:1 AND entity:=:$ENTITY$)';
$filter .= ' AND (rowid:IN:SELECT cp.fk_product FROM ' . MAIN_DB_PREFIX . 'categorie_product cp LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie c ON cp.fk_categorie = c.rowid WHERE cp.fk_categorie = ' . getDolGlobalInt('DOLIMEET_FORMATION_MAIN_CATEGORY') . ')';
$filter .= ' AND (rowid:IN:SELECT ds.fk_element FROM ' . MAIN_DB_PREFIX . 'dolimeet_session ds WHERE ds.fk_element = p.rowid AND ds.model = 1 AND ds.date_start IS NOT NULL AND ds.date_end IS NOT NULL AND ds.fk_project = ' . getDolGlobalInt('DOLIMEET_TRAININGSESSION_TEMPLATES_PROJECT') . ')';
}
$extrafields->attributes['projet']['param']['trainingsession_service'] = ['options' => [$filter => '']];
$extrafields->attributes['propal']['param']['trainingsession_service'] = ['options' => [$filter => '']];
} else {
$extrafields->attributes['projet']['param']['trainingsession_service'] = ['options' => ['' => NULL]];
$extrafields->attributes['propal']['param']['trainingsession_service'] = ['options' => ['' => NULL]];
}
}

Expand Down Expand Up @@ -224,6 +229,26 @@ public function formObjectOptions(array $parameters, $object, $action): int
$out .= '<li class="notice-opportunity-status">' . $langs->transnoentities('OpportunityStatus') . '</li>';
$out .= '</ul></div></div></div>';

// $out2 = '<tr class="field_options_trainingsession_service project_extras_trainingsession_service trextrafields_collapse" data-element="extrafield" data-targetelement="project" data-targetid="">';
// $out2 .= '<td class="titlefieldmax45 wordbreak">';
// $out2 .= $form->textwithpicto($langs->transnoentities($extrafields->attributes['projet']['label']['trainingsession_service']), $langs->transnoentities($extrafields->attributes['projet']['help']['trainingsession_service']));
// $out2 .= '</td><td class="valuefieldcreate project_extras_trainingsession_service">';
//
// $filter = [
// 'customsql' => 'fk_product_type = 1 AND entity = ' . $conf->entity .
// ' AND rowid IN (SELECT cp.fk_product FROM ' . MAIN_DB_PREFIX . 'categorie_product cp LEFT JOIN ' . MAIN_DB_PREFIX . 'categorie c ON cp.fk_categorie = c.rowid WHERE cp.fk_categorie = ' . getDolGlobalInt('DOLIMEET_FORMATION_MAIN_CATEGORY') . ')' .
// ' AND rowid IN (SELECT ds.fk_element FROM ' . MAIN_DB_PREFIX . 'dolimeet_session ds WHERE ds.fk_element = t.rowid AND ds.model = 1 AND ds.element_type = "service" AND ds.date_start IS NOT NULL AND ds.date_end IS NOT NULL AND ds.fk_project = ' . getDolGlobalInt('DOLIMEET_TRAININGSESSION_TEMPLATES_PROJECT') . ' GROUP BY ds.fk_element HAVING SUM(ds.duration) = t.duration * 3600)'
// ];
// $a = saturne_fetch_all_object_type('Product', 'ASC', 'label', 0, 0, $filter);
// if (!empty($a) && is_array($a)) {
// foreach ($a as $product) {
// $b[$product->id] = $product->label;
// }
// }
// $out2 .= Form::multiselectarray('options_trainingsession_service', $b, $object->array_options['options_trainingsession_service']);
// $out2 .= '</td></tr>';
// print $out2

?>
<script>
$(document).on('change', '#socid', function() {
Expand Down Expand Up @@ -489,7 +514,7 @@ public function printCommonFooter(array $parameters): int
$signatory = new SaturneSignature($db, 'digiquali', $survey->element);

$contacts = array_merge($object->liste_contact(-1, 'internal'), $object->liste_contact(-1));
$contactsCodeWanted = ['BILLING', 'TRAINEE', 'SESSIONTRAINER', 'OPCO'];
$contactsCodeWanted = ['BILLING', 'CUSTOMER', 'TRAINEE', 'SESSIONTRAINER'];

$object->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);

Expand Down
21 changes: 8 additions & 13 deletions core/modules/modDoliMeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public function init($options = ''): int

if (getDolGlobalInt('DOLIMEET_EMAIL_TEMPLATE_SET') == 0 && isModEnabled('digiquali') && version_compare(getDolGlobalString('DIGIQUALI_VERSION'), '1.11.0', '>=')) {
$position = 100;
$satisfactionSurveys = ['billing', 'trainee', 'sessiontrainer', 'opco'];
$satisfactionSurveys = ['billing', 'customer', 'trainee', 'sessiontrainer'];
foreach ($satisfactionSurveys as $satisfactionSurvey) {
$saturneMail->entity = 0;
$saturneMail->type_template = 'contract';
Expand Down Expand Up @@ -674,20 +674,15 @@ public function init($options = ''): int
$extraFields = new ExtraFields($this->db);

$extraFieldsArrays = [
'label' => ['Label' => 'Label', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['contrat'], 'position' => 1, 'params' => '', 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_type' => ['Label' => 'TrainingSessionType', 'type' => 'sellist', 'length' => '', 'elementtype' => ['contrat', 'propal', 'projet'], 'position' => 10, 'params' => 'a:1:{s:7:"options";a:1:{s:34:"c_trainingsession_type:label:rowid";N;}}', 'list' => 1, 'help' => ['contrat' => '', 'propal' => '', 'projet' => 'TrainingSessionTypeHelp'], 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_service' => ['Label' => 'TrainingSessionService', 'type' => 'chkbxlst', 'length' => '', 'elementtype' => ['propal', 'projet'], 'position' => 10, 'params' => '', 'list' => 1, 'help' => 'TrainingSessionServiceHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_location' => ['Label' => 'TrainingSessionLocation', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['contrat', 'propal', 'projet'], 'position' => 20, 'params' => '', 'list' => 1, 'help' => 'TrainingSessionLocationHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_opco_financing' => ['Label' => 'TrainingSessionOpcoFinancing', 'type' => 'boolean', 'length' => '', 'elementtype' => ['contrat'], 'position' => 60, 'params' => '', 'alwayseditable' => 1, 'list' => 5, 'help' => 'TrainingSessionOpcoFinancingHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')"],
'syllabus' => ['Label' => 'Syllabus', 'type' => 'html', 'length' => '', 'elementtype' => ['product'], 'position' => 100, 'params' => '', 'alwayseditable' => 1, 'list' => 4, 'help' => 'SyllabusHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')"]
'label' => ['Label' => 'Label', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['contrat'], 'position' => 1, 'params' => '', 'list' => 1, 'help' => '', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_type' => ['Label' => 'TrainingSessionType', 'type' => 'sellist', 'length' => '', 'elementtype' => ['contrat', 'propal', 'projet'], 'position' => 10, 'params' => ['c_trainingsession_type:label:rowid' => NULL], 'list' => 1, 'help' => ['contrat' => '', 'propal' => '', 'projet' => 'TrainingSessionTypeHelp'], 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_service' => ['Label' => 'TrainingSessionService', 'type' => 'chkbxlst', 'length' => '', 'elementtype' => ['propal', 'projet'], 'position' => 10, 'params' => '', 'list' => 1, 'help' => 'TrainingSessionServiceHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_location' => ['Label' => 'TrainingSessionLocation', 'type' => 'varchar', 'length' => 255, 'elementtype' => ['contrat', 'propal', 'projet'], 'position' => 20, 'params' => '', 'list' => 1, 'help' => 'TrainingSessionLocationHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')", ['css' => 'minwidth100 maxwidth300 widthcentpercentminusxx']],
'trainingsession_opco_financing' => ['Label' => 'TrainingSessionOpcoFinancing', 'type' => 'boolean', 'length' => '', 'elementtype' => ['contrat'], 'position' => 60, 'params' => '', 'alwayseditable' => 1, 'list' => 5, 'help' => 'TrainingSessionOpcoFinancingHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')"],
'syllabus' => ['Label' => 'Syllabus', 'type' => 'html', 'length' => '', 'elementtype' => ['product'], 'position' => 100, 'params' => '', 'alwayseditable' => 1, 'list' => 4, 'help' => 'SyllabusHelp', 'entity' => 0, 'langfile' => 'dolimeet@dolimeet', 'enabled' => "isModEnabled('dolimeet')"]
];

foreach ($extraFieldsArrays as $key => $extraField) {
foreach ($extraField['elementtype'] as $extraFieldElementType) {
$extraFields->update($key, $extraField['Label'], $extraField['type'], $extraField['length'], $extraFieldElementType, 0, 0, $this->numero . $extraField['position'], $extraField['params'], '', '', $extraField['list'], ($extraField['help'][$extraFieldElementType] ?? $extraField['help']), '', '', $extraField['entity'], $extraField['langfile'], $extraField['enabled'] . ' && isModEnabled("' . $extraFieldElementType . '")', 0, 0, $extraField['css']);
$extraFields->addExtraField($key, $extraField['Label'], $extraField['type'], $this->numero . $extraField['position'], $extraField['length'], $extraFieldElementType, 0, 0, '', $extraField['params'], $extraField['alwayseditable'], '', $extraField['list'], $extraField['help'], '', $extraField['entity'], $extraField['langfile'], $extraField['enabled'] . ' && isModEnabled("' . $extraFieldElementType . '")', 0, 0, $extraField['css']);
}
}
saturne_manage_extrafields($extraFieldsArrays);

if (getDolGlobalInt('DOLIMEET_EXTRAFIELDS_BACKWARD_COMPATIBILITY') == 0) {
$extraFieldsArrays = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$contactCode = dol_getIdFromCode($this->db, $contactTypeID, 'c_type_contact', 'rowid', 'code');

if (isModEnabled('digiquali') && version_compare(getDolGlobalString('DIGIQUALI_VERSION'), '1.11.0', '>=')) {
$contactsCodeWanted = ['BILLING', 'TRAINEE', 'SESSIONTRAINER', 'OPCO'];
$contactsCodeWanted = ['BILLING', 'CUSTOMER', 'TRAINEE', 'SESSIONTRAINER'];
if (in_array($contactCode, $contactsCodeWanted) && !empty($contactID)) {
set_satisfaction_survey($object, $contactCode, $contactID, $contactSource);
}
Expand Down Expand Up @@ -381,8 +381,6 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
// Load DoliMeet libraries
require_once __DIR__ . '/../../lib/dolimeet_function.lib.php';

$this->db->begin();

$propal = new Propal($this->db);
$product = new Product($this->db);
$contratLigne = new ContratLigne($this->db);
Expand Down Expand Up @@ -415,6 +413,9 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$contratLigne->price_ht = 0;
$contratLigne->remise = 0;

// Todo changer par addline
$this->db->begin();

$contratLigne->insert($user);
}
}
Expand All @@ -428,7 +429,7 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$trainingSession = new Trainingsession($this->db);

$propal->fetch($object->linked_objects['propal']);
if (strpos($propal->array_options['options_trainingsession_service'], ',') === false) {
if (strpos($propal->array_options['options_trainingsession_service'], ',') !== false) {
$propal->array_options['options_trainingsession_service'] = explode(',', $propal->array_options['options_trainingsession_service']);
}
foreach ($propal->array_options['options_trainingsession_service'] as $trainingSessionServiceId) {
Expand Down
4 changes: 2 additions & 2 deletions langs/en_US/dolimeet.lang
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ DoliMeetDescriptionLong = Follow-up of meetings, training sessions, audits
SatisfactionSurvey = Satisfaction survey
BillingSatisfactionSurvey = Billing satisfaction survey
BillingSatisfactionSurveyDescription = Defines the model used by default for billing satisfaction surveys
CustomerSatisfactionSurvey = Customer satisfaction survey
CustomerSatisfactionSurveyDescription = Defines the model used by default for customer satisfaction surveys
TraineeSatisfactionSurvey = Trainee satisfaction survey
TraineeSatisfactionSurveyDescription = Defines the model used by default for trainee satisfaction surveys
SessiontrainerSatisfactionSurvey = Session trainer satisfaction survey
SessiontrainerSatisfactionSurveyDescription = Defines the model used by default for session trainer satisfaction surveys
OpcoSatisfactionSurvey = OPCO satisfaction survey
OpcoSatisfactionSurveyDescription = Defines the model used by default for OPCO satisfaction surveys



Expand Down
Loading