diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 7d7b8a8510c..c91caea435c 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -36,11 +36,11 @@ $rowid=GETPOST('rowid','int'); $entity=GETPOST('entity','int'); $action=GETPOST('action','alpha'); $update=GETPOST('update','alpha'); -$delete=GETPOST('delete'); // Do not use alpha here +$delete=GETPOST('delete','none'); // Do not use alpha here $debug=GETPOST('debug','int'); $consts=GETPOST('const','array'); $constname=GETPOST('constname','alpha'); -$constvalue=GETPOST('constvalue'); +$constvalue=GETPOST('constvalue','none'); // We shoul dbe able to send everything here $constnote=GETPOST('constnote','alpha'); @@ -247,7 +247,7 @@ if ($result) while ($i < $num) { $obj = $db->fetch_object($result); - + print "\n"; diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 790445f7032..03c31180af3 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -38,7 +38,7 @@ if (!$user->admin) accessforbidden(); $id=GETPOST('rowid','int'); $action=GETPOST('action','alpha'); -$mode = GETPOST('mode')?GETPOST('mode'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' +$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'createform'; // 'createform', 'filters', 'sortorder', 'focus' $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index cd236d85122..191db98a402 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -89,7 +89,7 @@ if ($action == 'update') if ($result > 0) { $menu->titre=GETPOST('titre', 'alpha'); - $menu->leftmenu=GETPOST('leftmenu', 'alpha'); + $menu->leftmenu=GETPOST('leftmenu', 'aZ09'); $menu->url=GETPOST('url','alpha'); $menu->langs=GETPOST('langs','alpha'); $menu->position=GETPOST('position','int'); diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index c36db521f70..347ac3c0145 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -157,7 +157,7 @@ $i=0; foreach($_SESSION as $key => $val) { if ($i > 0) print ', '; - print $key.' => '.$val; + print $key.' => '.dol_escape_htmltag($val); $i++; } print ''."\n"; diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 1999aab006c..4faf0cebe8a 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -39,7 +39,7 @@ $transkey=GETPOST('transkey','alpha'); $transvalue=GETPOST('transvalue','alpha'); -$mode = GETPOST('mode')?GETPOST('mode'):'overwrite'; +$mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'overwrite'; $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index e846b47cb4e..1d22d21d574 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4376,7 +4376,7 @@ else if ($id > 0 || ! empty($ref)) if ($objectidnext) { print '
' . $langs->trans('DoPayment') . '
'; } else { - //if ($resteapayer == 0) { + //if ($resteapayer == 0) { // Sometimes we can receive more, so we accept to enter more and will offer a button to convert into discount (but it is not a credit note, just a prepayment done) // print '
' . $langs->trans('DoPayment') . '
'; //} else { print '
' . $langs->trans('DoPayment') . '
'; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 6dbc622032d..fe8ca1f2352 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -613,6 +613,7 @@ class CMailFile if (! $res) { + $langs->load("errors"); $this->error="Failed to send mail with php mail"; $linuxlike=1; if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index ac5d3869a3d..af9d694e5e6 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -173,7 +173,7 @@ abstract class CommonInvoice extends CommonObject } /** - * Return amount (with tax) of all credit notes and deposits invoices used by invoice + * Return amount (with tax) of all credit notes invoices + excess received used by invoice * * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 547bd8ad4e4..792ed58ab2b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -190,7 +190,12 @@ class Form $morealt=' style="width: '.$cols.'"'; $cols=''; } - $ret.=''; + + $valuetoshow = ($editvalue?$editvalue:$value); + + $ret.=''; } else if ($typeofdata == 'day' || $typeofdata == 'datepicker') { @@ -288,7 +293,7 @@ class Form $out=''; // Check parameters - if ($inputType == 'textarea') $value = dol_nl2br($value); + if (preg_match('/^text/',$inputType)) $value = dol_nl2br($value); else if (preg_match('/^numeric/',$inputType)) $value = price($value); else if ($inputType == 'day' || $inputType == 'datepicker') $value = dol_print_date($value, 'day'); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 2d66661c839..bd22470d952 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -196,7 +196,7 @@ class FormActions if (! empty($conf->agenda->enabled)) { - $buttontoaddnewevent = ''; + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e6e3a240878..f5cef250060 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -276,7 +276,7 @@ function GETPOSTISSET($paramname) * @param string $noreplace Force disable of replacement of __xxx__ strings. * @return string|string[] Value found (string or array), or '' if check fails */ -function GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0) +function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0) { global $mysoc,$user,$conf; @@ -4090,7 +4090,7 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) * 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK) * @param int $alreadysqlnb Put 1 if you know that content is already universal format number - * @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. + * @return string Amount with universal numeric format (Example: '99.99999') or unchanged text if conversion fails. If amount is null or '', it returns ''. * * @see price Opposite function of price2num */ @@ -5014,7 +5014,7 @@ function picto_required() * @param string $pagecodeto Encoding of input/output string * @return string String cleaned * - * @see dol_escape_htmltag strip_tags + * @see dol_escape_htmltag strip_tags dol_string_onlythesehtmltags dol_string_neverthesehtmltags */ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF-8') { @@ -5041,6 +5041,51 @@ function dol_string_nohtmltag($stringtoclean,$removelinefeed=1,$pagecodeto='UTF- return trim($temp); } +/** + * Clean a string to keep only desirable HTML tags. + * + * @param string $stringtoclean String to clean + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_neverthesehtmltags + */ +function dol_string_onlythesehtmltags($stringtoclean) +{ + $allowed_tags = array( + "html", "head", "meta", "body", "b", "br", "div", "em", "font", "img", "hr", "i", "li", "link", + "ol", "p", "s", "section", "span", "strong", "title", + "table", "tr", "th", "td", "u", "ul" + ); + + $allowed_tags_string = join("><", $allowed_tags); + $allowed_tags_string = preg_replace('/^>/','',$allowed_tags_string); + $allowed_tags_string = preg_replace('/<$/','',$allowed_tags_string); + + $temp = strip_tags($stringtoclean, $allowed_tags_string); + + return $temp; +} + +/** + * Clean a string from some undesirable HTML tags. + * + * @param string $stringtoclean String to clean + * @param array $disallowed_tags Array of tags not allowed + * @return string String cleaned + * + * @see dol_escape_htmltag strip_tags dol_string_nohtmltag dol_string_onlythesehtmltags + */ +function dol_string_neverthesehtmltags($stringtoclean, $disallowed_tags=array('textarea')) +{ + $temp = $stringtoclean; + foreach($disallowed_tags as $tagtoremove) + { + $temp = preg_replace('/<\/?'.$tagtoremove.'>/', '', $temp); + $temp = preg_replace('/<\/?'.$tagtoremove.'\s+[^>]*>/', '', $temp); + } + return $temp; +} + /** * Return first line of text. Cut will depends if content is HTML or not. @@ -6103,7 +6148,7 @@ function dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensiti else { ($case_sensitive) ? natsort($temp) : natcasesort($temp); - if($order!='asc') $temp=array_reverse($temp,TRUE); + if($order!='asc') $temp=array_reverse($temp,true); } $sorted = array(); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 8050abf811b..0e781044a18 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -780,7 +780,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - // Loop on each deposits and credit notes included + // Loop on each discount available (deposits and credit notes and excess of payment included) $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; @@ -797,9 +797,10 @@ class pdf_crabe extends ModelePDFFactures $y+=3; $obj = $this->db->fetch_object($resql); - if ($obj->type == 2) $text=$outputlangs->trans("CreditNote"); - elseif ($obj->type == 3) $text=$outputlangs->trans("Deposit"); - else $text=$outputlangs->trans("UnknownType"); + if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote"); + elseif ($obj->type == 3) $text=$outputlangs->transnoentities("Deposit"); + elseif ($obj->type == 0) $text=$outputlangs->transnoentities("ExcessReceived"); + else $text=$outputlangs->transnoentities("UnknownType"); $invoice->fetch($obj->fk_facture_source); @@ -1289,7 +1290,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); @@ -1307,9 +1308,10 @@ class pdf_crabe extends ModelePDFFactures // Credit note if ($creditnoteamount) { + $labeltouse = ($outputlangs->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangs->transnoentities("CreditNotesOrExcessReceived") : $outputlangs->transnoentities("CreditNotes"); $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $labeltouse, 0, 'L', 0); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount, 0, $outputlangs), 0, 'R', 0); } @@ -1688,7 +1690,7 @@ class pdf_crabe extends ModelePDFFactures { $top_shift = $pdf->getY() - $current_y; } - + if ($showaddress) { // Sender properties diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index f22b25c88a5..c43158be500 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -71,7 +71,7 @@ elseif ($module == 'shipping') { $permission=$user->rights->expedition->cr elseif ($module == 'product') { $permission=$user->rights->produit->creer;} //else dol_print_error('','Bad value '.$module.' for param module'); -if (! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. +if (! empty($conf->fckeditor->enabled) && ! empty($conf->global->FCKEDITOR_ENABLE_SOCIETE)) $typeofdata='ckeditor:dolibarr_notes:100%:200::1:12:95%'; // Rem: This var is for all notes, not only thirdparties note. else $typeofdata='textarea:12:95%'; print ''."\n"; diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php index 053d293db83..5b633552380 100644 --- a/htdocs/expensereport/list.php +++ b/htdocs/expensereport/list.php @@ -310,8 +310,7 @@ if ($search_status != '' && $search_status >= 0) $sql.=" AND d.fk_statut IN (".$ if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) && (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || empty($user->rights->expensereport->writeall_advance))) { - $childids = $user->getAllChildIds(); - $childids[]=$user->id; + $childids = $user->getAllChildIds(1); $sql.= " AND d.fk_user_author IN (".join(',',$childids).")\n"; } // Add where from extra fields @@ -442,12 +441,15 @@ if ($resql) print ''.$langs->trans("Modify").''; } - $canedit=(($user->id == $user_id && $user->rights->expensereport->creer) || ($user->id != $user_id)); + $childids = $user->getAllChildIds(1); + + $canedit=((in_array($user_id, $childids) && $user->rights->expensereport->creer) + || ($conf->global->MAIN_USE_ADVANCED_PERMS && $user->rights->expensereport->writeall_advance)); // Boutons d'actions if ($canedit) { - print ''.$langs->trans("AddTrip").''; + print ''.$langs->trans("AddTrip").''; } print ''; diff --git a/htdocs/hrm/index.php b/htdocs/hrm/index.php index 2f360dce5c5..58a681693e1 100644 --- a/htdocs/hrm/index.php +++ b/htdocs/hrm/index.php @@ -36,38 +36,35 @@ if ($conf->deplacement->enabled) require_once DOL_DOCUMENT_ROOT.'/compta/deplace if ($conf->expensereport->enabled) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; -$langs->load('users'); -$langs->load('holidays'); -$langs->load('trips'); +$langs->loadLangs(array('users','holidays','trips')); -$socid=GETPOST("socid"); +$socid=GETPOST("socid","int"); // Protection if external user if ($user->societe_id > 0) accessforbidden(); +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; + +$holiday = new Holiday($db); +$holidaystatic=new Holiday($db); + /* * Actions */ -// None - +// Update sold +if (! empty($conf->holiday->enabled) && ! empty($setupcompanynotcomplete)) +{ + $result = $holiday->updateBalance(); +} /* * View */ -$holiday = new Holiday($db); -$holidaystatic=new Holiday($db); - -// Update sold -if (! empty($conf->holiday->enabled)) -{ - $result = $holiday->updateBalance(); -} - $childids = $user->getAllChildIds(); $childids[]=$user->id; @@ -76,13 +73,13 @@ llxHeader('', $langs->trans('HRMArea')); print load_fiche_titre($langs->trans("HRMArea"),'', 'title_hrm.png'); -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto=img_warning($langs->trans("WarningMandatorySetupNotComplete")); print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").'
'; + llxFooter(); exit; } diff --git a/htdocs/index.php b/htdocs/index.php index b01e37927c4..4d4ebb03cb9 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -526,7 +526,7 @@ foreach($valid_dashboardlines as $board) } } //var_dump($totallate, $totaltodo); -if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $totallate = round($totallate / $totaltodo * 100, 2); +if(!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE) && !empty($totaltodo)) $totallate = round($totallate / $totaltodo * 100, 2); //var_dump($totallate); $boxwork=''; $boxwork.='
'; diff --git a/htdocs/install/step1.php b/htdocs/install/step1.php index 838ef34afa3..a8eed4e26e4 100644 --- a/htdocs/install/step1.php +++ b/htdocs/install/step1.php @@ -47,16 +47,16 @@ $main_data_dir = GETPOST('main_data_dir') ? GETPOST('main_data_dir') : $main_dir // Dolibarr root URL $main_url = GETPOST('main_url'); // Database login informations -$userroot=GETPOST('db_user_root'); -$passroot=GETPOST('db_pass_root'); +$userroot=GETPOST('db_user_root','alpha'); +$passroot=GETPOST('db_pass_root','none'); // Database server -$db_type=GETPOST('db_type','alpha'); +$db_type=GETPOST('db_type','aZ09'); $db_host=GETPOST('db_host','alpha'); -$db_name=GETPOST('db_name','alpha'); +$db_name=GETPOST('db_name','aZ09'); $db_user=GETPOST('db_user','alpha'); -$db_pass=GETPOST('db_pass'); +$db_pass=GETPOST('db_pass','none'); $db_port=GETPOST('db_port','int'); -$db_prefix=GETPOST('db_prefix','alpha'); +$db_prefix=GETPOST('db_prefix','aZ09'); $db_create_database = GETPOST('db_create_database','none'); $db_create_user = GETPOST('db_create_user','none'); // Force https diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 3e5aaca5198..1bcebb8c890 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -279,6 +279,7 @@ RelativeDiscount=Relative discount GlobalDiscount=Global discount CreditNote=Credit note CreditNotes=Credit notes +CreditNotesOrExcessReceived=Credit notes or excess received Deposit=Down payment Deposits=Down payments DiscountFromCreditNote=Discount from credit note %s diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index e476c951123..e60572a4045 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -76,7 +76,7 @@ MenuNewSocialContribution=New social/fiscal tax NewSocialContribution=New social/fiscal tax AddSocialContribution=Add social/fiscal tax ContributionsToPay=Social/fiscal taxes to pay -AccountancyTreasuryArea=Accountancy/Treasury area +AccountancyTreasuryArea=Billing and payment area NewPayment=New payment Payments=Payments PaymentCustomerInvoice=Customer invoice payment diff --git a/htdocs/langs/fr_FR/bills.lang b/htdocs/langs/fr_FR/bills.lang index 9f2f21fbe77..1f5c33c2ef9 100644 --- a/htdocs/langs/fr_FR/bills.lang +++ b/htdocs/langs/fr_FR/bills.lang @@ -282,6 +282,7 @@ RelativeDiscount=Remise relative GlobalDiscount=Ligne de déduction CreditNote=Avoir CreditNotes=Avoirs +CreditNotesOrExcessReceived=Avoirs ou trop perçus Deposit=Acompte Deposits=Acomptes DiscountFromCreditNote=Remise issue de l'avoir %s diff --git a/htdocs/loan/index.php b/htdocs/loan/index.php index d1436287db3..afaefc4575c 100644 --- a/htdocs/loan/index.php +++ b/htdocs/loan/index.php @@ -71,7 +71,7 @@ $loan_static = new Loan($db); llxHeader(); -$sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend,"; +$sql = "SELECT l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend,"; $sql.= " SUM(pl.amount_capital) as alreadypayed"; $sql.= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql.= " ON l.rowid = pl.fk_loan"; @@ -83,7 +83,7 @@ if ($filtre) { $filtre=str_replace(":","=",$filtre); $sql .= " AND ".$filtre; } -$sql.= " GROUP BY l.rowid, l.label, l.capital, l.datestart, l.dateend"; +$sql.= " GROUP BY l.rowid, l.label, l.capital, l.paid, l.datestart, l.dateend"; $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = ''; diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index f71601e7bc0..295bf530f91 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -242,6 +242,8 @@ if ($resql) if ($fourn_id) $param.="&fourn_id=".$fourn_id; if ($snom) $param.="&snom=".$snom; if ($sref) $param.="&sref=".$sref; + if ($toolowstock) $param.="&toolowstock=".$toolowstock; + if ($search_categ) $param.="&search_categ=".$search_categ; $formProduct = new FormProduct($db); $formProduct->loadWarehouses(); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index dc3d9a9b7d6..3b793d3acd7 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -49,11 +49,13 @@ $hookmanager->initHooks(array('productstatsorder')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; @@ -112,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -142,25 +144,22 @@ if ($id > 0 || ! empty($ref)) $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= " ORDER BY $sortfield $sortorder "; - + $sql.= $db->order($sortfield, $sortorder); + //Calcul total qty and amount for global if full scan list $total_ht=0; $total_qty=0; - $totalrecords=0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql.= $db->plimit($conf->liste_limit +1, $offset); - + + $sql .= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { @@ -172,7 +171,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month='.$search_month; if (! empty($search_year)) $option .= '&search_year='.$search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '
' . "\n"; if (! empty($sortfield)) print ''; @@ -183,7 +183,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,''); + print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; @@ -211,20 +211,22 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + + $orderstatic->id=$objp->commandeid; + $orderstatic->ref=$objp->ref; + $orderstatic->ref_client=$objp->ref_client; + $societestatic->fetch($objp->socid); + print ''; print ''; - $orderstatic->id=$objp->commandeid; - $orderstatic->ref=$objp->ref; - $orderstatic->ref_client=$objp->ref_client; print $orderstatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print ''.$societestatic->getNomUrl(1).''; print "".$objp->code_client."\n"; print ''; @@ -234,15 +236,11 @@ if ($id > 0 || ! empty($ref)) print ''.$orderstatic->LibStatut($objp->statut,$objp->facture,5).''; print "\n"; $i++; - - if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print ''.$total_qty.''; print ''.price($total_ht).''; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 4526af86f96..7c80062da81 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -119,7 +119,7 @@ if ($id > 0 || ! empty($ref)) { print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -153,24 +153,21 @@ if ($id > 0 || ! empty($ref)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND c.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; - + $sql.= $db->order($sortfield, $sortorder); + // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } - } - } - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { @@ -182,7 +179,8 @@ if ($id > 0 || ! empty($ref)) { $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -193,7 +191,7 @@ if ($id > 0 || ! empty($ref)) { $option .= '&page=' . $page; } - print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; @@ -219,20 +217,24 @@ if ($id > 0 || ! empty($ref)) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; - if ($num > 0) { - $var = True; - while ( $i < $num && $i < $conf->liste_limit ) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $supplierorderstatic->id = $objp->commandeid; $supplierorderstatic->ref = $objp->ref; $supplierorderstatic->statut = $objp->statut; + $societestatic->fetch($objp->socid); + + print ''; + print ''; print $supplierorderstatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print '' . $societestatic->getNomUrl(1) . ''; print "" . $objp->code_client . "\n"; print ''; @@ -241,16 +243,12 @@ if ($id > 0 || ! empty($ref)) { print '' . price($objp->total_ht) . "\n"; print '' . $supplierorderstatic->getLibStatut(4) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index ef3723e2e55..fc88010553b 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -46,11 +46,13 @@ $hookmanager->initHooks(array('productstatscontract')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; @@ -102,7 +104,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product,$socid); print "
"; @@ -133,7 +135,20 @@ if ($id > 0 || ! empty($ref)) if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + + //Calcul total qty and amount for global if full scan list + $total_ht=0; + $total_qty=0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -145,7 +160,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -156,7 +172,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); $i = 0; print '
'; @@ -177,8 +193,7 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 794d939bc6e..6c039b816e2 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -50,15 +50,18 @@ $hookmanager->initHooks(array('productstatsinvoice')); $showmessage=GETPOST('showmessage'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; + $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -129,7 +132,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - $nboflines = show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -164,25 +167,19 @@ if ($id > 0 || ! empty($ref)) if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= $db->order($sortfield, $sortorder); - //Calcul total qty and amount for global if full scan list + // Calcul total qty and amount for global if full scan list $total_ht=0; $total_qty=0; - $totalrecords=0; + + // Count total nb of records + $totalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - if ($result) - { - $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) - { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($conf->liste_limit + 1, $offset); + $sql.= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -194,7 +191,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($search_month)) $option .= '&search_month='.$search_month; if (! empty($search_year)) - $option .= '&search_year='.$search_year; + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); print '' . "\n"; if (! empty($sortfield)) @@ -206,7 +204,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,''); + print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"],"&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; @@ -234,11 +232,13 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < min($num,$conf->liste_limit)) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $invoicestatic->id=$objp->facid; $invoicestatic->ref=$objp->facnumber; $societestatic->fetch($objp->socid); @@ -257,15 +257,11 @@ if ($id > 0 || ! empty($ref)) print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).''; print "\n"; $i++; - - if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print ''.$total_qty.''; print ''.price($total_ht).''; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 2e6b8d19677..a08486975ee 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -51,11 +51,13 @@ $hookmanager->initHooks(array('productstatssupplyinvoice')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder = "DESC"; @@ -114,7 +116,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -149,20 +151,17 @@ if ($id > 0 || ! empty($ref)) // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql .= $db->plimit($conf->liste_limit + 1, $offset); - + + $sql.= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { @@ -174,7 +173,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -185,7 +185,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; @@ -213,19 +213,21 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $supplierinvoicestatic->id = $objp->facid; $supplierinvoicestatic->ref = $objp->facnumber; + $societestatic->fetch($objp->socid); + + print ''; + print ''; print $supplierinvoicestatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print '' . $societestatic->getNomUrl(1) . ''; print "" . $objp->code_client . "\n"; print ''; @@ -234,16 +236,12 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->total_ht) . "\n"; print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 3173a04ee55..34c64964c23 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND p.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; + $sql.= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->amount; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -178,7 +175,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; @@ -216,20 +214,22 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->amount; + $total_qty+=$objp->qty; + $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; $propalstatic->ref_client=$objp->ref_client; - print $propalstatic->getNomUrl(1); - print "\n"; $societestatic->fetch($objp->socid); + + print ''; + print ''; + print $propalstatic->getNomUrl(1); + print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; print dol_print_date($db->jdate($objp->datep), 'dayhour') . ""; @@ -237,17 +237,13 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->amount) . '' . "\n"; print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 07e8015d846..a50c8bab832 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND p.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; + $sql.= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->amount; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -178,6 +175,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); print '' . "\n"; if (! empty($sortfield)) @@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; @@ -216,19 +214,21 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->amount; + $total_qty+=$objp->qty; + $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; - print $propalstatic->getNomUrl(1); - print "\n"; $societestatic->fetch($objp->socid); + + print ''; + print ''; + print $propalstatic->getNomUrl(1); + print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . ""; @@ -236,17 +236,13 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->amount) . '' . "\n"; print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8cbb45eae37..edfbef084df 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1715,7 +1715,7 @@ class Project extends CommonObject // For external user, no check is done on company permission because readability is managed by public status of project and assignement. //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql.= " WHERE p.fk_statut = 1"; - $sql.= " AND p.entity IN (".getEntity('project', 0).')'; + $sql.= " AND p.entity IN (".getEntity('project').')'; if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // No need to check company, as filtering of projects must be done by getProjectsAuthorizedForUser //if ($socid || ! $user->rights->societe->client->voir) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")"; @@ -1791,7 +1791,7 @@ class Project extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE"; - $sql.= " p.entity IN (".getEntity('projet').")"; + $sql.= " p.entity IN (".getEntity('project').")"; if (! $user->rights->projet->all->lire) { $projectsListId = $this->getProjectsAuthorizedForUser($user,0,1);