Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2022-12-10 18:49:52 +01:00
commit 51454102ae
5 changed files with 51 additions and 25 deletions

View File

@ -52,7 +52,12 @@ $langs->loadLangs(array("interventions", "admin", "compta", "bills"));
// Security check // Security check
$id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int')); $id = (GETPOST('fichinterid', 'int') ?GETPOST('fichinterid', 'int') : GETPOST('id', 'int'));
$ref = GETPOST('ref', 'alpha');
$date_next_execution = GETPOST('date_next_execution', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha');
$socid = GETPOST('socid', 'int');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
@ -62,12 +67,19 @@ if ($action == "create" || $action == "add") {
} }
$result = restrictedArea($user, 'ficheinter', $id, $objecttype); $result = restrictedArea($user, 'ficheinter', $id, $objecttype);
if ($page == -1) { // Load variable for pagination
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
// If $page is not defined, or '' or -1 or if we click on clear filters
$page = 0; $page = 0;
} }
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
@ -102,6 +114,17 @@ $arrayfields = array(
* Actions * Actions
*/ */
if ($cancel) {
/*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/
if (!empty($backtopageforcancel)) {
header("Location: ".$backtopageforcancel);
exit;
} elseif (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
$action = '';
}
// Create predefined intervention // Create predefined intervention
if ($action == 'add') { if ($action == 'add') {
@ -130,6 +153,8 @@ if ($action == 'add') {
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors');
$action = "create"; $action = "create";
$error++; $error++;
} else {
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
} }
if ($nb_gen_max === '') { if ($nb_gen_max === '') {
setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors'); setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors');
@ -151,7 +176,6 @@ if ($action == 'add') {
$object->nb_gen_max = $nb_gen_max; $object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int'); $object->auto_validate = GETPOST('auto_validate', 'int');
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$object->date_when = $date_next_execution; $object->date_when = $date_next_execution;
if ($object->create($user) > 0) { if ($object->create($user) > 0) {
@ -268,6 +292,7 @@ if ($action == 'create') {
print '<form action="card-rec.php" method="post">'; print '<form action="card-rec.php" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="fichinterid" value="'.$object->id.'">'; print '<input type="hidden" name="fichinterid" value="'.$object->id.'">';
print dol_get_fiche_head(); print dol_get_fiche_head();
@ -332,7 +357,7 @@ if ($action == 'create') {
if (isModEnabled('contrat')) { if (isModEnabled('contrat')) {
$formcontract = new FormContract($db); $formcontract = new FormContract($db);
print "<tr><td>".$langs->trans("Contract")."</td><td>"; print "<tr><td>".$langs->trans("Contract")."</td><td>";
$contractid = GETPOST('contractid') ?GETPOST('contractid') : $object->fk_contract; $contractid = GETPOST('contractid') ? GETPOST('contractid') : (!empty($object->fk_contract) ? $object->fk_contract : 0) ;
$numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid'); $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid');
print "</td></tr>"; print "</td></tr>";
} }
@ -357,7 +382,7 @@ if ($action == 'create') {
// First date of execution for cron // First date of execution for cron
print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>"; print "<tr><td>".$langs->trans('NextDateToExecution')."</td><td>";
if ($date_next_execution != "") { if (empty($date_next_execution)) {
$date_next_execution = (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); $date_next_execution = (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1);
} }
print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1); print $form->selectDate($date_next_execution, '', 1, 1, '', "add", 1, 1);
@ -763,22 +788,22 @@ if ($action == 'create') {
} }
$sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " WHERE f.fk_soc = s.rowid";
$sql .= " AND f.entity = ".$conf->entity; $sql .= " AND f.entity = ".$conf->entity;
if ($socid) { if (!empty($socid)) {
$sql .= " AND s.rowid = ".((int) $socid); $sql .= " AND s.rowid = ".((int) $socid);
} }
if (empty($user->rights->societe->client->voir) && !$socid) { if (empty($user->rights->societe->client->voir) && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
} }
if ($search_ref) { if (!empty($search_ref)) {
$sql .= natural_search('f.titre', $search_ref); $sql .= natural_search('f.titre', $search_ref);
} }
if ($search_societe) { if (!empty($search_societe)) {
$sql .= natural_search('s.nom', $search_societe); $sql .= natural_search('s.nom', $search_societe);
} }
if ($search_frequency == '1') { if (!empty($search_frequency) && $search_frequency == '1') {
$sql .= ' AND f.frequency > 0'; $sql .= ' AND f.frequency > 0';
} }
if ($search_frequency == '0') { if (isset($search_frequency) && (string) $search_frequency == '0') {
$sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)';
} }

View File

@ -1642,7 +1642,7 @@ if ($action == 'create') {
// Create intervention model // Create intervention model
if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) {
print '<div class="inline-block divButAction">'; print '<div class="inline-block divButAction">';
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$object->id).'">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>';
print '</div>'; print '</div>';
} }

View File

@ -234,7 +234,7 @@ class FichinterRec extends Fichinter
0, 0,
$fichintsrc->lines[$i]->product_type, $fichintsrc->lines[$i]->product_type,
$fichintsrc->lines[$i]->special_code, $fichintsrc->lines[$i]->special_code,
$fichintsrc->lines[$i]->label, !empty($fichintsrc->lines[$i]->label) ? $fichintsrc->lines[$i]->label : "",
$fichintsrc->lines[$i]->fk_unit $fichintsrc->lines[$i]->fk_unit
); );
@ -304,10 +304,10 @@ class FichinterRec extends Fichinter
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author; $this->user_author = $obj->fk_user_author;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = !empty($obj->model_pdf) ? $obj->model_pdf : "";
$this->modelpdf = $obj->model_pdf; // deprecated $this->modelpdf = !empty($obj->model_pdf) ? $obj->model_pdf : ""; // deprecated
$this->rang = $obj->rang; $this->rang = !empty($obj->rang) ? $obj->rang : "";
$this->special_code = $obj->special_code; $this->special_code = !empty($obj->special_code) ? $obj->special_code : "";
$this->frequency = $obj->frequency; $this->frequency = $obj->frequency;
$this->unit_frequency = $obj->unit_frequency; $this->unit_frequency = $obj->unit_frequency;
$this->date_when = $this->db->jdate($obj->date_when); $this->date_when = $this->db->jdate($obj->date_when);
@ -384,9 +384,9 @@ class FichinterRec extends Fichinter
$line->subprice = $objp->subprice; $line->subprice = $objp->subprice;
$line->tva_tx = $objp->tva_tx; $line->tva_tx = $objp->tva_tx;
$line->remise_percent = $objp->remise_percent; $line->remise_percent = $objp->remise_percent;
$line->fk_remise_except = $objp->fk_remise_except; $line->fk_remise_except = !empty($objp->fk_remise_except) ? $objp->fk_remise_except : "";
$line->fk_product = $objp->fk_product; $line->fk_product = $objp->fk_product;
$line->info_bits = $objp->info_bits; $line->info_bits = !empty($objp->info_bits) ? $objp->info_bits : "";
$line->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva; $line->total_tva = $objp->total_tva;
$line->total_ttc = $objp->total_ttc; $line->total_ttc = $objp->total_ttc;

View File

@ -288,11 +288,11 @@ foreach ($data as $val) {
print '<tr class="oddeven" height="24">'; print '<tr class="oddeven" height="24">';
print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>'; print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&amp;mode='.$mode.($socid > 0 ? '&socid='.$socid : '').($userid > 0 ? '&userid='.$userid : '').'">'.$year.'</a></td>';
print '<td class="right">'.$val['nb'].'</td>'; print '<td class="right">'.$val['nb'].'</td>';
print '<td class="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'</td>'; print '<td class="right opacitylow" style="'.((!isset($val['nb_diff']) || $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['nb_diff']) ? round($val['nb_diff']): "0").'%</td>';
print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>'; print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
print '<td class="right" style="'.(($val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['total_diff']).'</td>'; print '<td class="right opacitylow" style="'.((!isset($val['total_diff']) || $val['total_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['total_diff']) ? round($val['total_diff']) : "0").'%</td>';
print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>'; print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
print '<td class="right" style="'.(($val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['avg_diff']).'</td>'; print '<td class="right opacitylow" style="'.((!isset($val['avg_diff']) || $val['avg_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.(isset($val['avg_diff']) ? round($val['avg_diff']) : "0").'%</td>';
print '</tr>'; print '</tr>';
$oldyear = $year; $oldyear = $year;
} }

View File

@ -29,6 +29,8 @@ require_once DOL_DOCUMENT_ROOT.'/reception/class/receptionstats.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$year = GETPOST("year", 'int'); $year = GETPOST("year", 'int');
$socid = GETPOST("socid", 'int');
$userid = GETPOST("userid", 'int');
// Security check // Security check
if ($user->socid) { if ($user->socid) {
@ -49,9 +51,8 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
$mesg = ''; $mesg = '';
print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.GETPOST("year", 'int'), $mesg); print load_fiche_titre($langs->trans("StatisticsOfReceptions").' '.GETPOST("year", 'int'), $mesg);
$stats = new ReceptionStats($db, $socid, '', ($userid > 0 ? $userid : 0));
$stats = new ReceptionStats($db); $data = $stats->getNbByMonth($year);
$data = $stats->getNbReceptionByMonth(GETPOST("year", 'int'));
dol_mkdir($conf->reception->dir_temp); dol_mkdir($conf->reception->dir_temp);