Skip to content

Commit

Permalink
#128 [FactureRec] add: check cron/trad/css button
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Aug 10, 2023
1 parent 591bc07 commit 728781d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions class/actions_easycrm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function printCommonFooter(array $parameters): int
$picto = img_picto('', $pictoPath, '', 1, 0, 0, '', 'pictoModule');

$out = $picto;
$out .= '<div class="wpeo-button button-strong ' . (($object->array_options['options_notation_invoice_rec_contact'] >= 80) ? 'button-green' : 'button-red') . '">';
$out .= '<div class="wpeo-button button-strong ' . (($object->array_options['options_notation_invoice_rec_contact'] >= 80) ? 'button-green' : 'button-red') . '" style="padding: 0; line-height: 1;">';
$out .= '<span>' . $object->array_options['options_notation_invoice_rec_contact'] . '</span>';
$out .= '</div>';
$out .= '<a class="reposition editfielda" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=set_notation_invoice_rec_contact&token=' . newToken() . '">';
Expand Down Expand Up @@ -422,7 +422,7 @@ public function printFieldListValue(array $parameters): int

if ($parameters['currentcontext'] == 'invoicereclist') {
if (isModEnabled('facture') && $user->hasRight('facture', 'lire')) {
$out = '<div class="wpeo-button button-strong ' . (($parameters['obj']->options_notation_invoice_rec_contact >= 80) ? 'button-green' : 'button-red') . '">';
$out = '<div class="wpeo-button button-strong ' . (($parameters['obj']->options_notation_invoice_rec_contact >= 80) ? 'button-green' : 'button-red') . '" style="padding: 0; line-height: 1;">';
$out .= '<span>' . $parameters['obj']->options_notation_invoice_rec_contact . '</span>';
$out .= '</div>'; ?>

Expand Down
16 changes: 14 additions & 2 deletions class/easycrmcron.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class EasycrmCron
*/
public DoliDB $db;

/**
* @var string Last output from end job execution
*/
public string $output = '';

/**
* Constructor
*
Expand All @@ -49,6 +54,8 @@ public function __construct(DoliDB $db)
*/
public function updateNotationInvoiceRecContacts(): int
{
global $langs;

// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture-rec.class.php';

Expand All @@ -62,9 +69,14 @@ public function updateNotationInvoiceRecContacts(): int

if (is_array($factureRecs) &&!empty($factureRecs)) {
foreach ($factureRecs as $factureRec) {
set_notation_invoice_rec_contact($factureRec);
$result = set_notation_invoice_rec_contact($factureRec);
if ($result < 0) {
return -1;
}
}
$this->output = 'test';
$this->output = $langs->transnoentities('NotationInvoiceRecContactsUpdated', count($factureRecs));
} else {
$this->output = $langs->transnoentities('NoInvoiceRec');
}
return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions langs/fr_FR/easycrm.lang
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ NotationInvoiceRecContactHelp = Taux de remplissage des information
SetNotationInvoiceRecContact = Mise à jour de la notation contact client facturation
UpdateNotationInvoiceRecContactsJob = Mise à jour des notations contact client facturation sur les factures récurrentes
UpdateNotationInvoiceRecContactsJobComment = Mise à jour de l'attribut suplémentaire des notations contact client facturation sur les factures récurrentes pour indiquer le taux de remplissage des informations du contact client facturation
NotationInvoiceRecContactsUpdated = Mise à jour des notations contact client facturation sur %d factures récurrentes
NoInvoiceRec = Aucune facture récurrente
5 changes: 3 additions & 2 deletions lib/easycrm_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
* Set notation invoice rec contact
*
* @param CommonObject $object Object
* @return int -1 = error, O = did nothing, 1 = OK
* @throws Exception
*/
function set_notation_invoice_rec_contact(CommonObject $object)
function set_notation_invoice_rec_contact(CommonObject $object): int
{
$notationInvoiceRecContacts = get_notation_invoice_rec_contacts($object);
$notationInvoiceRecContact = array_shift($notationInvoiceRecContacts);
$object->fetch_optionals();
$object->array_options['options_notation_invoice_rec_contact'] = ($notationInvoiceRecContact['percentage'] ?: 0) . ' %';
$object->updateExtraField('notation_invoice_rec_contact');
return $object->updateExtraField('notation_invoice_rec_contact');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion view/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
global $conf, $db, $hookmanager, $langs, $user;

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

// Get parameters
$id = (GETPOSTISSET('facid') ? GETPOST('facid', 'int') : GETPOST('id', 'int'));
Expand Down

0 comments on commit 728781d

Please sign in to comment.