Skip to content

Commit

Permalink
Merge pull request #162 from Eoxia/develop
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
nicolas-eoxia authored Sep 13, 2023
2 parents 264a0af + 06b2858 commit 5fd4649
Show file tree
Hide file tree
Showing 16 changed files with 1,277 additions and 119 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
## Informations

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

- Version : 1.1.0
- Compatibilité : Dolibarr 16.0.0 - 17.0.2
- Saturne Framework : 1.1.1
- Version : 1.2.0
- Compatibilité : Dolibarr 16.0.0 - 18.0.1
- Saturne Framework : 1.1.2

## Liens

Expand Down Expand Up @@ -49,3 +49,4 @@
git clone https://github.com/Eoxia/easycrm.git
git clone https://github.com/Evarisk/saturne.git
```
- Activer le module dans la liste des Modules/Applications installés
75 changes: 0 additions & 75 deletions admin/about.php

This file was deleted.

144 changes: 142 additions & 2 deletions class/actions_easycrm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,31 @@ public function addMoreActionsButtons(array $parameters, CommonObject $object, s
return 0; // or return 1 to replace standard code
}

/**
* Overloading the doActions function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @param CommonObject $object Current object
* @param string $action Current action
* @return int 0 < on error, 0 on success, 1 to replace standard code
* @throws Exception
*/
public function doActions(array $parameters, $object, string $action): int
{
if (in_array($parameters['currentcontext'], ['invoicecard', 'invoicereccard', 'thirdpartycomm', 'thirdpartycard'])) {
if ($action == 'set_notation_object_contact') {
require_once __DIR__ . '/../lib/easycrm_function.lib.php';

set_notation_object_contact($object);

header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit;
}
}

return 0; // or return 1 to replace standard code
}

/**
* Overloading the printCommonFooter function : replacing the parent's function with the one below
*
Expand All @@ -243,7 +268,7 @@ public function addMoreActionsButtons(array $parameters, CommonObject $object, s
*/
public function printCommonFooter(array $parameters): int
{
global $conf, $db, $langs;
global $conf, $db, $langs , $object;

// Do something only for the current context
if (in_array($parameters['currentcontext'], ['thirdpartycomm', 'projectcard'])) {
Expand Down Expand Up @@ -304,6 +329,55 @@ public function printCommonFooter(array $parameters): int
}
}

if (in_array($parameters['currentcontext'], ['invoicelist', 'invoicereclist', 'thirdpartylist'])) {
$cssPath = dol_buildpath('/saturne/css/saturne.min.css', 1);
print '<link href="' . $cssPath . '" rel="stylesheet">';

$jQueryElement = 'notation_' . $object->element . '_contact';
$pictoPath = dol_buildpath('/easycrm/img/easycrm_color.png', 1);
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule'); ?>

<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
var outJS = <?php echo json_encode($picto); ?>;
var cell = $('.liste > tbody > tr.liste_titre').find('th[data-titlekey="' + objectElement + '"]');
cell.prepend(outJS);
</script>
<?php
}

if (in_array($parameters['currentcontext'], ['invoicecard', 'invoicereccard', 'thirdpartycomm', 'thirdpartycard'])) {
$cssPath = dol_buildpath('/saturne/css/saturne.min.css', 1);
print '<link href="' . $cssPath . '" rel="stylesheet">';

$jQueryElement = '.' . $object->element . '_extras_notation_' . $object->element . '_contact';
$pictoPath = dol_buildpath('/easycrm/img/easycrm_color.png', 1);
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');

$out = $picto;
$out .= '<div class="wpeo-button button-strong ' . (($object->array_options['options_notation_' . $object->element . '_contact'] >= 80) ? 'button-green' : 'button-red') . '" style="padding: 0; line-height: 1;">';
$out .= '<span>' . $object->array_options['options_notation_' . $object->element . '_contact'] . '</span>';
$out .= '</div>';
$out .= '<a class="reposition editfielda" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=set_notation_object_contact&token=' . newToken() . '">';
$out .= img_picto($langs->trans('SetNotationObjectContact'), 'fontawesome_fa-redo_fas_#444', 'class="paddingleft"') . '</a>'; ?>

<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
jQuery(objectElement).html(<?php echo json_encode($out); ?>);
</script>
<?php
}

if ($parameters['currentcontext'] == 'contactcard') {
if (in_array(GETPOST('action'), ['create', 'edit'])) {
$out = img_picto('', 'fontawesome_fa-id-card-alt_fas', 'class="pictofixedwidth"'); ?>
<script>
jQuery('#roles').before(<?php echo json_encode($out); ?>);
</script>
<?php
}
}

return 0; // or return 1 to replace standard code
}

Expand All @@ -316,7 +390,7 @@ public function printCommonFooter(array $parameters): int
*/
public function printFieldListValue(array $parameters): int
{
global $conf, $db, $langs, $user;
global $conf, $db, $langs, $object, $user;

// Do something only for the current context
if ($parameters['currentcontext'] == 'projectlist') {
Expand Down Expand Up @@ -362,6 +436,29 @@ public function printFieldListValue(array $parameters): int
}
}

if (in_array($parameters['currentcontext'], ['invoicelist', 'invoicereclist', 'thirdpartylist'])) {
if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) {
$extrafieldName = 'options_notation_' . $object->element . '_contact';
if ($object->element == 'facturerec') {
$specialName = 'facture_rec';
} else {
$specialName = $object->element;
}
$jQueryElement = $specialName . '.notation_' . $object->element . '_contact';
$out = '<div class="wpeo-button button-strong ' . (($parameters['obj']->$extrafieldName >= 80) ? 'button-green' : 'button-red') . '" style="padding: 0; line-height: 1;">';
$out .= '<span>' . $parameters['obj']->$extrafieldName . '</span>';
$out .= '</div>'; ?>

<script>
var objectElement = <?php echo "'" . $jQueryElement . "'"; ?>;
var outJS = <?php echo json_encode($out); ?>;
var cell = $('.liste > tbody > tr.oddeven').find('td[data-key="' + objectElement + '"]').last();
cell.html(outJS);
</script>
<?php
}
}

return 0; // or return 1 to replace standard code
}

Expand All @@ -384,4 +481,47 @@ public function formConfirm(array $parameters, CommonObject $object): int
return 0; // or return 1 to replace standard code
}

/**
* Overloading the completeTabsHead function : replacing the parent's function with the one below
*
* @param array $parameters Hook metadatas (context, etc...)
* @return int 0 < on error, 0 on success, 1 to replace standard code
*/
public function completeTabsHead(array $parameters): int
{
global $langs;

if (in_array($parameters['currentcontext'], ['invoicereccard', 'invoicereccontact'])) {
$nbContact = 0;
// Enable caching of thirdrparty count Contacts
require_once DOL_DOCUMENT_ROOT . '/core/lib/memory.lib.php';
$cacheKey = 'count_contacts_thirdparty_' . $parameters['object']->id;
$dataRetrieved = dol_getcache($cacheKey);

if (!is_null($dataRetrieved)) {
$nbContact = $dataRetrieved;
} else {
$sql = "SELECT COUNT(p.rowid) as nb";
$sql .= " FROM " . MAIN_DB_PREFIX . "socpeople as p";
$sql .= " WHERE p.fk_soc = " . $parameters['object']->socid;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
$nbContact = $obj->nb;
}

dol_setcache($cacheKey, $nbContact, 120); // If setting cache fails, this is not a problem, so we do not test result
}
$parameters['head'][1][0] = DOL_URL_ROOT . '/custom/easycrm/view/contact.php?id=' . $parameters['object']->id;
$parameters['head'][1][1] = $langs->trans('ContactsAddresses');
if ($nbContact > 0) {
$parameters['head'][1][1] .= '<span class="badge marginleftonlyshort">' . $nbContact . '</span>';
}
$parameters['head'][1][2] = 'contact';

$this->results = $parameters;
}

return 0; // or return 1 to replace standard code
}
}
6 changes: 3 additions & 3 deletions class/address.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Address extends SaturneObject
/**
* @var string Module name.
*/
public string $module = 'easycrm';
public $module = 'easycrm';

/**
* @var string Element type of object.
Expand All @@ -51,7 +51,7 @@ class Address extends SaturneObject
* @var int Does this object support multicompany module ?
* 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
*/
public int $ismultientitymanaged = 1;
public $ismultientitymanaged = 1;

/**
* @var int Does object support extrafields ? 0=No, 1=Yes
Expand Down Expand Up @@ -109,7 +109,7 @@ class Address extends SaturneObject
/**
* @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
*/
public array $fields = [
public $fields = [
'rowid' => ['type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'comment' => 'Id'],
'ref' => ['type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'validate' => 1, 'comment' => 'Reference of object'],
'ref_ext' => ['type' => 'varchar(128)', 'label' => 'RefExt', 'enabled' => 1, 'position' => 20, 'notnull' => 0, 'visible' => 0],
Expand Down
Loading

0 comments on commit 5fd4649

Please sign in to comment.