Skip to content

Commit

Permalink
Clean code to avoid strange code manipulation as reported into Doliba…
Browse files Browse the repository at this point in the history
…rr#30259

FIX SQL Error group by
  • Loading branch information
eldy committed Jul 6, 2024
1 parent 830c795 commit 6fb7aee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion htdocs/comm/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture';
$sql .= " WHERE f.fk_soc = s.rowid AND s.rowid = ".((int) $object->id);
$sql .= " AND f.entity IN (".getEntity('invoice').")";
$sql .= ' GROUP BY f.rowid, f.ref, f.type, f.total_ht, f.total_tva, f.total_ttc,';
$sql .= ' GROUP BY f.rowid, f.ref, f.type, f.ref_client, f.total_ht, f.total_tva, f.total_ttc,';
$sql .= ' f.entity, f.datef, f.date_lim_reglement, f.datec, f.paye, f.fk_statut,';
$sql .= ' s.nom, s.rowid';
$sql .= " ORDER BY f.datef DESC, f.datec DESC";
Expand Down
24 changes: 12 additions & 12 deletions htdocs/contrat/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
$ref = GETPOST('ref', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOSTINT('originid');
$idline = GETPOSTINT('elrowid') ? GETPOSTINT('elrowid') : GETPOSTINT('rowid');

// PDF
$hidedetails = (GETPOSTINT('hidedetails') ? GETPOSTINT('hidedetails') : (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS') ? 1 : 0));
Expand Down Expand Up @@ -707,13 +708,12 @@
if (!empty($date_start_update) && !empty($date_end_update) && $date_start_update > $date_end_update) {
setEventMessages($langs->trans("Error").': '.$langs->trans("DateStartPlanned").' > '.$langs->trans("DateEndPlanned"), null, 'errors');
$action = 'editline';
$_GET['rowid'] = GETPOST('elrowid'); // Keep $_GET here. Used by GETPOST('rowid') later
$error++;
}

if (!$error) {
$objectline = new ContratLigne($db);
if ($objectline->fetch(GETPOSTINT('elrowid')) < 0) {
if ($objectline->fetch($idline) < 0) {
setEventMessages($objectline->error, $objectline->errors, 'errors');
$error++;
}
Expand Down Expand Up @@ -1594,7 +1594,7 @@


// Line in view mode
if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) {
if ($action != 'editline' || $idline != $objp->rowid) {
$moreparam = '';
if (getDolGlobalString('CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT') && $objp->statut == ContratLigne::STATUS_CLOSED && $action != 'showclosedlines') {
$moreparam = 'style="display: none;"';
Expand Down Expand Up @@ -1663,18 +1663,18 @@

// Icon move, update et delete (status contract 0=draft,1=validated,2=closed)
print '<td class="nowraponall right">';
if ($user->hasRight('contrat', 'creer') && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->statut >= 0)) {
if ($user->hasRight('contrat', 'creer') && is_array($arrayothercontracts) && count($arrayothercontracts) && ($object->status >= 0)) {
print '<!-- link to move service line into another contract -->';
print '<a class="reposition marginrightonly" style="padding-left: 5px;" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=move&token='.newToken().'&rowid='.$objp->rowid.'">';
print img_picto($langs->trans("MoveToAnotherContract"), 'uparrow');
print '</a>';
}
if ($user->hasRight('contrat', 'creer') && ($object->statut >= 0)) {
if ($user->hasRight('contrat', 'creer') && ($object->status >= 0)) {
print '<a class="reposition marginrightonly editfielda" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=editline&token='.newToken().'&rowid='.$objp->rowid.'">';
print img_edit();
print '</a>';
}
if ($user->hasRight('contrat', 'creer') && ($object->statut >= 0)) {
if ($user->hasRight('contrat', 'creer') && ($object->status >= 0)) {
print '<a class="reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=deleteline&token='.newToken().'&rowid='.$objp->rowid.'">';
print img_delete();
print '</a>';
Expand Down Expand Up @@ -1872,17 +1872,17 @@
/*
* Confirmation to delete service line of contract
*/
if ($action == 'deleteline' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOST('rowid'), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1);
if ($action == 'deleteline' && !$cancel && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == $idline) {
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".((int) $object->id)."&lineid=".((int) $idline), $langs->trans("DeleteContractLine"), $langs->trans("ConfirmDeleteContractLine"), "confirm_deleteline", '', 0, 1);
if ($ret == 'html') {
print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
print '<table class="notopnoleftnoright centpercent"><tr class="oddeven" height="6"><td></td></tr></table>';
}
}

/*
* Confirmation to move service toward another contract
*/
if ($action == 'move' && !$_REQUEST["cancel"] && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == GETPOST('rowid')) {
if ($action == 'move' && !$cancel && $user->hasRight('contrat', 'creer') && $object->lines[$cursorline - 1]->id == $idline) {
$arraycontractid = array();
foreach ($arrayothercontracts as $contractcursor) {
$arraycontractid[$contractcursor->id] = $contractcursor->ref;
Expand All @@ -1893,8 +1893,8 @@
'text' => $langs->trans("ConfirmMoveToAnotherContractQuestion"),
0 => array('type' => 'select', 'name' => 'newcid', 'values' => $arraycontractid));

print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id."&lineid=".GETPOSTINT('rowid'), $langs->trans("MoveToAnotherContract"), $langs->trans("ConfirmMoveToAnotherContract"), "confirm_move", $formquestion);
print '<table class="notopnoleftnoright" width="100%"><tr class="oddeven" height="6"><td></td></tr></table>';
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".((int) $object->id)."&lineid=".((int) $idline), $langs->trans("MoveToAnotherContract"), $langs->trans("ConfirmMoveToAnotherContract"), "confirm_move", $formquestion, 'yes');
print '<table class="notopnoleftnoright centpercent"><tr class="oddeven" height="6"><td></td></tr></table>';
}

// Area with status and activation info of line
Expand Down

0 comments on commit 6fb7aee

Please sign in to comment.