Merge branch 'Dolibarr:develop' into SELECT_PRODUITS_LIST

This commit is contained in:
marcusdeangabriel 2023-03-15 14:29:54 +01:00 committed by GitHub
commit b299068cf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 257 additions and 185 deletions

View File

@ -106,6 +106,9 @@ class DolibarrApiAccess implements iAuthenticate
if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY if (isset($_SERVER['HTTP_DOLAPIKEY'])) { // Param DOLAPIKEY in header can be read with HTTP_DOLAPIKEY
$api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded) $api_key = $_SERVER['HTTP_DOLAPIKEY']; // With header method (recommanded)
} }
if (preg_match('/^dolcrypt:/i', $api_key)) {
throw new RestException(503, 'Bad value for the API key. An API key should not start with dolcrypt:');
}
if ($api_key) { if ($api_key) {
$userentity = 0; $userentity = 0;

View File

@ -1304,7 +1304,8 @@ if (empty($reshook)) {
$object->date_pointoftax = $date_pointoftax; $object->date_pointoftax = $date_pointoftax;
$object->note_public = trim(GETPOST('note_public', 'restricthtml')); $object->note_public = trim(GETPOST('note_public', 'restricthtml'));
$object->note_private = trim(GETPOST('note_private', 'restricthtml')); $object->note_private = trim(GETPOST('note_private', 'restricthtml'));
$object->ref_client = GETPOST('ref_client'); $object->ref_customer = GETPOST('ref_client');
$object->ref_client = $object->ref_customer;
$object->model_pdf = GETPOST('model'); $object->model_pdf = GETPOST('model');
$object->fk_project = GETPOST('projectid', 'int'); $object->fk_project = GETPOST('projectid', 'int');
$object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id')); $object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id'));

View File

@ -261,7 +261,12 @@ if ($object->id > 0) {
$param .= '&limit='.$limit; $param .= '&limit='.$limit;
} }
print load_fiche_titre($langs->trans("ActionsOnContract"), $newcardbutton, ''); // Try to know count of actioncomm from cache
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_thirdparty_'.$object->id;
$nbEvent = dol_getcache($cachekey);
print load_fiche_titre($langs->trans("ActionsOnContract").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>': ''), $newcardbutton, '');
//print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1); //print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $newcardbutton, '', 0, 1, 1);
// List of all actions // List of all actions

View File

@ -98,13 +98,18 @@ class FormMargin
} }
$pv = $line->total_ht; $pv = $line->total_ht;
$pa_ht = ($pv < 0 ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign $pa_ht = (($pv < 0 || ($pv == 0 && $object->type == $object::TYPE_CREDIT_NOTE)) ? -$line->pa_ht : $line->pa_ht); // We choosed to have line->pa_ht always positive in database, so we guess the correct sign
if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1) { // Special case for old situation mode
if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION) if (($object->element == 'facture' && $object->type == $object::TYPE_SITUATION)
|| ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) { || ($object->element == 'facture' && $object->type == $object::TYPE_CREDIT_NOTE && getDolGlobalInt('INVOICE_USE_SITUATION_CREDIT_NOTE') && $object->situation_counter > 0)) {
// We need a compensation relative to $line->situation_percent
$pa = $line->qty * $pa_ht * ($line->situation_percent / 100); $pa = $line->qty * $pa_ht * ($line->situation_percent / 100);
} else { } else {
$pa = $line->qty * $pa_ht; $pa = $line->qty * $pa_ht;
} }
} else {
$pa = $line->qty * $pa_ht;
}
// calcul des marges // calcul des marges
if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise if (isset($line->fk_remise_except) && isset($conf->global->MARGIN_METHODE_FOR_DISCOUNT)) { // remise
@ -233,8 +238,8 @@ class FormMargin
print '});</script>'; print '});</script>';
} }
print '<!-- displayMarginInfos() - Show margin table -->' . "\n";
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<!-- Margin table -->' . "\n";
print '<table class="noborder margintable centpercent" id="margintable">'; print '<table class="noborder margintable centpercent" id="margintable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -87,11 +87,37 @@ function contract_prepare_head(Contrat $object)
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/contrat/agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbEvent = 0;
// Enable caching of thirdparty count actioncomm
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_contract_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbEvent = $dataretrieved;
} else {
$sql = "SELECT COUNT(id) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE fk_element = ".((int) $object->id);
$sql .= " AND elementtype = 'contract'";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbEvent = $obj->nb;
} else {
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
}
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][1] .= '/'; $head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda"); $head[$h][1] .= $langs->trans("Agenda");
if ($nbEvent > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
}
} }
$head[$h][2] = 'agenda'; $head[$h][2] = 'agenda';
$h++; $h++;

View File

@ -5413,7 +5413,7 @@ function load_fiche_titre($titre, $morehtmlright = '', $picto = 'generic', $pict
* @param string $morecss More css to the table * @param string $morecss More css to the table
* @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit). * @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit).
* @param int $hideselectlimit Force to hide select limit * @param int $hideselectlimit Force to hide select limit
* @param int $hidenavigation Force to hide all navigation tools * @param int $hidenavigation Force to hide the arrows and page for navigation
* @param int $pagenavastextinput 1=Do not suggest list of pages to navigate but suggest the page number into an input field. * @param int $pagenavastextinput 1=Do not suggest list of pages to navigate but suggest the page number into an input field.
* @param string $morehtmlrightbeforearrow More html to show (before arrows) * @param string $morehtmlrightbeforearrow More html to show (before arrows)
* @return void * @return void
@ -5536,8 +5536,8 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
} }
} }
if (($savlimit || $morehtmlright || $morehtmlrightbeforearrow) && empty($hidenavigation)) { if ($savlimit || $morehtmlright || $morehtmlrightbeforearrow) {
print_fleche_navigation((int) $page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow); // output the div and ul for previous/last completed with page numbers into $pagelist print_fleche_navigation((int) $page, $file, $options, $nextpage, $pagelist, $morehtmlright, $savlimit, $totalnboflines, $hideselectlimit, $morehtmlrightbeforearrow, $hidenavigation); // output the div and ul for previous/last completed with page numbers into $pagelist
} }
// js to autoselect page field on focus // js to autoselect page field on focus
@ -5571,9 +5571,10 @@ function print_barre_liste($titre, $page, $file, $options = '', $sortfield = '',
* @param int $totalnboflines Total number of records/lines for all pages (if known) * @param int $totalnboflines Total number of records/lines for all pages (if known)
* @param int $hideselectlimit Force to hide select limit * @param int $hideselectlimit Force to hide select limit
* @param string $beforearrows HTML content to show before arrows. Must NOT contains '<li> </li>' tags. * @param string $beforearrows HTML content to show before arrows. Must NOT contains '<li> </li>' tags.
* @param int $hidenavigation Force to hide the arrows and page for navigation
* @return void * @return void
*/ */
function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $betweenarrows = '', $afterarrows = '', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows = '') function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $betweenarrows = '', $afterarrows = '', $limit = -1, $totalnboflines = 0, $hideselectlimit = 0, $beforearrows = '', $hidenavigation = 0)
{ {
global $conf, $langs; global $conf, $langs;
@ -5583,6 +5584,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print $beforearrows; print $beforearrows;
print '</li>'; print '</li>';
} }
if (!empty($hidenavigation)) {
if ((int) $limit > 0 && empty($hideselectlimit)) { if ((int) $limit > 0 && empty($hideselectlimit)) {
$pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000'; $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000';
$pagesizechoices .= ',5000:5000,10000:10000,20000:20000'; $pagesizechoices .= ',5000:5000,10000:10000,20000:20000';
@ -5647,6 +5649,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
print $afterarrows; print $afterarrows;
print '</li>'; print '</li>';
} }
}
print '</ul></div>'."\n"; print '</ul></div>'."\n";
} }
@ -12310,25 +12313,28 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
$out .= '</div>'; $out .= '</div>';
// Title // Title
$libelle = '';
$out .= ' <div class="messaging-title inline-block">'; $out .= ' <div class="messaging-title inline-block">';
if (preg_match('/^TICKET_MSG/', $actionstatic->code)) { if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
$out .= $langs->trans('TicketNewMessage'); $out .= $langs->trans('TicketNewMessage');
} elseif (preg_match('/^TICKET_MSG_PRIVATE/', $actionstatic->code)) { } elseif (preg_match('/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
$out .= $langs->trans('TicketNewMessage').' <em>('.$langs->trans('Private').')</em>'; $out .= $langs->trans('TicketNewMessage').' <em>('.$langs->trans('Private').')</em>';
} else { } elseif (isset($histo[$key]['type'])) {
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'action') { if ($histo[$key]['type'] == 'action') {
$transcode = $langs->trans("Action".$histo[$key]['acode']); $transcode = $langs->transnoentitiesnoconv("Action".$histo[$key]['acode']);
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
$libelle = $histo[$key]['note']; $libelle = $histo[$key]['note'];
$actionstatic->id = $histo[$key]['id']; $actionstatic->id = $histo[$key]['id'];
$out .= dol_trunc($libelle, 120); $out .= dol_escape_htmltag(dol_trunc($libelle, 120));
} } elseif ($histo[$key]['type'] == 'mailing') {
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' '; $out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
$transcode = $langs->trans("Action".$histo[$key]['acode']); $transcode = $langs->transnoentitiesnoconv("Action".$histo[$key]['acode']);
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing'); $libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
$out .= dol_trunc($libelle, 120); $out .= dol_escape_htmltag(dol_trunc($libelle, 120));
} else {
$libelle .= $histo[$key]['note'];
$out .= dol_escape_htmltag(dol_trunc($libelle, 120));
} }
} }
@ -12336,7 +12342,7 @@ function show_actions_messaging($conf, $langs, $db, $filterobj, $objcon = '', $n
$out .= '</h3>'; $out .= '</h3>';
if (!empty($histo[$key]['message']) if (!empty($histo[$key]['message'] && $histo[$key]['message'] != $libelle)
&& $actionstatic->code != 'AC_TICKET_CREATE' && $actionstatic->code != 'AC_TICKET_CREATE'
&& $actionstatic->code != 'AC_TICKET_MODIFY' && $actionstatic->code != 'AC_TICKET_MODIFY'
) { ) {

View File

@ -118,7 +118,6 @@ function facture_prepare_head($object)
$head[$h][2] = 'documents'; $head[$h][2] = 'documents';
$h++; $h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/agenda.php?id='.$object->id; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/agenda.php?id='.$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {

View File

@ -126,16 +126,38 @@ function member_prepare_head(Adherent $object)
$h++; $h++;
// Show agenda tab // Show agenda tab
if (isModEnabled('agenda')) { $head[$h][0] = DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id;
$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
$head[$h][1] = $langs->trans("Events"); $head[$h][1] = $langs->trans("Events");
if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) { if (isModEnabled('agenda')&& (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$nbEvent = 0;
// Enable caching of thirdparty count actioncomm
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$cachekey = 'count_events_member_'.$object->id;
$dataretrieved = dol_getcache($cachekey);
if (!is_null($dataretrieved)) {
$nbEvent = $dataretrieved;
} else {
$sql = "SELECT COUNT(id) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm";
$sql .= " WHERE elementtype = 'member' AND fk_element = ".((int) $object->id);
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$nbEvent = $obj->nb;
} else {
dol_syslog('Failed to count actioncomm '.$db->lasterror(), LOG_ERR);
}
dol_setcache($cachekey, $nbEvent, 120); // If setting cache fails, this is not a problem, so we do not test result.
}
$head[$h][1] .= '/'; $head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda"); $head[$h][1] .= $langs->trans("Agenda");
if ($nbEvent > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbEvent.'</span>';
}
} }
$head[$h][2] = 'agenda'; $head[$h][2] = 'agenda';
$h++; $h++;
}
complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external'); complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'add', 'external');

View File

@ -124,7 +124,7 @@ if ($nolinesbefore) {
<?php if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { ?> <?php if (isModEnabled("multicurrency") && $this->multicurrency_code != $conf->currency) { ?>
<td class="linecoluht_currency right"><span id="title_up_ht_currency"><?php echo $langs->trans('PriceUHTCurrency'); ?></span></td> <td class="linecoluht_currency right"><span id="title_up_ht_currency"><?php echo $langs->trans('PriceUHTCurrency'); ?></span></td>
<?php } ?> <?php } ?>
<?php if (!empty($inputalsopricewithtax)) { ?> <?php if (!empty($inputalsopricewithtax) && !getDolGlobalInt('MAIN_NO_INPUT_PRICE_WITH_TAX')) { ?>
<td class="linecoluttc right"><span id="title_up_ttc"><?php echo $langs->trans('PriceUTTC'); ?></span></td> <td class="linecoluttc right"><span id="title_up_ttc"><?php echo $langs->trans('PriceUTTC'); ?></span></td>
<?php } ?> <?php } ?>
<td class="linecolqty right"><?php echo $langs->trans('Qty'); ?></td> <td class="linecolqty right"><?php echo $langs->trans('Qty'); ?></td>

View File

@ -38,6 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal')); $langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal'));
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'thirdpartyagenda';
if (GETPOST('actioncode', 'array')) { if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
@ -79,9 +80,16 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$result = $object->fetch($socid);
if ($result <= 0) {
accessforbidden('Third party not found');
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
/* /*
* Actions * Actions
*/ */
@ -114,9 +122,6 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
if ($socid > 0) {
$result = $object->fetch($socid);
$title = $langs->trans("Agenda"); $title = $langs->trans("Agenda");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title; $title = $object->name." - ".$title;
@ -184,7 +189,7 @@ if ($socid > 0) {
// $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); // $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus);
if (isModEnabled('agenda')) { if (isModEnabled('agenda')) {
if (!empty($user->rights->agenda->myactions->create) || $user->hasRight('agenda', 'allactions', 'create')) { if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
} }
} }
@ -215,7 +220,7 @@ if ($socid > 0) {
// TODO Replace this with same code than into list.php // TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
} }
}
// End of page // End of page
llxFooter(); llxFooter();