Skip to content

Commit

Permalink
Merge pull request #262 from Eoxia/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
nicolas-eoxia authored Jul 5, 2024
2 parents 0f9f37e + 6c11637 commit d6be091
Show file tree
Hide file tree
Showing 17 changed files with 532 additions and 88 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
## Informations

- Numéro du module : 436351
- Dernière mise à jour : 19/12/2023
- Dernière mise à jour : 05/07/2024
- Éditeur : [Eoxia](https://eoxia.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux
-
### Version

- Version : 1.3.0
- Version : 1.4.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.3
- Saturne Framework : 1.2.1
- Compatibilité : Dolibarr 17.0.2 - 20.0.0
- Saturne Framework : 1.5.1

## Liens

Expand Down
78 changes: 78 additions & 0 deletions admin/product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/* Copyright (C) 2024 EVARISK <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

/**
* \file admin/product.php
* \ingroup easycrm
* \brief EasyCRM product config page.
*/

// Load EasyCRM environment
if (file_exists('../easycrm.main.inc.php')) {
require_once __DIR__ . '/../easycrm.main.inc.php';
} elseif (file_exists('../../easycrm.main.inc.php')) {
require_once __DIR__ . '/../../easycrm.main.inc.php';
} else {
die('Include of easycrm main fails');
}

// Libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';

require_once __DIR__ . '/../lib/easycrm.lib.php';

// Global variables definitions
global $langs, $user;

// Load translation files required by the page
saturne_load_langs(['admin']);

// Get parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');

// Security check - Protection if external user
$permissiontoread = $user->hasRight('easycrm','adminpage','read');

saturne_check_access($permissiontoread);

/*
* View
*/

$title = $langs->trans('ModuleSetup', 'EasyCRM');
$help_url = 'FR:Module_EasyCRM';

saturne_header(0,'', $title, $help_url);

// Subheader
$linkback = '<a href="' . ($backtopage ?: DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans('BackToModuleList') . '</a>';
print load_fiche_titre($title, $linkback, 'easycrm_color@easycrm');

// Configuration header
$head = easycrm_admin_prepare_head();
print dol_get_fiche_head($head, 'product', $title, -1, 'easycrm_color@easycrm');

$constArray['easycrm'] = [
'controldocument' => [
'name' => 'ProductKitConf',
'description' => 'ProductKitConfDesc',
'code' => 'EASYCRM_PRODUCTKIT_DESC_ADD_LINE_PROPAL'
]
];

require_once __DIR__ . '/../../saturne/core/tpl/admin/object/object_const_view.tpl.php';
380 changes: 340 additions & 40 deletions class/actions_easycrm.class.php

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions class/address.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Address extends SaturneObject
/**
* @var int Does object support extrafields ? 0=No, 1=Yes
*/
public int $isextrafieldmanaged = 0;
public $isextrafieldmanaged = 0;

/**
* @var string String with name of icon for signature. Must be the part after the 'object_' into object_signature.png
Expand Down Expand Up @@ -254,12 +254,12 @@ class Address extends SaturneObject
/**
* @var int User ID.
*/
public int $fk_user_creat;
public $fk_user_creat;

/**
* @var int|null User ID.
*/
public ?int $fk_user_modif;
public $fk_user_modif;

/**
* Constructor.
Expand Down
24 changes: 15 additions & 9 deletions core/modules/modEasyCRM.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($db)
$this->editor_url = 'https://www.eoxia.com';

// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
$this->version = '1.3.0';
$this->version = '1.4.0';

// Url to the file with your last numberversion of this module
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
Expand Down Expand Up @@ -130,7 +130,8 @@ public function __construct($db)
'contactcard',
'thirdpartycard',
'thirdpartylist',
'main'
'main',
'pwaadmin'
],
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0,
Expand Down Expand Up @@ -218,6 +219,9 @@ public function __construct($db)
$i++ => ['EASYCRM_EVENT_DESCRIPTION_VISIBLE', 'integer', 1, '', 0, 'current'],
$i++ => ['EASYCRM_EVENT_CATEGORIES_VISIBLE', 'integer', 1, '', 0, 'current'],

// CONST PWA
$i++ => ['EASYCRM_PWA_CLOSE_PROJECT_WHEN_OPPORTUNITY_ZERO', 'integer', 0, '', 0, 'current'],

// CONST ADDRESS
$i++ => ['EASYCRM_DISPLAY_MAIN_ADDRESS', 'integer', 0, '', 0, 'current'],
$i++ => ['EASYCRM_ADDRESS_ADDON', 'chaine', 'mod_address_standard', '', 0, 'current'],
Expand All @@ -238,11 +242,12 @@ public function __construct($db)
$i => ['EASYCRM_DISPLAY_NUMBER_MEDIA_GALLERY', 'integer', 8, '', 0, 'current'],
];

// Some keys to add into the overwriting translation tables
/*$this->overwrite_translation = array(
'en_US:ParentCompany'=>'Parent company or reseller',
'fr_FR:ParentCompany'=>'Maison mère ou revendeur'
)*/
// Some keys to add into the overwriting translation tables
$this->overwrite_translation = [
'fr_FR:ActionAC_EMAIL_IN' => 'Email entrant',
'fr_FR:ActionAC_EMAIL' => 'Email sortant',
'fr_FR:ActionAC_RDV' => 'Rendez-vous physique ou visioconférence'
];

if (!isset($conf->easycrm) || !isset($conf->easycrm->enabled)) {
$conf->easycrm = new stdClass();
Expand Down Expand Up @@ -538,11 +543,12 @@ public function init($options = ''): int
$objectsMetadata = saturne_get_objects_metadata();

$extrafields->addExtraField('commrelaunch', $langs->transnoentities('CommercialsRelaunching'), 'text', 100, 2000, 'projet', 0, 0, '', '', 0, '', 2);
$extrafields->update('commtask', $langs->transnoentities('CommercialTask'), 'sellist', '', 'projet', 0, 0, 100, 'a:1:{s:7:"options";a:1:{s:39:"projet_task:ref:rowid::fk_projet = $ID$";N;}}', 1, '', 4);
$extrafields->addExtraField('commtask', $langs->transnoentities('CommercialTask'), 'sellist', 100, '', 'projet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:39:"projet_task:ref:rowid::fk_projet = $ID$";N;}}', 1, '', 4);
$extrafields->update('commtask', $langs->transnoentities('CommercialTask'), 'sellist', '', 'projet', 0, 0, 100, 'a:1:{s:7:"options";a:1:{s:21:"projet_task:ref:rowid";N;}}', 1, '', 4);
$extrafields->addExtraField('commtask', $langs->transnoentities('CommercialTask'), 'sellist', 100, '', 'projet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:21:"projet_task:ref:rowid";N;}}', 1, '', 4);
$extrafields->addExtraField('projectphone', $langs->transnoentities('ProjectPhone'), 'phone', 100, '', 'projet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:0:"";N;}}', 1, '', 1);
$extrafields->addExtraField('commstatus', $langs->transnoentities('CommercialStatus'), 'sellist', 100, '', 'propal', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:34:"c_commercial_status:label:rowid::1";N;}}', 1, '', 1, 'CommercialStatusHelp');
$extrafields->addExtraField('commrefusal', $langs->transnoentities('RefusalReason'), 'sellist', 100, '', 'propal', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:31:"c_refusal_reason:label:rowid::1";N;}}', 1, '', 1, 'RefusalReasonHelp');
$extrafields->addExtraField('opporigin', $langs->transnoentities('OpportunityOrigin'), 'sellist', 100, '', 'projet', 0, 0, '', 'a:1:{s:7:"options";a:1:{s:19:"c_input_reason:code";N;}}', 1, '', 1);

// Societe extrafields
$extrafields->update('notation_societe_contact', 'NotationObjectContact', 'text', '', 'societe', 0, 0, 100, '', '', '', 5, 'NotationObjectContactHelp', '', '', 0, 'easycrm@easycrm', 1, 0, 0, ['csslist' => 'center']);
Expand Down
22 changes: 11 additions & 11 deletions core/tpl/easycrm_thirdparty_quickcreation.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,56 @@
print '<table class="border centpercent tableforfieldcreate">';

// Name, firstname
if ($conf->global->EASYCRM_THIRDPARTY_NAME_VISIBLE > 0) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_NAME_VISIBLE') > 0) {
print '<tr><td class="titlefieldcreate fieldrequired"><label for="name">' . $langs->trans('ThirdPartyName') . '</label></td>';
print '<td><input type="text" name="name" id="name" class="maxwidth200 widthcentpercentminusx" maxlength="128" value="' . (GETPOSTISSET('name') ? GETPOST('name', 'alpha') : '') . '" autofocus="autofocus"></td>';
print '</tr>';
}

if ($conf->global->EASYCRM_THIRDPARTY_CLIENT_VISIBLE > 0) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_CLIENT_VISIBLE') > 0) {
print '<tr><td class="titlefieldcreate fieldrequired"><label for="name">' . $langs->trans('ProspectCustomer') . '</label></td>';
print '<td>' . $formcompany->selectProspectCustomerType(GETPOSTISSET('client') ? GETPOST('client') : $conf->global->EASYCRM_THIRDPARTY_CLIENT_VALUE, 'client', 'customerprospect', 'form', 'maxwidth200 widthcentpercentminusx') . '</td>';
print '<td>' . $formcompany->selectProspectCustomerType(GETPOSTISSET('client') ? GETPOST('client') : getDolGlobalInt('EASYCRM_THIRDPARTY_CLIENT_VALUE'), 'client', 'customerprospect', 'form', 'maxwidth200 widthcentpercentminusx') . '</td>';
}

// Phone
if ($conf->global->EASYCRM_THIRDPARTY_PHONE_VISIBLE > 0) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_PHONE_VISIBLE') > 0) {
print '<tr><td><label for="phone">' . $langs->trans('Phone') . '</label></td>';
print '<td>' . img_picto('', 'phone', 'class="pictofixedwidth"') . ' <input type="text" name="phone" id="phone" class="maxwidth200 widthcentpercentminusx" value="' . (GETPOSTISSET('phone') ? GETPOST('phone', 'alpha') : '') . '"></td>';
print '</tr>';
}

// Email
if ($conf->global->EASYCRM_THIRDPARTY_EMAIL_VISIBLE > 0) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_EMAIL_VISIBLE') > 0) {
print '<tr><td><label for="email_thirdparty">' . $langs->trans('Email') . '</label></td>';
print '<td>' . img_picto('', 'object_email', 'class="pictofixedwidth"') . ' <input type="text" name="email_thirdparty" id="email_thirdparty" class="maxwidth200 widthcentpercentminusx" value="' . (GETPOSTISSET('email_thirdparty') ? GETPOST('email_thirdparty', 'alpha') : '') . '"></td>';
print '</tr>';
}

// Web
if ($conf->global->EASYCRM_THIRDPARTY_WEB_VISIBLE > 0) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_WEB_VISIBLE') > 0) {
print '<tr><td><label for="url">' . $langs->trans('Web') . '</label></td>';
print '<td>' . img_picto('', 'globe', 'class="pictofixedwidth"') . ' <input type="text" name="url" id="url" class="maxwidth200 widthcentpercentminusx" value="' . (GETPOSTISSET('url') ? GETPOST('url', 'alpha') : '') . '"></td>';
print '</tr>';
}

// Commerical
if ($conf->global->EASYCRM_THIRDPARTY_WEB_VISIBLE > 0) {
// Commercial
if (getDolGlobalInt('EASYCRM_THIRDPARTY_COMMERCIAL_VISIBLE') > 0) {
print '<tr><td>' . $langs->trans('AllocateCommercial') . '</td><td>';
$userList = $form->select_dolusers('', '', 0, null, 0, '', '', 0, 0, 0, ' AND u.statut = 1 AND u.employee = 1', 0, '', '', 0, 1);
print img_picto('', 'user', 'class="pictofixedwidth"') . $form->multiselectarray('commercial', $userList, GETPOST('commercial', 'array'), '', '', 'quatrevingtpercent widthcentpercentminusx');
print '</td></tr>';
}

// Private note
if ($conf->global->EASYCRM_THIRDPARTY_PRIVATE_NOTE_VISIBLE > 0 && isModEnabled('fckeditor')) {
if (getDolGlobalInt('EASYCRM_THIRDPARTY_PRIVATE_NOTE_VISIBLE') > 0 && isModEnabled('fckeditor')) {
print '<tr><td><label for="note_private">' . $langs->trans('NotePrivate') . '</label></td>';
$doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ? GETPOST('note_private', 'alpha') : ''), '', 80, 'dolibarr_notes', 'In', 0, false, ((empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) || $conf->browser->layout == 'phone') ? 0 : 1), ROWS_3, '90%');
$doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ? GETPOST('note_private', 'alpha') : ''), '', 80, 'dolibarr_notes', 'In', 0, false, ((empty(getDolGlobalInt('FCKEDITOR_ENABLE_NOTE_PRIVATE')) || $conf->browser->layout == 'phone') ? 0 : 1), ROWS_3, '90%');
print '<td>' . $doleditor->Create(1) . '</td>';
print '</tr>';
}

// Categories
if (isModEnabled('categorie') && $conf->global->EASYCRM_THIRDPARTY_CATEGORIES_VISIBLE > 0 ) {
if (isModEnabled('categorie') && getDolGlobalInt('EASYCRM_THIRDPARTY_CATEGORIES_VISIBLE') > 0 ) {
print '<tr><td>' . $langs->trans('CustomersProspectsCategoriesShort') . '</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_CUSTOMER, '', 'parent', 64, 0, 1);
print img_picto('', 'category', 'class="pictofixedwidth"') . $form->multiselectarray('categories_customer', $cate_arbo, GETPOST('categories_customer', 'array'), '', 0, 'quatrevingtpercent widthcentpercentminusx');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<label for="opp_percent">
<div class="opp-percent-label">
<span class="label"><?php echo $langs->trans('OpportunityProbability'); ?></span>
<span class="opp_percent-value">0</span>
<span class="opp_percent-value">0 %</span>
</div>
<div class="opp-percent">
<?php echo img_picto('', 'fontawesome_fa-frown-open_fas_#c62828_2em', 'class="percent-image"'); ?>
Expand Down
15 changes: 8 additions & 7 deletions core/tpl/frontend/easycrm_quickcreation_actions_frontend.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,29 +58,30 @@
$project->title = GETPOST('title');
$project->description = GETPOST('description', 'restricthtml');
$project->opp_percent = GETPOST('opp_percent','int');

switch ($project->opp_percent) {
case 20 < 40:
case $project->opp_percent < 20:
$project->opp_status = 1;
break;
case $project->opp_percent < 40:
$project->opp_status = 2;
break;
case 40 < 60:
case $project->opp_percent < 60:
$project->opp_status = 3;
break;
case 60 < 100:
case $project->opp_percent < 100:
$project->opp_status = 4;
break;
case 100:
case $project->opp_percent == 100:
$project->opp_status = 5;
break;
default:
$project->opp_status = 1;
break;
}

$project->opp_amount = price2num(GETPOST('opp_amount', 'int'));
$project->date_c = dol_now();
$project->date_start = dol_now();
$project->statut = 1;
$project->statut = getDolGlobalInt('EASYCRM_PWA_CLOSE_PROJECT_WHEN_OPPORTUNITY_ZERO') > 0 && $project->opp_percent == 0 ? Project::STATUS_CLOSED : Project::STATUS_VALIDATED;
$project->usage_opportunity = 1;
$project->usage_task = 1;

Expand Down
26 changes: 25 additions & 1 deletion core/triggers/interface_99_modEasycrm_EasycrmTriggers.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(DoliDB $db)
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = 'demo';
$this->description = 'EasyCRM triggers';
$this->version = '1.3.0';
$this->version = '1.4.0';
$this->picto = 'easycrm@easycrm';
}

Expand Down Expand Up @@ -127,6 +127,30 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
$actioncomm->label = $langs->transnoentities('AddContactNotificationTrigger');
$actioncomm->create($user);
break;
case 'LINEPROPAL_INSERT' :
if (!empty($object->fk_product) && getDolGlobalInt('EASYCRM_PRODUCTKIT_DESC_ADD_LINE_PROPAL') > 0) {
$product = new Product($this->db);
$product->id = $object->fk_product;
$product->get_sousproduits_arbo();
if (!empty($product->sousprods) && is_array($product->sousprods) && count($product->sousprods)) {
$labelProductService = '';
$tmpArrayOfSubProducts = reset($product->sousprods);
foreach ($tmpArrayOfSubProducts as $subProdVal) {
$productChild = new Product($this->db);
$productChild->fetch($subProdVal[0]);
$concatDesc = dol_concatdesc('<b>' . $productChild->label . '</b>',$productChild->description);
$labelProductService = dol_concatdesc($labelProductService, $concatDesc);
}
$result = $object->setValueFrom('description', $labelProductService, '', '', '', '', $user, '', '');
if ($result < 0) {
$this->error .= $object->error;
$this->errors[] = $object->error;
$this->errors = array_merge($this->errors, $object->errors);
return -1;
}
}
}
break;
}
return 0;
}
Expand Down
Loading

0 comments on commit d6be091

Please sign in to comment.