From 55c9f37ffade081d9e98debac711bd3a1e47e01e Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 14 Jun 2021 13:37:02 +0000 Subject: [PATCH 1/2] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- .../accountancy/class/bookkeeping.class.php | 10 +- htdocs/compta/cashcontrol/report.php | 12 +- htdocs/compta/facture/class/facture.class.php | 22 +- htdocs/contact/card.php | 34 +-- .../boxes/box_graph_new_vs_close_ticket.php | 6 +- htdocs/core/lib/invoice.lib.php | 16 +- .../fourn/class/fournisseur.facture.class.php | 22 +- htdocs/partnership/admin/setup.php | 6 +- .../class/partnershiputils.class.php | 98 ++++---- htdocs/partnership/partnership_list.php | 14 +- htdocs/product/card.php | 12 +- htdocs/product/stock/card.php | 8 +- htdocs/salaries/payments.php | 231 +++++++++++++----- htdocs/societe/partnership.php | 32 ++- 14 files changed, 325 insertions(+), 198 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 59d74783d04..6bd39f4e227 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -297,11 +297,11 @@ class BookKeeping extends CommonObject $sql .= " AND fk_doc = ".((int) $this->fk_doc); if (!empty($conf->global->ACCOUNTANCY_ENABLE_FKDOCDET)) { // DO NOT USE THIS IN PRODUCTION. This will generate a lot of trouble into reports and will corrupt database (by generating duplicate entries. - $sql .= " AND fk_docdet = " . $this->fk_docdet; // This field can be 0 if record is for several lines + $sql .= " AND fk_docdet = ".$this->fk_docdet; // This field can be 0 if record is for several lines } $sql .= " AND numero_compte = '".$this->db->escape($this->numero_compte)."'"; $sql .= " AND label_operation = '".$this->db->escape($this->label_operation)."'"; - $sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features + $sql .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features $resql = $this->db->query($sql); @@ -318,7 +318,7 @@ class BookKeeping extends CommonObject $sqlnum .= " AND fk_docdet = ".((int) $this->fk_docdet); } $sqlnum .= " AND doc_ref = '".$this->db->escape($this->doc_ref)."'"; // ref of source object - $sqlnum .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features + $sqlnum .= " AND entity = ".$conf->entity; // Do not use getEntity for accounting features dol_syslog(get_class($this).":: create sqlnum=".$sqlnum, LOG_DEBUG); $resqlnum = $this->db->query($sqlnum); @@ -331,7 +331,7 @@ class BookKeeping extends CommonObject if (empty($this->piece_num)) { $sqlnum = "SELECT MAX(piece_num)+1 as maxpiecenum"; $sqlnum .= " FROM ".MAIN_DB_PREFIX.$this->table_element; - $sqlnum .= " WHERE entity = ".$conf->entity; // Do not use getEntity for accounting features + $sqlnum .= " WHERE entity = ".$conf->entity; // Do not use getEntity for accounting features $resqlnum = $this->db->query($sqlnum); if ($resqlnum) { @@ -1067,7 +1067,7 @@ class BookKeeping extends CommonObject $line->label_operation = $obj->label_operation; $line->debit = $obj->debit; $line->credit = $obj->credit; - $line->montant = $obj->amount; // deprecated + $line->montant = $obj->amount; // deprecated $line->amount = $obj->amount; $line->sens = $obj->sens; $line->lettering_code = $obj->lettering_code; diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index de597a608dc..6a23beab86b 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -126,7 +126,7 @@ $sql .= " WHERE pf.fk_facture = f.rowid AND p.rowid = pf.fk_paiement AND cp.id = $sql .= " AND f.module_source = '".$db->escape($posmodule)."'"; $sql .= " AND f.pos_source = '".$db->escape($terminalid)."'"; $sql .= " AND f.paye = 1"; -$sql .= " AND p.entity = ".$conf->entity; // Never share entities for features related to accountancy +$sql .= " AND p.entity = ".$conf->entity; // Never share entities for features related to accountancy /*if ($key == 'cash') $sql.=" AND cp.code = 'LIQ'"; elseif ($key == 'cheque') $sql.=" AND cp.code = 'CHQ'"; elseif ($key == 'card') $sql.=" AND cp.code = 'CB'"; @@ -222,7 +222,7 @@ if ($resql) { $invoicetmp->fetch($objp->facid); if (empty($cacheinvoiceid[$objp->facid])) { - $cacheinvoiceid[$objp->facid] = $objp->facid; // First time this invoice is found into list of invoice x payments + $cacheinvoiceid[$objp->facid] = $objp->facid; // First time this invoice is found into list of invoice x payments foreach ($invoicetmp->lines as $line) { $totalqty += $line->qty; $totalvat += $line->total_tva; @@ -348,21 +348,21 @@ if ($resql) { print '
'; print '

'; - print $langs->trans("Cash").' '.($transactionspertype['CASH']?'('.$transactionspertype['CASH'].')':'').': '.price($cash).''; + print $langs->trans("Cash").' '.($transactionspertype['CASH'] ? '('.$transactionspertype['CASH'].')' : '').': '.price($cash).''; if ($object->status == $object::STATUS_VALIDATED && $cash != $object->cash) { print ' <> '.$langs->trans("Declared").': '.price($object->cash).''; } print "
"; //print '
'; - print $langs->trans("PaymentTypeCHQ").' '.($transactionspertype['CHQ']?'('.$transactionspertype['CHQ'].')':'').': '.price($cheque).''; + print $langs->trans("PaymentTypeCHQ").' '.($transactionspertype['CHQ'] ? '('.$transactionspertype['CHQ'].')' : '').': '.price($cheque).''; if ($object->status == $object::STATUS_VALIDATED && $cheque != $object->cheque) { print ' <> '.$langs->trans("Declared").': '.price($object->cheque).''; } print "
"; //print '
'; - print $langs->trans("PaymentTypeCB").' '.($transactionspertype['CB']?'('.$transactionspertype['CB'].')':'').': '.price($bank).''; + print $langs->trans("PaymentTypeCB").' '.($transactionspertype['CB'] ? '('.$transactionspertype['CB'].')' : '').': '.price($bank).''; if ($object->status == $object::STATUS_VALIDATED && $bank != $object->card) { print ' <> '.$langs->trans("Declared").': '.price($object->card).''; } @@ -370,7 +370,7 @@ if ($resql) { // print '
'; if ($other) { - print ''.$langs->trans("Other").' '.($transactionspertype['OTHER']?'('.$transactionspertype['OTHER'].')':'').': '.price($other).""; + print ''.$langs->trans("Other").' '.($transactionspertype['OTHER'] ? '('.$transactionspertype['OTHER'].')' : '').': '.price($other).""; print '
'; } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1ee946e8a00..940cd146f7b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -522,7 +522,7 @@ class Facture extends CommonInvoice $this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project; $this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public; $this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private; - $this->model_pdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->model_pdf; + $this->model_pdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->model_pdf; $this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id; $this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id; $this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account; @@ -1180,8 +1180,8 @@ class Facture extends CommonInvoice // Clear fields $object->date = (empty($this->date) ? dol_now() : $this->date); - $object->user_author = $user->id; // deprecated - $object->user_valid = null; // deprecated + $object->user_author = $user->id; // deprecated + $object->user_valid = null; // deprecated $object->fk_user_author = $user->id; $object->fk_user_valid = null; $object->fk_facture_source = 0; @@ -1227,7 +1227,7 @@ class Facture extends CommonInvoice } } - $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext + $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext } // Create clone @@ -1672,9 +1672,9 @@ class Facture extends CommonInvoice $this->note = $obj->note_private; // deprecated $this->note_private = $obj->note_private; $this->note_public = $obj->note_public; - $this->user_author = $obj->fk_user_author; // deprecated - $this->user_valid = $obj->fk_user_valid; // deprecated - $this->fk_user_author = $obj->fk_user_author; + $this->user_author = $obj->fk_user_author; // deprecated + $this->user_valid = $obj->fk_user_valid; // deprecated + $this->fk_user_author = $obj->fk_user_author; $this->fk_user_valid = $obj->fk_user_valid; $this->model_pdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf; // deprecated @@ -3430,7 +3430,7 @@ class Facture extends CommonInvoice $qty = price2num($qty); $pu = price2num($pu); $pu_ht_devise = price2num($pu_ht_devise); - $pa_ht = price2num($pa_ht); + $pa_ht = price2num($pa_ht); if (!preg_match('/\((.*)\)/', $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5' } @@ -4158,7 +4158,7 @@ class Facture extends CommonInvoice if (!empty($conf->global->INVOICE_USE_SITUATION_CREDIT_NOTE)) { // Keep invoices that are not situation invoices or that are the last in serie if it is a situation invoice $sql .= " AND (f.type <> ".self::TYPE_SITUATION." OR f.rowid IN "; - $sql .= '(SELECT MAX(fs.rowid)'; // This select returns several ID becasue of the group by later + $sql .= '(SELECT MAX(fs.rowid)'; // This select returns several ID becasue of the group by later $sql .= " FROM ".MAIN_DB_PREFIX."facture as fs"; $sql .= " WHERE fs.entity IN (".getEntity('invoice').")"; $sql .= " AND fs.type = ".self::TYPE_SITUATION; @@ -4166,7 +4166,7 @@ class Facture extends CommonInvoice if ($socid > 0) { $sql .= " AND fs.fk_soc = ".((int) $socid); } - $sql .= " GROUP BY fs.situation_cycle_ref)"; // For each situation_cycle_ref, we take the higher rowid + $sql .= " GROUP BY fs.situation_cycle_ref)"; // For each situation_cycle_ref, we take the higher rowid $sql .= ")"; } else { $sql .= " AND f.type <> ".self::TYPE_SITUATION; // Keep invoices that are not situation invoices @@ -5594,7 +5594,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= ", total_localtax2=".price2num($this->total_localtax2); } $sql .= ", fk_product_fournisseur_price=".(!empty($this->fk_fournprice) ? "'".$this->db->escape($this->fk_fournprice)."'" : "null"); - $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) + $sql .= ", buy_price_ht=".(($this->pa_ht || $this->pa_ht === 0 || $this->pa_ht === '0') ? price2num($this->pa_ht) : "null"); // $this->pa_ht should always be defined (set to 0 or to sell price depending on option) $sql .= ", fk_parent_line=".($this->fk_parent_line > 0 ? $this->fk_parent_line : "null"); if (!empty($this->rang)) { $sql .= ", rang=".((int) $this->rang); diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index d185815b51a..dea4f9d185d 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -225,7 +225,7 @@ if (empty($reshook)) { $action = 'create'; } - if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && $object->no_email==-1 && !empty($object->email)) { + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && $object->no_email == -1 && !empty($object->email)) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); $action = 'create'; @@ -256,7 +256,7 @@ if (empty($reshook)) { if (empty($error)) { // Categories association $contcats = GETPOST('contcats', 'array'); - if (count($contcats)>0) { + if (count($contcats) > 0) { $result = $object->setCategories($contcats); if ($result <= 0) { $error++; @@ -268,8 +268,8 @@ if (empty($reshook)) { if (empty($error) && !empty($conf->mailing->enabled) && !empty($object->email)) { // Add mass emailing flag into table mailing_unsubscribe - $result=$object->setNoEmail($object->no_email); - if ($result<0) { + $result = $object->setNoEmail($object->no_email); + if ($result < 0) { $error++; $errors = array_merge($errors, ($object->error ? array($object->error) : $object->errors)); $action = 'create'; @@ -297,7 +297,7 @@ if (empty($reshook)) { $object->old_lastname = (string) GETPOST("old_lastname", 'alpha'); $object->old_firstname = (string) GETPOST("old_firstname", 'alpha'); - $result = $object->delete(); // TODO Add $user as first param + $result = $object->delete(); // TODO Add $user as first param if ($result > 0) { if ($backtopage) { header("Location: ".$backtopage); @@ -317,7 +317,7 @@ if (empty($reshook)) { $action = 'edit'; } - if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1 && GETPOST("no_email", "int")==-1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { + if (!empty($conf->mailing->enabled) && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1 && GETPOST("no_email", "int") == -1 && !empty(GETPOST('email', 'custom', 0, FILTER_SANITIZE_EMAIL))) { $error++; $errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("No_Email")); $action = 'edit'; @@ -417,7 +417,7 @@ if (empty($reshook)) { $object->note_public = (string) GETPOST("note_public", 'restricthtml'); $object->note_private = (string) GETPOST("note_private", 'restricthtml'); - $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty + $object->roles = GETPOST("roles", 'array'); // Note GETPOSTISSET("role") is null when combo is empty // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -436,8 +436,8 @@ if (empty($reshook)) { // Update mass emailing flag into table mailing_unsubscribe if (GETPOSTISSET('no_email') && $object->email) { $no_email = GETPOST('no_email', 'int'); - $result=$object->setNoEmail($no_email); - if ($result<0) { + $result = $object->setNoEmail($no_email); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } @@ -779,7 +779,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Unsubscribe if (!empty($conf->mailing->enabled)) { - if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1) { + if ($conf->use_javascript_ajax && $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1) { print "\n".''."\n"; } if (!GETPOSTISSET("no_email") && !empty($object->email)) { - $result=$object->getNoEmail(); - if ($result<0) { + $result = $object->getNoEmail(); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } print ''; print ''; - print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS==-1)).''; + print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ? GETPOST("no_email", 'int') : $conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS), 1, false, ($conf->global->MAILING_CONTACT_DEFAULT_BULK_STATUS == -1)).''; print ''; } @@ -1078,8 +1078,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''."\n"; } if (!GETPOSTISSET("no_email") && !empty($object->email)) { - $result=$object->getNoEmail(); - if ($result<0) { + $result = $object->getNoEmail(); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } } @@ -1313,8 +1313,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Unsubscribe opt-out if (!empty($conf->mailing->enabled)) { - $result=$object->getNoEmail(); - if ($result<0) { + $result = $object->getNoEmail(); + if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } print ''.$langs->trans("No_Email").''.yn($object->no_email).''; diff --git a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php index 5b17c335f3f..f2e2170a1b8 100644 --- a/htdocs/core/boxes/box_graph_new_vs_close_ticket.php +++ b/htdocs/core/boxes/box_graph_new_vs_close_ticket.php @@ -89,7 +89,7 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes $data = array(); $totalnb = 0; $sql = "SELECT COUNT(t.datec) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; $sql .= " WHERE CAST(t.datec AS DATE) = CURRENT_DATE"; $sql .= " AND t.fk_statut <> 8"; $sql .= " GROUP BY CAST(t.datec AS DATE)"; @@ -107,7 +107,7 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes dol_print_error($this->db); } $sql = "SELECT COUNT(t.date_close) as nb"; - $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; $sql .= " WHERE CAST(t.date_close AS DATE) = CURRENT_DATE"; $sql .= " AND t.fk_statut = 8"; $sql .= " GROUP BY CAST(t.date_close AS DATE)"; @@ -148,7 +148,7 @@ class box_graph_new_vs_close_ticket extends ModeleBoxes $stringtoprint .= $px1->show($totalnb ? 0 : 1); } $stringtoprint .= '

'; - $this->info_box_contents[][]=array( + $this->info_box_contents[][] = array( 'td' => 'class="center"', 'text' => $stringtoprint ); diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php index c328d659b93..3838829f8cd 100644 --- a/htdocs/core/lib/invoice.lib.php +++ b/htdocs/core/lib/invoice.lib.php @@ -508,16 +508,16 @@ function getNumberInvoicesPieChart($mode) while ($i < $num) { $obj = $db->fetch_object($resql); - $dataseries = array(array($langs->trans('InvoiceLate30Days'),$obj->nblate30) - ,array($langs->trans('InvoiceLate15Days'),$obj->nblate15-$obj->nblate30) - ,array($langs->trans('InvoiceLateMinus15Days'),$obj->nblatenow-$obj->nblate15) - ,array($langs->trans('InvoiceNotLate'),$obj->nbnotlatenow-$obj->nbnotlate15) - ,array($langs->trans('InvoiceNotLate15Days'),$obj->nbnotlate15-$obj->nbnotlate30) - ,array($langs->trans('InvoiceNotLate30Days'),$obj->nbnotlate30)); + $dataseries = array(array($langs->trans('InvoiceLate30Days'), $obj->nblate30) + ,array($langs->trans('InvoiceLate15Days'), $obj->nblate15 - $obj->nblate30) + ,array($langs->trans('InvoiceLateMinus15Days'), $obj->nblatenow - $obj->nblate15) + ,array($langs->trans('InvoiceNotLate'), $obj->nbnotlatenow - $obj->nbnotlate15) + ,array($langs->trans('InvoiceNotLate15Days'), $obj->nbnotlate15 - $obj->nbnotlate30) + ,array($langs->trans('InvoiceNotLate30Days'), $obj->nbnotlate30)); $i++; } foreach ($dataseries as $key=>$value) { - $total+=$value[1]; + $total += $value[1]; } $colorseries = array($badgeStatus8, $badgeStatus1, $badgeStatus3, $badgeStatus4, $badgeStatus11, '-'.$badgeStatus11); @@ -615,7 +615,7 @@ function getCustomerInvoiceDraftTable($maxCount = 500, $socid = 0) $sql .= " s.nom, s.rowid, s.email, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,"; $sql .= " cc.rowid, cc.code"; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ", sc.fk_soc, sc.fk_user"; + $sql .= ", sc.fk_soc, sc.fk_user"; } // Add Group from hooks diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f5840712807..0c825672f65 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -714,7 +714,7 @@ class FactureFournisseur extends CommonInvoice $this->remise = $obj->remise; $this->close_code = $obj->close_code; $this->close_note = $obj->close_note; - $this->tva = $obj->tva; + $this->tva = $obj->tva; $this->total_localtax1 = $obj->localtax1; $this->total_localtax2 = $obj->localtax2; $this->total_ht = $obj->total_ht; @@ -729,7 +729,7 @@ class FactureFournisseur extends CommonInvoice $this->fk_project = $obj->fk_project; $this->cond_reglement_id = $obj->fk_cond_reglement; $this->cond_reglement_code = $obj->cond_reglement_code; - $this->cond_reglement = $obj->cond_reglement_label; // deprecated + $this->cond_reglement = $obj->cond_reglement_label; // deprecated $this->cond_reglement_label = $obj->cond_reglement_label; $this->cond_reglement_doc = $obj->cond_reglement_doc; $this->fk_account = $obj->fk_account; @@ -3234,8 +3234,8 @@ class SupplierInvoiceLine extends CommonObjectLine $this->ref_supplier = $obj->ref_supplier; $this->product_desc = $obj->product_desc; - $this->subprice = $obj->pu_ht; - $this->pu_ht = $obj->pu_ht; + $this->subprice = $obj->pu_ht; + $this->pu_ht = $obj->pu_ht; $this->pu_ttc = $obj->pu_ttc; $this->tva_tx = $obj->tva_tx; $this->localtax1_tx = $obj->localtax1_tx; @@ -3245,7 +3245,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->qty = $obj->qty; $this->remise_percent = $obj->remise_percent; - $this->fk_remise_except = $obj->fk_remise_except; + $this->fk_remise_except = $obj->fk_remise_except; $this->tva = $obj->total_tva; // deprecated $this->total_ht = $obj->total_ht; $this->total_tva = $obj->total_tva; @@ -3401,8 +3401,8 @@ class SupplierInvoiceLine extends CommonObjectLine $sql .= ", pu_ttc = ".price2num($this->pu_ttc); $sql .= ", qty = ".price2num($this->qty); $sql .= ", remise_percent = ".price2num($this->remise_percent); - if ($this->fk_remise_except) $sql.= ", fk_remise_except=".((int) $this->fk_remise_except); - else $sql.= ", fk_remise_except=null"; + if ($this->fk_remise_except) $sql .= ", fk_remise_except=".((int) $this->fk_remise_except); + else $sql .= ", fk_remise_except=null"; $sql .= ", vat_src_code = '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."'"; $sql .= ", tva_tx = ".price2num($this->tva_tx); $sql .= ", localtax1_tx = ".price2num($this->localtax1_tx); @@ -3633,7 +3633,7 @@ class SupplierInvoiceLine extends CommonObjectLine if ($discount->fk_facture_line > 0) { if (empty($noerrorifdiscountalreadylinked)) { $this->error = $langs->trans("ErrorDiscountAlreadyUsed", $discount->id); - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } @@ -3641,20 +3641,20 @@ class SupplierInvoiceLine extends CommonObjectLine $result = $discount->link_to_invoice($this->rowid, 0); if ($result < 0) { $this->error = $discount->error; - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } } } else { $this->error = $langs->trans("ErrorADiscountThatHasBeenRemovedIsIncluded"); - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } } else { $this->error = $discount->error; - dol_syslog(get_class($this) . "::insert Error " . $this->error, LOG_ERR); + dol_syslog(get_class($this)."::insert Error ".$this->error, LOG_ERR); $this->db->rollback(); return -3; } diff --git a/htdocs/partnership/admin/setup.php b/htdocs/partnership/admin/setup.php index 4005be154a1..25567b137db 100644 --- a/htdocs/partnership/admin/setup.php +++ b/htdocs/partnership/admin/setup.php @@ -134,8 +134,8 @@ print ''; if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') { print ''.$langs->trans("PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL").''; print ''; - $dnbdays = '15'; - $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; + $dnbdays = '15'; + $backlinks = (!empty($conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL)) ? $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL : $dnbdays; print ''; print ''; print ''.$dnbdays.''; @@ -164,7 +164,7 @@ print ''; print ''.$langs->trans("PARTNERSHIP_BACKLINKS_TO_CHECK").''; print ''; -$backlinks = (empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) ? '' : $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK); +$backlinks = (empty($conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK) ? '' : $conf->global->PARTNERSHIP_BACKLINKS_TO_CHECK); print ''; print ''; print 'dolibarr.org|dolibarr.fr|dolibarr.es'; diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 7cf01c2957c..0588b9e5df2 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -37,9 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; */ class PartnershipUtils { - public $db; //!< To store db handler - public $error; //!< To return error code (or message) - public $errors=array(); //!< To return several error codes (or messages) + public $db; //!< To store db handler + public $error; //!< To return error code (or message) + public $errors = array(); //!< To return several error codes (or messages) /** @@ -71,19 +71,19 @@ class PartnershipUtils } $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL) ? 25 : $conf->global->PARTNERSHIP_MAX_EXPIRATION_CANCEL_PER_CALL); // Limit to 25 per call $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; if ($gracedelay < 1) { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; + $this->error = 'BadValueForDelayBeforeCancelCheckSetup'; return -1; } @@ -116,7 +116,7 @@ class PartnershipUtils $obj = $this->db->fetch_object($resql); if ($obj) { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + if (!empty($partnershipsprocessed[$obj->rowid])) continue; if ($somethingdoneonpartnership >= $MAXPERCALL) { dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doCancelStatusOfMemberPartnership to avoid to reach email quota.", LOG_WARNING); @@ -142,7 +142,7 @@ class PartnershipUtils else $this->errors = $object->errors; } } else { - $partnershipsprocessed[$object->id]=$object->ref; + $partnershipsprocessed[$object->id] = $object->ref; // Send an email to inform member $labeltemplate = '(SendingEmailOnPartnershipCanceled)'; @@ -152,21 +152,21 @@ class PartnershipUtils // Send deployment email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + $formmail = new FormMail($this->db); // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); + $outputlangs->loadLangs(array('main', 'member', 'partnership')); } - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); @@ -179,7 +179,7 @@ class PartnershipUtils $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); $result = $cmail->sendfile(); - if (! $result || $cmail->error) { + if (!$result || $cmail->error) { $erroremail .= ($erroremail ? ', ' : '').$cmail->error; $this->errors[] = $cmail->error; if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; @@ -193,18 +193,18 @@ class PartnershipUtils $this->error = $this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->db->commit(); $this->output = $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail; } else { $this->db->rollback(); $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' expired partnership members found'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail; + $this->output .= $numofexpiredmembers.' expired partnership members found'."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail; } - return ($error ? 1: 0); + return ($error ? 1 : 0); } @@ -222,19 +222,19 @@ class PartnershipUtils $managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR; $partnership = new Partnership($this->db); - $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call + $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call $langs->loadLangs(array("partnership", "member")); - $error = 0; - $erroremail = ''; - $this->output = ''; - $this->error = ''; + $error = 0; + $erroremail = ''; + $this->output = ''; + $this->error = ''; $partnershipsprocessed = array(); - $gracedelay=$conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; + $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL; if ($gracedelay < 1) { - $this->error='BadValueForDelayBeforeCancelCheckSetup'; + $this->error = 'BadValueForDelayBeforeCancelCheckSetup'; return -1; } @@ -269,16 +269,16 @@ class PartnershipUtils $resql = $this->db->query($sql); if ($resql) { - $numofexpiredmembers = $this->db->num_rows($resql); + $numofexpiredmembers = $this->db->num_rows($resql); $somethingdoneonpartnership = 0; - $ifetchpartner = 0; + $ifetchpartner = 0; $websitenotfound = ''; while ($ifetchpartner < $numofexpiredmembers) { $ifetchpartner++; $obj = $this->db->fetch_object($resql); if ($obj) { - if (! empty($partnershipsprocessed[$obj->rowid])) continue; + if (!empty($partnershipsprocessed[$obj->rowid])) continue; if ($somethingdoneonpartnership >= $MAXPERCALL) { dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING); @@ -318,21 +318,21 @@ class PartnershipUtils // Send deployment email include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $formmail=new FormMail($this->db); + $formmail = new FormMail($this->db); // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09'); - if (! empty($newlang)) { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); - $outputlangs->loadLangs(array('main','member','partnership')); + $outputlangs->loadLangs(array('main', 'member', 'partnership')); } - $arraydefaultmessage=$formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); + $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate); - $substitutionarray=getCommonSubstitutionArray($outputlangs, 0, null, $object); + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); @@ -343,7 +343,7 @@ class PartnershipUtils $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1); $result = $cmail->sendfile(); - if (! $result || $cmail->error) { + if (!$result || $cmail->error) { $erroremail .= ($erroremail ? ', ' : '').$cmail->error; $this->errors[] = $cmail->error; if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors; @@ -360,7 +360,7 @@ class PartnershipUtils $object->reason_decline_or_cancel = ''; } - $partnershipsprocessed[$object->id]=$object->ref; + $partnershipsprocessed[$object->id] = $object->ref; $object->last_check_backlink = $this->db->idate($now); @@ -372,22 +372,22 @@ class PartnershipUtils $this->error = $this->db->lasterror(); } - if (! $error) { + if (!$error) { $this->db->commit(); $this->output = $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; } else { $this->db->rollback(); $this->output = "Rollback after error\n"; - $this->output.= $numofexpiredmembers.' partnership checked'."\n"; - if ($erroremail) $this->output.='. Got errors when sending some email : '.$erroremail."\n"; - if ($emailnotfound) $this->output.='. Email not found for some partner : '.$emailnotfound."\n"; - if ($websitenotfound) $this->output.='. Website not found for some partner : '.$websitenotfound."\n"; + $this->output .= $numofexpiredmembers.' partnership checked'."\n"; + if ($erroremail) $this->output .= '. Got errors when sending some email : '.$erroremail."\n"; + if ($emailnotfound) $this->output .= '. Email not found for some partner : '.$emailnotfound."\n"; + if ($websitenotfound) $this->output .= '. Website not found for some partner : '.$websitenotfound."\n"; } - return ($error ? 1: 0); + return ($error ? 1 : 0); } /** diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index c8bb93ccb7d..79f51be6ca9 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -82,7 +82,7 @@ if ($managedfor != 'member' && $sortfield == 'd.datefin') $sortfield = ''; // Default sort order (if not yet defined by previous GETPOST) if (!$sortfield) { - reset($object->fields); // Reset is required to avoid key() to return null. + reset($object->fields); // Reset is required to avoid key() to return null. $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. } if (!$sortorder) { @@ -136,8 +136,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; $permissiontodelete = $user->rights->partnership->delete; // Security check @@ -305,13 +305,13 @@ foreach ($search as $key => $val) { } } else { if (preg_match('/(_dtstart|_dtend)$/', $key) && $search[$key] != '') { - $columnName=preg_replace('/(_dtstart|_dtend)$/', '', $key); + $columnName = preg_replace('/(_dtstart|_dtend)$/', '', $key); if (preg_match('/^(date|timestamp|datetime)/', $object->fields[$columnName]['type'])) { if (preg_match('/_dtstart$/', $key)) { - $sql .= " AND t." . $columnName . " >= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$columnName." >= '".$db->idate($search[$key])."'"; } if (preg_match('/_dtend$/', $key)) { - $sql .= " AND t." . $columnName . " <= '" . $db->idate($search[$key]) . "'"; + $sql .= " AND t.".$columnName." <= '".$db->idate($search[$key])."'"; } } } @@ -538,7 +538,7 @@ foreach ($object->fields as $key => $val) { print ''; if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:')=== 0)) { + } elseif ((strpos($val['type'], 'integer:') === 0) || (strpos($val['type'], 'sellist:') === 0)) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth125', 1); } elseif (!preg_match('/^(date|timestamp|datetime)/', $val['type'])) { print ''; diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 170853b9c2b..1b04a77083c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -315,11 +315,11 @@ if (empty($reshook)) { $object->type = $type; $object->status = GETPOST('statut'); - $object->status_buy = GETPOST('statut_buy'); + $object->status_buy = GETPOST('statut_buy'); $object->status_batch = GETPOST('status_batch'); $object->batch_mask = GETPOST('batch_mask'); - $object->barcode_type = GETPOST('fk_barcode_type'); + $object->barcode_type = GETPOST('fk_barcode_type'); $object->barcode = GETPOST('barcode'); // Set barcode_type_xxx from barcode_type id $stdobject = new GenericObject($db); @@ -1620,10 +1620,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $tooltip .= $langs->trans("GenericMaskCodes5"); print ''.$langs->trans("ManageLotMask").''; if ($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') { - $mask = ! empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; + $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; } if ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') { - $mask = ! empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; + $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; } $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; @@ -2011,7 +2011,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $formbarcode = new FormBarCode($db); } - $fk_barcode_type=''; + $fk_barcode_type = ''; if ($action == 'editbarcodetype') { print $formbarcode->formBarcodeType($_SERVER['PHP_SELF'].'?id='.$object->id, $object->barcode_type, 'fk_barcode_type'); $fk_barcode_type = $object->barcode_type; @@ -2057,7 +2057,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$langs->trans("ManageLotSerial").''; print $object->getLibStatut(0, 2); print ''; - if ((($object->status_batch == '1' &&$conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') + if ((($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') || ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS))) { print ''.$langs->trans("ManageLotMask").''; print $object->batch_mask; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 55ab129edee..876ced9892c 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -169,7 +169,7 @@ if (empty($reshook)) { // Modification entrepot if ($action == 'update' && !$cancel) { if ($object->fetch($id)) { - $object->label = GETPOST("libelle"); + $object->label = GETPOST("libelle"); $object->fk_parent = GETPOST("fk_parent"); $object->fk_project = GETPOST('projectid'); $object->description = GETPOST("desc"); @@ -179,8 +179,8 @@ if (empty($reshook)) { $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST("country_id"); - $object->phone = GETPOST("phone"); - $object->fax = GETPOST("fax"); + $object->phone = GETPOST("phone"); + $object->fax = GETPOST("fax"); // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost(null, $object); @@ -648,7 +648,7 @@ if ($action == 'create') { $sql .= " AND ps.fk_entrepot = ".((int) $object->id); if ($separatedPMP) { - $sql .= " AND pa.fk_product = p.rowid AND pa.entity = ". (int) $conf->entity; + $sql .= " AND pa.fk_product = p.rowid AND pa.entity = ".(int) $conf->entity; } $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 8b0c774cc6a..28cf3f821cf 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -28,7 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +} // Load translation files required by the page $langs->loadLangs(array("compta", "salaries", "bills", "hrm")); @@ -52,8 +54,12 @@ if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST( $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "s.datep,s.rowid"; -if (!$sortorder) $sortorder = "DESC,DESC"; +if (!$sortfield) { + $sortfield = "s.datep,s.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC,DESC"; +} // Initialize technical objects $object = new PaymentSalary($db); @@ -66,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (!$sortfield) $sortfield = "s.datep,s.rowid"; -if (!$sortorder) $sortorder = "DESC,DESC"; +if (!$sortfield) { + $sortfield = "s.datep,s.rowid"; +} +if (!$sortorder) { + $sortorder = "DESC,DESC"; +} $search_ref = GETPOST('search_ref', 'int'); $search_ref_salary = GETPOST('search_ref_salary', 'int'); @@ -89,7 +99,9 @@ if (!GETPOST('search_type_id', 'int')) { $filterarray = explode('-', $newfiltre); foreach ($filterarray as $val) { $part = explode(':', $val); - if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1]; + if ($part[0] == 's.fk_typepayment') { + $search_type_id = $part[1]; + } } } else { $search_type_id = GETPOST('search_type_id', 'int'); @@ -133,7 +145,9 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (empty($reshook)) { // Selection of new fields @@ -203,21 +217,47 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro $sql .= " ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.rowid = sal.fk_user"; $sql .= " AND s.entity IN (".getEntity('payment_salaries').")"; -if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; +if (empty($user->rights->salaries->readall)) { + $sql .= " AND s.fk_user IN (".$db->sanitize(join(',', $childids)).")"; +} // Search criteria -if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref); -if ($search_ref_salary) $sql .= " AND sal.rowid=".((int) $search_ref_salary); -if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); -if ($search_label) $sql .= natural_search(array('sal.label'), $search_label); -if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; -if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; -if ($search_dateep_start) $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'"; -if ($search_dateep_end) $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'"; -if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1); -if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account); -if ($search_fk_bank) $sql .= " AND s.fk_bank=".((int) $search_fk_bank); -if ($search_chq_number) $sql .= natural_search(array('s.num_payment'), $search_chq_number); +if ($search_ref) { + $sql .= " AND s.rowid=".((int) $search_ref); +} +if ($search_ref_salary) { + $sql .= " AND sal.rowid=".((int) $search_ref_salary); +} +if ($search_user) { + $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user); +} +if ($search_label) { + $sql .= natural_search(array('sal.label'), $search_label); +} +if ($search_date_start) { + $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'"; +} +if ($search_date_end) { + $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'"; +} +if ($search_dateep_start) { + $sql .= " AND sal.dateep >= '".$db->idate($search_dateep_start)."'"; +} +if ($search_dateep_end) { + $sql .= " AND sal.dateep <= '".$db->idate($search_dateep_end)."'"; +} +if ($search_amount) { + $sql .= natural_search("s.amount", $search_amount, 1); +} +if ($search_account > 0) { + $sql .= " AND b.fk_account=".((int) $search_account); +} +if ($search_fk_bank) { + $sql .= " AND s.fk_bank=".((int) $search_fk_bank); +} +if ($search_chq_number) { + $sql .= natural_search(array('s.num_payment'), $search_chq_number); +} if ($search_type_id > 0) { $sql .= " AND s.fk_typepayment=".((int) $search_type_id); @@ -238,7 +278,9 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); if (!$resql) { @@ -257,21 +299,51 @@ llxHeader('', $title, $help_url); $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); -if ($search_ref_salary) $param .= '&search_ref_salary='.urlencode($search_ref_salary); -if ($search_user) $param .= '&search_user='.urlencode($search_user); -if ($search_label) $param .= '&search_label='.urlencode($search_label); -if ($search_fk_bank) $param .= '&search_fk_bank='.urlencode($search_fk_bank); -if ($search_chq_number) $param .= '&search_chq_number='.urlencode($search_chq_number); -if ($search_account) $param .= '&search_account='.urlencode($search_account); -if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); -if ($search_dateep_start) $param .= '&search_dateep_startday='.urlencode(GETPOST('search_dateep_startday', 'int')).'&search_dateep_startmonth='.urlencode(GETPOST('search_dateep_startmonth', 'int')).'&search_dateep_startyear='.urlencode(GETPOST('search_dateep_startyear', 'int')); -if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); -if ($search_dateep_end) $param .= '&search_dateep_endday='.urlencode(GETPOST('search_dateep_endday', 'int')).'&search_dateep_endmonth='.urlencode(GETPOST('search_dateep_endmonth', 'int')).'&search_dateep_endyear='.urlencode(GETPOST('search_dateep_endyear', 'int')); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($search_type_id) { + $param .= '&search_type_id='.urlencode($search_type_id); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($search_ref) { + $param .= '&search_ref='.urlencode($search_ref); +} +if ($search_ref_salary) { + $param .= '&search_ref_salary='.urlencode($search_ref_salary); +} +if ($search_user) { + $param .= '&search_user='.urlencode($search_user); +} +if ($search_label) { + $param .= '&search_label='.urlencode($search_label); +} +if ($search_fk_bank) { + $param .= '&search_fk_bank='.urlencode($search_fk_bank); +} +if ($search_chq_number) { + $param .= '&search_chq_number='.urlencode($search_chq_number); +} +if ($search_account) { + $param .= '&search_account='.urlencode($search_account); +} +if ($search_date_start) { + $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int')); +} +if ($search_dateep_start) { + $param .= '&search_dateep_startday='.urlencode(GETPOST('search_dateep_startday', 'int')).'&search_dateep_startmonth='.urlencode(GETPOST('search_dateep_startmonth', 'int')).'&search_dateep_startyear='.urlencode(GETPOST('search_dateep_startyear', 'int')); +} +if ($search_date_end) { + $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int')); +} +if ($search_dateep_end) { + $param .= '&search_dateep_endday='.urlencode(GETPOST('search_dateep_endday', 'int')).'&search_dateep_endmonth='.urlencode(GETPOST('search_dateep_endmonth', 'int')).'&search_dateep_endyear='.urlencode(GETPOST('search_dateep_endyear', 'int')); +} // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -281,11 +353,15 @@ $arrayofmassactions = array( //'buildsepa'=>$langs->trans("BuildSepa"), // TODO ); //if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -294,7 +370,9 @@ print ''; print ''; $url = DOL_URL_ROOT.'/salaries/card.php?action=create'; -if (!empty($socid)) $url .= '&socid='.$socid; +if (!empty($socid)) { + $url .= '&socid='.$socid; +} $newcardbutton = dolGetButtonTitle($langs->trans('NewSalaryPayment'), '', 'fa fa-plus-circle', $url, '', $user->rights->salaries->write); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1); @@ -413,7 +491,10 @@ print ''."\n"; $needToFetchEachLine = 0; if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; + } + // There is at least one compute field that use $object } } @@ -424,7 +505,10 @@ $total = 0; $totalarray = array(); while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; + } + // Should not happen // Store properties in $object $object->setVarsFromFetchObj($obj); @@ -449,22 +533,32 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Ref print "".$paymentsalstatic->getNomUrl(1)."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print "".$salstatic->getNomUrl(1)."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Label payment print "".dol_trunc($obj->label, 40)."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Date end period print ''.dol_print_date($db->jdate($obj->dateep), 'day')."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Date payment print ''.dol_print_date($db->jdate($obj->datep), 'day')."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Date value /*print ''.dol_print_date($db->jdate($obj->datev), 'day')."\n"; @@ -472,15 +566,21 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Employee print "".$userstatic->getNomUrl(1)."\n"; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Type print ''.$langs->trans("PaymentTypeShort".$obj->payment_code).''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Chq number print ''.$obj->num_payment.''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } // Account if (!empty($conf->banque->enabled)) { @@ -489,7 +589,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { $accountlinestatic->id = $obj->fk_bank; print $accountlinestatic->getNomUrl(1); print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''; if ($obj->fk_bank > 0) { @@ -514,15 +616,23 @@ while ($i < ($limit ? min($num, $limit) : $num)) { if ($accountstatic->id > 0) { print $accountstatic->getNomUrl(1); } - } else print ' '; + } else { + print ' '; + } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } } // Amount print ''.price($obj->amount).''; - if (!$i) $totalarray['nbfield']++; - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + if (!$i) { + $totalarray['nbfield']++; + } + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 'totalttcfield'; + } $totalarray['val']['totalttcfield'] += $obj->amount; // Extra fields @@ -535,11 +645,15 @@ while ($i < ($limit ? min($num, $limit) : $num)) { print ''; if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; @@ -553,7 +667,10 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { + $colspan++; + } + } print ''.$langs->trans("NoRecordFound").''; } diff --git a/htdocs/societe/partnership.php b/htdocs/societe/partnership.php index 912307a5675..9cb065d2c3b 100644 --- a/htdocs/societe/partnership.php +++ b/htdocs/societe/partnership.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; require_once DOL_DOCUMENT_ROOT.'/partnership/lib/partnership.lib.php'; // Load translation files required by the page -$langs->loadLangs(array("companies","partnership", "other")); +$langs->loadLangs(array("companies", "partnership", "other")); // Get parameters $id = GETPOST('id', 'int'); @@ -82,19 +82,27 @@ foreach ($object->fields as $key => $val) { // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. -$permissiontoread = $user->rights->partnership->read; -$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissiontoread = $user->rights->partnership->read; +$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php $permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php -$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php -$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; +$usercanclose = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1]; -if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'thirdparty') accessforbidden(); -if (empty($conf->partnership->enabled)) accessforbidden(); -if (empty($permissiontoread)) accessforbidden(); -if ($action == 'edit' && empty($permissiontoadd)) accessforbidden(); +if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && $conf->global->PARTNERSHIP_IS_MANAGED_FOR != 'thirdparty') { + accessforbidden(); +} +if (empty($conf->partnership->enabled)) { + accessforbidden(); +} +if (empty($permissiontoread)) { + accessforbidden(); +} +if ($action == 'edit' && empty($permissiontoadd)) { + accessforbidden(); +} if (($action == 'update' || $action == 'edit') && $object->status != $object::STATUS_DRAFT && !empty($user->socid)) { accessforbidden(); @@ -128,7 +136,9 @@ if (empty($reshook)) { } $object->fields['fk_soc']['visible'] = 0; -if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) $object->fields['reason_decline_or_cancel']['visible'] = 1; +if ($object->id > 0 && $object->status == $object::STATUS_REFUSED && empty($action)) { + $object->fields['reason_decline_or_cancel']['visible'] = 1; +} $object->fields['note_public']['visible'] = 1; From afa1e117c5a371003b32271b4d7286f100e7e4e5 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 14 Jun 2021 13:37:39 +0000 Subject: [PATCH 2/2] Fixing style errors. --- htdocs/salaries/payments.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php index 28cf3f821cf..bfc795ebcef 100644 --- a/htdocs/salaries/payments.php +++ b/htdocs/salaries/payments.php @@ -550,9 +550,9 @@ while ($i < ($limit ? min($num, $limit) : $num)) { // Date end period print ''.dol_print_date($db->jdate($obj->dateep), 'day')."\n"; - if (!$i) { - $totalarray['nbfield']++; - } + if (!$i) { + $totalarray['nbfield']++; + } // Date payment print ''.dol_print_date($db->jdate($obj->datep), 'day')."\n"; @@ -668,7 +668,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; if ($num == 0) { $colspan = 1; foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) { - $colspan++; + $colspan++; } } print ''.$langs->trans("NoRecordFound").'';