Skip to content

Commit

Permalink
#27 [Admin] add: conf tags for manage actioncomm event
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Mar 22, 2023
1 parent 2f316e2 commit df287d6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
12 changes: 2 additions & 10 deletions class/actions_easycrm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,13 @@ public function printCommonFooter(array $parameters): int
if (in_array($parameters['currentcontext'], ['thirdpartycomm', 'projectcard'])) {
if (isModEnabled('agenda')) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';

$pictopath = dol_buildpath('/easycrm/img/easycrm_color.png', 1);
$picto = img_picto('', $pictopath, '', 1, 0, 0, '', 'pictoModule');

$actiomcomm = new ActionComm($db);
$category = new Categorie($db);

$category->fetch('', $langs->trans('CommercialRelaunching'));

$filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . $category->id . ')';
$filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . $conf->global->EASYCRM_TAGS_SET . ')';
$actiomcomms = $actiomcomm->getActions(GETPOST('socid'), ($parameters['currentcontext'] != 'thirdpartycomm' ? GETPOST('id') : ''), ($parameters['currentcontext'] != 'thirdpartycomm' ? 'project' : ''), $filter, 'a.datec');
if (is_array($actiomcomms) && !empty($actiomcomms)) {
$nbActiomcomms = count($actiomcomms);
Expand Down Expand Up @@ -286,7 +282,6 @@ public function printCommonFooter(array $parameters): int
if (isModEnabled('agenda') && isModEnabled('project') && $user->hasRight('projet', 'lire') && isModEnabled('saturne')) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';

require_once __DIR__ . '/../../saturne/lib/object.lib.php';

Expand All @@ -303,11 +298,8 @@ public function printCommonFooter(array $parameters): int
$offset = $limit * $page;

$actiomcomm = new ActionComm($db);
$category = new Categorie($db);

$category->fetch('', $langs->trans('CommercialRelaunching'));

$filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . $category->id . ')';
$filter = ' AND a.id IN (SELECT c.fk_actioncomm FROM ' . MAIN_DB_PREFIX . 'categorie_actioncomm as c WHERE c.fk_categorie = ' . $conf->global->EASYCRM_TAGS_SET . ')';
$projects = saturne_fetch_all_object_type('Project', '', '', $limit, $offset);
if (is_array($projects) && !empty($projects)) {
foreach ($projects as $project) {
Expand Down
17 changes: 11 additions & 6 deletions core/modules/modEasyCRM.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ public function __construct($db)
// CONST MODULE
$i++ => ['EASYCRM_VERSION','chaine', $this->version, '', 0, 'current'],
$i++ => ['EASYCRM_DB_VERSION', 'chaine', $this->version, '', 0, 'current'],
$i => ['EASYCRM_SHOW_PATCH_NOTE', 'integer', 1, '', 0, 'current'],
$i++ => ['EASYCRM_SHOW_PATCH_NOTE', 'integer', 1, '', 0, 'current'],
$i => ['EASYCRM_TAGS_SET', 'integer', 0, '', 0, 'current'],
];

// Some keys to add into the overwriting translation tables
Expand Down Expand Up @@ -376,13 +377,17 @@ public function init($options = ''): int
$extrafields->addExtraField('commrelaunch', $langs->transnoentities('CommercialsRelaunching'), 'text', 100, 2000, 'projet', 0, 0, '', '', '', '', 2);
$extrafields->addExtraField('commtask', $langs->transnoentities('CommercialTask'), 'sellist', 100, 2000, 'projet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:39:"projet_task:ref:rowid::fk_projet = $ID$";N;}}', 1, '', 1);

require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';
if (empty($conf->global->EASYCRM_TAGS_SET)) {
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php';

$category = new Categorie($this->db);
$category = new Categorie($this->db);

$category->label = $langs->trans('CommercialRelaunching');
$category->type = 'actioncomm';
$category->create($user);
$category->label = $langs->trans('CommercialRelaunching');
$category->type = 'actioncomm';
$categoryID = $category->create($user);

dolibarr_set_const($this->db, 'EASYCRM_TAGS_SET', $categoryID, 'integer', 0, '', $conf->entity);
}

// Permissions
$this->remove($options);
Expand Down
2 changes: 1 addition & 1 deletion view/quickevent.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
if (isModEnabled('categorie') && $conf->global->EASYCRM_EVENT_CATEGORIES_VISIBLE > 0) {
print '<tr><td>' . $langs->trans('Categories') . '</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_ACTIONCOMM, '', 'parent', 64, 0, 1);
$category->fetch('', $langs->trans('CommercialRelaunching'));
$category->fetch($conf->global->EASYCRM_TAGS_SET);
$categoriesArray = [$category->id, $category->label];
print img_picto('', 'category', 'class="pictofixedwidth"') . $form->multiselectarray('categories', $cate_arbo, GETPOSTISSET('categories') ? GETPOST('categories', 'array') : $categoriesArray, '', 0, 'quatrevingtpercent widthcentpercentminusx');
print '</td></tr>';
Expand Down

0 comments on commit df287d6

Please sign in to comment.