From 17592798faba2f5de754e58f92123b421243c7f6 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 23 Aug 2023 10:39:28 +0200 Subject: [PATCH 01/20] #1482 [Cron] add: cron tab sendEmailsReminder --- core/modules/modDigiQuali.class.php | 8 +++++++- ...e_99_modDigiQuali_DigiQualiTriggers.class.php | 16 +++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/core/modules/modDigiQuali.class.php b/core/modules/modDigiQuali.class.php index e30a68e4..50296d91 100644 --- a/core/modules/modDigiQuali.class.php +++ b/core/modules/modDigiQuali.class.php @@ -148,7 +148,7 @@ public function __construct($db) // A condition to hide module $this->hidden = false; // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->depends = ['modFckeditor', 'modProduct', 'modProductBatch', 'modAgenda', 'modECM', 'modProjet', 'modCategorie', 'modSaturne', 'modTicket']; + $this->depends = ['modFckeditor', 'modProduct', 'modProductBatch', 'modAgenda', 'modECM', 'modProjet', 'modCategorie', 'modSaturne', 'modTicket', 'modCron']; $this->requiredby = []; // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) $this->conflictwith = []; // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) @@ -721,6 +721,12 @@ public function init($options = ''): int dolibarr_set_const($this->db, 'DIGIQUALI_QUESTION_BACKWARD_COMPATIBILITY', 1, 'integer', 0, '', $conf->entity); } + require_once DOL_DOCUMENT_ROOT . '/cron/class/cronjob.class.php'; + + $cronJob = new Cronjob($this->db); + $cronJob->fetch(0, 'ActionComm', 'sendEmailsReminder'); + $cronJob->reprogram_jobs($user->login, dol_now()); + return $result; } diff --git a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php index 122ab7c7..60b06aeb 100644 --- a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php +++ b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php @@ -264,13 +264,15 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $reminderArray = explode(',' , getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_FREQUENCY')); foreach ($reminderArray as $reminder) { - $dateReminder = dol_time_plus_duree($object->next_control_date, -$reminder, 'd'); - - $actionCommReminder->dateremind = $dateReminder; - $actionCommReminder->offsetvalue = $reminder; - $actionCommReminder->offsetunit = 'd'; - $actionCommReminder->typeremind = getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_TYPE'); - $actionCommReminder->create($user); + if ($qcFrequency <= $reminder) { + $dateReminder = dol_time_plus_duree(dol_stringtotime($object->next_control_date), -$reminder, 'd'); + + $actionCommReminder->dateremind = $dateReminder; + $actionCommReminder->offsetvalue = $reminder; + $actionCommReminder->offsetunit = 'd'; + $actionCommReminder->typeremind = getDolGlobalString('DIGIQUALI_CONTROL_REMINDER_TYPE'); + $actionCommReminder->create($user); + } } } break; From ad6cc47e6d4dc54d4253a16590d4b30c8e007715 Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Wed, 23 Aug 2023 16:12:44 +0200 Subject: [PATCH 02/20] #1499 [Hook] add: Picto for extrafields --- class/actions_digiquali.class.php | 37 ++- core/modules/modDigiQuali.class.php | 5 +- lib/digiquali_sheet.lib.php | 348 +++++++++++++++------------- 3 files changed, 229 insertions(+), 161 deletions(-) diff --git a/class/actions_digiquali.class.php b/class/actions_digiquali.class.php index b9778f97..a690cf25 100644 --- a/class/actions_digiquali.class.php +++ b/class/actions_digiquali.class.php @@ -170,7 +170,7 @@ public function doActions(array $parameters, $object, string $action): int */ public function printCommonFooter($parameters) { - global $conf, $form, $langs, $user; + global $conf, $form, $langs, $object, $user; $error = 0; // Error counter @@ -284,6 +284,41 @@ public function printCommonFooter($parameters) element) { + if ($parameters['currentcontext'] == $linkableElement['hook_name_card']) { + $picto = img_picto('', 'fontawesome_fa-clipboard-check_fas_#d35968', 'class="pictofixedwidth"'); + $extrafieldsNames = ['qc_frequency', 'control_history_link']; + foreach ($extrafieldsNames as $extrafieldsName) { + $jQueryElement = 'td.' . $object->element . '_extras_' . $extrafieldsName; ?> + + + + results = array('myreturn' => 999); return 0; // or return 1 to replace standard code diff --git a/core/modules/modDigiQuali.class.php b/core/modules/modDigiQuali.class.php index e30a68e4..f5d67c88 100644 --- a/core/modules/modDigiQuali.class.php +++ b/core/modules/modDigiQuali.class.php @@ -125,7 +125,7 @@ public function __construct($db) 'publiccontrol', 'publicsurvey', 'digiqualiadmindocuments', - 'productlotcard' + 'projecttaskscard' ], // Set this to 1 if features of module are opened to external users 'moduleforexternal' => 0, @@ -287,6 +287,9 @@ public function __construct($db) $objectType = $linkableElement['tab_type']; } $this->tabs[] = ['data' => $objectType . ':+control:' . $pictoDigiQuali . $langs->trans('Controls') . ':digiquali@digiquali:$user->rights->digiquali->control->read:/custom/digiquali/view/control/control_list.php?fromid=__ID__&fromtype=' . $linkableElement['link_name']]; + + $this->module_parts['hooks'][] = $linkableElement['hook_name_list']; + $this->module_parts['hooks'][] = $linkableElement['hook_name_card']; } } diff --git a/lib/digiquali_sheet.lib.php b/lib/digiquali_sheet.lib.php index 245de7fd..6ea5bbf5 100644 --- a/lib/digiquali_sheet.lib.php +++ b/lib/digiquali_sheet.lib.php @@ -71,208 +71,236 @@ function get_sheet_linkable_objects(): array if (isModEnabled('product')) { $linkableObjectTypes['product'] = [ - 'langs' => 'ProductOrService', - 'langfile' => 'products', - 'picto' => 'product', - 'className' => 'Product', - 'post_name' => 'fk_product', - 'link_name' => 'product', - 'tab_type' => 'product', - 'name_field' => 'ref', - 'create_url' => 'product/card.php', - 'class_path' => 'product/class/product.class.php', + 'langs' => 'ProductOrService', + 'langfile' => 'products', + 'picto' => 'product', + 'className' => 'Product', + 'post_name' => 'fk_product', + 'link_name' => 'product', + 'tab_type' => 'product', + 'hook_name_list' => 'productservicelist', + 'hook_name_card' => 'productcard', + 'name_field' => 'ref', + 'create_url' => 'product/card.php', + 'class_path' => 'product/class/product.class.php', ]; } if (isModEnabled('productbatch')) { $linkableObjectTypes['productlot'] = [ - 'langs' => 'Batch', - 'langfile' => 'products', - 'picto' => 'lot', - 'className' => 'ProductLot', - 'post_name' => 'fk_productlot', - 'link_name' => 'productbatch', - 'tab_type' => 'productlot', - 'name_field' => 'batch', - 'fk_parent' => 'fk_product', - 'parent_post' => 'fk_product', - 'create_url' => 'product/stock/productlot_card.php', - 'class_path' => 'product/stock/class/productlot.class.php', + 'langs' => 'Batch', + 'langfile' => 'products', + 'picto' => 'lot', + 'className' => 'ProductLot', + 'post_name' => 'fk_productlot', + 'link_name' => 'productbatch', + 'tab_type' => 'productlot', + 'hook_name_list' => 'product_lotlist', + 'hook_name_card' => 'productlotcard', + 'name_field' => 'batch', + 'fk_parent' => 'fk_product', + 'parent_post' => 'fk_product', + 'create_url' => 'product/stock/productlot_card.php', + 'class_path' => 'product/stock/class/productlot.class.php', ]; } if (isModEnabled('user')) { $linkableObjectTypes['user'] = [ - 'langs' => 'User', - 'picto' => 'user', - 'className' => 'User', - 'post_name' => 'fk_user', - 'link_name' => 'user', - 'tab_type' => 'user', - 'name_field' => 'lastname, firstname', - 'create_url' => 'user/card.php', - 'class_path' => 'user/class/user.class.php', + 'langs' => 'User', + 'picto' => 'user', + 'className' => 'User', + 'post_name' => 'fk_user', + 'link_name' => 'user', + 'tab_type' => 'user', + 'hook_name_list' => 'userlist', + 'hook_name_card' => 'usercard', + 'name_field' => 'lastname, firstname', + 'create_url' => 'user/card.php', + 'class_path' => 'user/class/user.class.php', ]; } if (isModEnabled('societe')) { $linkableObjectTypes['thirdparty'] = [ - 'langs' => 'ThirdParty', - 'langfile' => 'companies', - 'picto' => 'building', - 'className' => 'Societe', - 'post_name' => 'fk_soc', - 'link_name' => 'societe', - 'tab_type' => 'thirdparty', - 'name_field' => 'nom', - 'create_url' => 'societe/card.php', - 'class_path' => 'societe/class/societe.class.php', + 'langs' => 'ThirdParty', + 'langfile' => 'companies', + 'picto' => 'building', + 'className' => 'Societe', + 'post_name' => 'fk_soc', + 'link_name' => 'societe', + 'tab_type' => 'thirdparty', + 'hook_name_list' => 'thirdpartylist', + 'hook_name_card' => 'thirdpartycard', + 'name_field' => 'nom', + 'create_url' => 'societe/card.php', + 'class_path' => 'societe/class/societe.class.php', ]; $linkableObjectTypes['contact'] = [ - 'langs' => 'Contact', - 'langfile' => 'companies', - 'picto' => 'address', - 'className' => 'Contact', - 'post_name' => 'fk_contact', - 'link_name' => 'contact', - 'tab_type' => 'contact', - 'name_field' => 'lastname, firstname', - 'fk_parent' => 'fk_soc', - 'parent_post' => 'fk_soc', - 'create_url' => 'contact/card.php', - 'class_path' => 'contact/class/contact.class.php', + 'langs' => 'Contact', + 'langfile' => 'companies', + 'picto' => 'address', + 'className' => 'Contact', + 'post_name' => 'fk_contact', + 'link_name' => 'contact', + 'tab_type' => 'contact', + 'hook_name_list' => 'contactlist', + 'hook_name_card' => 'contactcard', + 'name_field' => 'lastname, firstname', + 'fk_parent' => 'fk_soc', + 'parent_post' => 'fk_soc', + 'create_url' => 'contact/card.php', + 'class_path' => 'contact/class/contact.class.php', ]; } if (isModEnabled('project')) { $linkableObjectTypes['project'] = [ - 'langs' => 'Project', - 'langfile' => 'projects', - 'picto' => 'project', - 'className' => 'Project', - 'post_name' => 'fk_project', - 'link_name' => 'project', - 'tab_type' => 'project', - 'name_field' => 'ref, title', - 'create_url' => 'projet/card.php', - 'class_path' => 'projet/class/project.class.php', + 'langs' => 'Project', + 'langfile' => 'projects', + 'picto' => 'project', + 'className' => 'Project', + 'post_name' => 'fk_project', + 'link_name' => 'project', + 'tab_type' => 'project', + 'hook_name_list' => 'projectlist', + 'hook_name_card' => 'projectcard', + 'name_field' => 'ref, title', + 'create_url' => 'projet/card.php', + 'class_path' => 'projet/class/project.class.php', ]; $linkableObjectTypes['task'] = [ - 'langs' => 'Task', - 'langfile' => 'projects', - 'picto' => 'projecttask', - 'className' => 'SaturneTask', - 'post_name' => 'fk_task', - 'link_name' => 'project_task', - 'tab_type' => 'task', - 'name_field' => 'label', - 'fk_parent' => 'fk_projet', - 'parent_post' => 'fk_project', - 'create_url' => 'projet/tasks.php', - 'class_path' => 'custom/saturne/class/task/saturnetask.class.php', + 'langs' => 'Task', + 'langfile' => 'projects', + 'picto' => 'projecttask', + 'className' => 'SaturneTask', + 'post_name' => 'fk_task', + 'link_name' => 'project_task', + 'tab_type' => 'task', + 'hook_name_list' => 'tasklist', + 'hook_name_card' => 'projecttaskcard', + 'name_field' => 'label', + 'fk_parent' => 'fk_projet', + 'parent_post' => 'fk_project', + 'create_url' => 'projet/tasks.php', + 'class_path' => 'custom/saturne/class/task/saturnetask.class.php', ]; } if (isModEnabled('facture')) { $linkableObjectTypes['invoice'] = [ - 'langs' => 'Invoice', - 'langfile' => 'bills', - 'picto' => 'bill', - 'className' => 'Facture', - 'post_name' => 'fk_invoice', - 'link_name' => 'facture', - 'tab_type' => 'invoice', - 'name_field' => 'ref', - 'create_url' => 'compta/facture/card.php', - 'class_path' => 'compta/facture/class/facture.class.php', + 'langs' => 'Invoice', + 'langfile' => 'bills', + 'picto' => 'bill', + 'className' => 'Facture', + 'post_name' => 'fk_invoice', + 'link_name' => 'facture', + 'tab_type' => 'invoice', + 'hook_name_list' => 'invoicelist', + 'hook_name_card' => 'invoicecard', + 'name_field' => 'ref', + 'create_url' => 'compta/facture/card.php', + 'class_path' => 'compta/facture/class/facture.class.php', ]; } if (isModEnabled('order')) { $linkableObjectTypes['order'] = [ - 'langs' => 'Order', - 'langfile' => 'orders', - 'picto' => 'order', - 'className' => 'Commande', - 'post_name' => 'fk_order', - 'link_name' => 'commande', - 'tab_type' => 'order', - 'name_field' => 'ref', - 'create_url' => 'commande/card.php', - 'class_path' => 'commande/class/commande.class.php', + 'langs' => 'Order', + 'langfile' => 'orders', + 'picto' => 'order', + 'className' => 'Commande', + 'post_name' => 'fk_order', + 'link_name' => 'commande', + 'tab_type' => 'order', + 'hook_name_list' => 'orderlist', + 'hook_name_card' => 'ordercard', + 'name_field' => 'ref', + 'create_url' => 'commande/card.php', + 'class_path' => 'commande/class/commande.class.php', ]; } if (isModEnabled('contract')) { $linkableObjectTypes['contract'] = [ - 'langs' => 'Contract', - 'langfile' => 'contracts', - 'picto' => 'contract', - 'className' => 'Contrat', - 'post_name' => 'fk_contract', - 'link_name' => 'contrat', - 'tab_type' => 'contract', - 'name_field' => 'ref', - 'create_url' => 'contrat/card.php', - 'class_path' => 'contrat/class/contrat.class.php', + 'langs' => 'Contract', + 'langfile' => 'contracts', + 'picto' => 'contract', + 'className' => 'Contrat', + 'post_name' => 'fk_contract', + 'link_name' => 'contrat', + 'tab_type' => 'contract', + 'hook_name_list' => 'contractlist', + 'hook_name_card' => 'contractcard', + 'name_field' => 'ref', + 'create_url' => 'contrat/card.php', + 'class_path' => 'contrat/class/contrat.class.php', ]; } if (isModEnabled('ticket')) { $linkableObjectTypes['ticket'] = [ - 'langs' => 'Ticket', - 'picto' => 'ticket', - 'className' => 'Ticket', - 'post_name' => 'fk_ticket', - 'link_name' => 'ticket', - 'tab_type' => 'ticket', - 'name_field' => 'ref, subject', - 'create_url' => 'ticket/card.php', - 'class_path' => 'ticket/class/ticket.class.php', + 'langs' => 'Ticket', + 'picto' => 'ticket', + 'className' => 'Ticket', + 'post_name' => 'fk_ticket', + 'link_name' => 'ticket', + 'tab_type' => 'ticket', + 'hook_name_list' => 'ticketlist', + 'hook_name_card' => 'ticketcard', + 'name_field' => 'ref, subject', + 'create_url' => 'ticket/card.php', + 'class_path' => 'ticket/class/ticket.class.php', ]; } if (isModEnabled('stock')) { $linkableObjectTypes['entrepot'] = [ - 'langs' => 'Warehouse', - 'langfile' => 'stocks', - 'picto' => 'stock', - 'className' => 'Entrepot', - 'post_name' => 'fk_entrepot', - 'link_name' => 'stock', - 'tab_type' => 'stock', - 'name_field' => 'ref', - 'create_url' => 'product/stock/entrepot/card.php', - 'class_path' => 'product/stock/class/entrepot.class.php', + 'langs' => 'Warehouse', + 'langfile' => 'stocks', + 'picto' => 'stock', + 'className' => 'Entrepot', + 'post_name' => 'fk_entrepot', + 'link_name' => 'stock', + 'tab_type' => 'stock', + 'hook_name_list' => 'stocklist', + 'hook_name_card' => 'warehousecard', + 'name_field' => 'ref', + 'create_url' => 'product/stock/entrepot/card.php', + 'class_path' => 'product/stock/class/entrepot.class.php', ]; } if (isModEnabled('expedition')) { $linkableObjectTypes['expedition'] = [ - 'langs' => 'Shipment', - 'langfile' => 'sendings', - 'picto' => 'dolly', - 'className' => 'DigiQualiExpedition', - 'post_name' => 'fk_expedition', - 'link_name' => 'expedition', - 'tab_type' => 'delivery', - 'name_field' => 'ref', - 'class_path' => 'custom/digiquali/class/dolibarrobjects/digiqualiexpedition.class.php', + 'langs' => 'Shipment', + 'langfile' => 'sendings', + 'picto' => 'dolly', + 'className' => 'DigiQualiExpedition', + 'post_name' => 'fk_expedition', + 'link_name' => 'expedition', + 'tab_type' => 'delivery', + 'hook_name_list' => 'shipmentlist', + 'hook_name_card' => 'ordershipmentcard', + 'name_field' => 'ref', + 'class_path' => 'custom/digiquali/class/dolibarrobjects/digiqualiexpedition.class.php', ]; } if (isModEnabled('propal')) { $linkableObjectTypes['propal'] = [ - 'langs' => 'Proposal', - 'langfile' => 'propal', - 'picto' => 'propal', - 'className' => 'Propal', - 'post_name' => 'fk_propal', - 'link_name' => 'propal', - 'tab_type' => 'propal', - 'name_field' => 'ref', - 'create_url' => 'comm/propal/card.php', - 'class_path' => 'comm/propal/class/propal.class.php', + 'langs' => 'Proposal', + 'langfile' => 'propal', + 'picto' => 'propal', + 'className' => 'Propal', + 'post_name' => 'fk_propal', + 'link_name' => 'propal', + 'tab_type' => 'propal', + 'hook_name_list' => 'propallist', + 'hook_name_card' => 'propalcard', + 'name_field' => 'ref', + 'create_url' => 'comm/propal/card.php', + 'class_path' => 'comm/propal/class/propal.class.php', ]; } @@ -339,22 +367,24 @@ function get_sheet_linkable_objects(): array $confCode = 'DIGIQUALI_SHEET_LINK_' . strtoupper($linkableObjectType); $linkableObjects[$linkableObjectType] = [ - 'code' => $confCode, - 'conf' => $conf->global->$confCode, - 'name' => 'Link' . ucfirst($linkableObjectType), - 'description' => 'Link' . ucfirst($linkableObjectType) . 'Description', - 'langs' => $linkableObjectInformations['langs'] ?? '', - 'langfile' => $linkableObjectInformations['langfile'] ?? '', - 'picto' => $linkableObjectInformations['picto'] ?? '', - 'className' => $linkableObjectInformations['className'] ?? '', - 'name_field' => $linkableObjectInformations['name_field'] ?? '', - 'post_name' => $linkableObjectInformations['post_name'] ?? '', - 'link_name' => $linkableObjectInformations['link_name'] ?? '', - 'tab_type' => $linkableObjectInformations['tab_type'] ?? '', - 'fk_parent' => $linkableObjectInformations['fk_parent'] ?? '', - 'parent_post' => $linkableObjectInformations['parent_post'] ?? '', - 'create_url' => $linkableObjectInformations['create_url'] ?? '', - 'class_path' => $linkableObjectInformations['class_path'] ?? '', + 'code' => $confCode, + 'conf' => $conf->global->$confCode, + 'name' => 'Link' . ucfirst($linkableObjectType), + 'description' => 'Link' . ucfirst($linkableObjectType) . 'Description', + 'langs' => $linkableObjectInformations['langs'] ?? '', + 'langfile' => $linkableObjectInformations['langfile'] ?? '', + 'picto' => $linkableObjectInformations['picto'] ?? '', + 'className' => $linkableObjectInformations['className'] ?? '', + 'name_field' => $linkableObjectInformations['name_field'] ?? '', + 'post_name' => $linkableObjectInformations['post_name'] ?? '', + 'link_name' => $linkableObjectInformations['link_name'] ?? '', + 'tab_type' => $linkableObjectInformations['tab_type'] ?? '', + 'hook_name_list' => $linkableObjectInformations['hook_name_list'] ?? '', + 'hook_name_card' => $linkableObjectInformations['hook_name_card'] ?? '', + 'fk_parent' => $linkableObjectInformations['fk_parent'] ?? '', + 'parent_post' => $linkableObjectInformations['parent_post'] ?? '', + 'create_url' => $linkableObjectInformations['create_url'] ?? '', + 'class_path' => $linkableObjectInformations['class_path'] ?? '', ]; if (!empty($linkableObjectInformations['langfile'])) { $langs->load($linkableObjectInformations['langfile']); From 9e7a7edd05d3c8300e17c3470b79dbe78601769e Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 24 Aug 2023 20:19:38 +0200 Subject: [PATCH 03/20] #1513 [Control] add: manage control date --- class/control.class.php | 7 ++- ...9_modDigiQuali_DigiQualiTriggers.class.php | 5 +- langs/fr_FR/digiquali.lang | 2 - view/control/control_card.php | 50 +++++-------------- 4 files changed, 21 insertions(+), 43 deletions(-) diff --git a/class/control.class.php b/class/control.class.php index c46fcce2..69e3c9f6 100644 --- a/class/control.class.php +++ b/class/control.class.php @@ -118,8 +118,8 @@ class Control extends SaturneObject 'date_creation' => ['type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 40, 'notnull' => 1, 'visible' => 2, 'positioncard' => 10], 'tms' => ['type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => 0], 'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 0, 'index' => 0], - 'control_date' => ['type' => 'date', 'label' => 'ControlDate', 'enabled' => 1, 'position' => 63, 'notnull' => 0, 'visible' => 5], - 'next_control_date' => ['type' => 'date', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 5], + 'control_date' => ['type' => 'date', 'label' => 'ControlDate', 'enabled' => 1, 'position' => 63, 'notnull' => 0, 'visible' => 2], + 'next_control_date' => ['type' => 'date', 'label' => 'NextControlDate', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 2], 'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 70, 'notnull' => 1, 'visible' => 5, 'index' => 1, 'default' => 0, 'arrayofkeyval' => [0 => 'Draft', 1 => 'Validated', 2 => 'Locked']], 'note_public' => ['type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0], 'note_private' => ['type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 0], @@ -551,6 +551,9 @@ public function createFromClone(User $user, int $fromID, array $options): int if (empty($options['photos'])) { $object->photo = ''; } + if (property_exists($object, 'control_date')) { + $object->control_date = ''; + } if (property_exists($object, 'next_control_date')) { $object->next_control_date = ''; } diff --git a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php index 0262dbfa..0dbe43e8 100644 --- a/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php +++ b/core/triggers/interface_99_modDigiQuali_DigiQualiTriggers.class.php @@ -231,7 +231,6 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf if (!empty($linkedObject->array_options['options_qc_frequency'])) { $qcFrequency = $linkedObject->array_options['options_qc_frequency']; - $object->control_date = $this->db->idate($now); if ($object->verdict == 2) { $object->next_control_date = $this->db->idate($now); } else { @@ -249,6 +248,10 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf $actioncomm->percentage = ActionComm::EVENT_TODO; $actioncommID = $actioncomm->create($user); } + if (dol_strlen($object->control_date) <= 0) { + $object->control_date = $this->db->idate($now); + $object->setValueFrom('control_date', $object->control_date, '', '', 'date', '', $user); + } } } } diff --git a/langs/fr_FR/digiquali.lang b/langs/fr_FR/digiquali.lang index 577add0d..9179c04d 100644 --- a/langs/fr_FR/digiquali.lang +++ b/langs/fr_FR/digiquali.lang @@ -287,8 +287,6 @@ ControlReminderFrequencyDescription = Choisir la fréquence de rappel ControlReminderType = Type de rappel d'évènement de contrôle ControlReminderTypeDescription = Choisir le type de rappel d'évènement de contrôle
(par défaut : navigateur) controlled = contrôlé(e) -NextControlDateUpdated = La date de prochain contrôle a été mise à jour -ErrorUpdatingNextControlDate = La date de prochain contrôle n'a pas pu être mise à jour PublicSurvey = Interface publique de réponse au contrôle PublicSurveyTitle = Titre de l'interface publique de réponse au contrôle PublicSurveyTitleDescription = Définir le titre de l'interface publique de réponse au contrôle diff --git a/view/control/control_card.php b/view/control/control_card.php index 7e2b115e..73097050 100644 --- a/view/control/control_card.php +++ b/view/control/control_card.php @@ -195,23 +195,6 @@ } require_once __DIR__ . '/../../core/tpl/digiquali_control_answers_save_action.tpl.php'; - if ($action == 'save_next_control_date') { - $day = GETPOST('reday'); - $month = GETPOST('remonth'); - $year = GETPOST('reyear'); - - $object->next_control_date = dol_mktime(0, 0, 0, $month, $day, $year); - - $result = $object->update($user); - - if ($result > 0) { - setEventMessages($langs->trans('NextControlDateUpdated'), []); - } else { - setEventMessages($langs->trans('ErrorUpdatingNextControlDate'), [], 'errors'); - } - header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $id); - exit; - } // Actions builddoc, forcebuilddoc, remove_file. require_once __DIR__ . '/../../../saturne/core/tpl/documents/documents_action.tpl.php'; @@ -641,28 +624,19 @@ print ''; } - include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; + print ''; + print $form->editfieldkey('ControlDate', 'control_date', $object->control_date, $object, $permissiontoadd, 'datepicker'); + print ''; + print $form->editfieldval('ControlDate', 'control_date', $object->control_date, $object, $permissiontoadd, 'datepicker', '', null, null, "id=$object->id"); + print ''; - if ($action != 'edit_next_control_date' && $object->status < $object::STATUS_LOCKED) : - ?> - - '; - $dateSelector .= ''; - $dateSelector .= ''; - $dateSelector .= $form->selectDate($object->next_control_date, 're', 0, 0, 1, '', 1, 1); - $dateSelector .= ''; - $dateSelector .= ''; - ?> - - '; + print $form->editfieldkey('NextControlDate', 'next_control_date', $object->next_control_date, $object, $permissiontoadd, 'datepicker'); + print ''; + print $form->editfieldval('NextControlDate', 'next_control_date', $object->next_control_date, $object, $permissiontoadd, 'datepicker', '', null, null, "id=$object->id"); + print ''; + + include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php'; // Categories if ($conf->categorie->enabled) { From 3c3d1b396fe164786efdb9143b38cf7c6097cf7a Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Thu, 24 Aug 2023 20:23:36 +0200 Subject: [PATCH 04/20] #1506 [Control] add: change check status photo medias --- view/control/control_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/control/control_card.php b/view/control/control_card.php index 7e2b115e..874d4305 100644 --- a/view/control/control_card.php +++ b/view/control/control_card.php @@ -732,7 +732,7 @@ $pathPhotos = $conf->digiquali->multidir_output[$conf->entity] . '/control/'. $object->ref . '/photos/'; $fileArray = dol_dir_list($pathPhotos, 'files'); ?> - status != Control::STATUS_LOCKED) ? '' : 'style="display:none"' ?>> + status < Control::STATUS_LOCKED) ? '' : 'style="display:none"' ?>>