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

This commit is contained in:
Laurent Destailleur 2020-04-05 04:01:38 +02:00
commit 5516d747af
46 changed files with 4623 additions and 3091 deletions

File diff suppressed because it is too large Load Diff

View File

@ -290,6 +290,7 @@ if ($modecompta == 'CREANCES-DETTES')
// Show Array
$i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
// Extra parameters management
foreach ($headerparams as $key => $value)
{

View File

@ -195,6 +195,7 @@ $name = array();
// Show array
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
// Extra parameters management
foreach ($headerparams as $key => $value)
{

View File

@ -352,6 +352,7 @@ if ($modecompta != 'CREANCES-DETTES') {
// Show array
$i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
// Extra parameters management
foreach ($headerparams as $key => $value)
{

View File

@ -0,0 +1,424 @@
<?php
/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/stats/supplier_ca.php
* \brief Page reporting purchase turnover
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
// Load translation files required by the page
$langs->loadLangs(array('compta', 'bills'));
$date_startday = GETPOST('date_startday', 'int');
$date_startmonth = GETPOST('date_startmonth', 'int');
$date_startyear = GETPOST('date_startyear', 'int');
$date_endday = GETPOST('date_endday', 'int');
$date_endmonth = GETPOST('date_endmonth', 'int');
$date_endyear = GETPOST('date_endyear', 'int');
$nbofyear = 4;
// Date range
$year = GETPOST('year', 'int');
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now());
$year_start = $year_current - ($nbofyear - 1);
} else {
$year_current = $year;
$month_current = strftime("%m", dol_now());
$year_start = $year - ($nbofyear - 1);
}
$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
// We define date_start and date_end
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q = GETPOST("q") ?GETPOST("q") : 0;
if ($q == 0)
{
// We define date_start and date_end
$year_end = $year_start + ($nbofyear - 1);
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (!GETPOST('month'))
{
if (!GETPOST("year") && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end = $month_start - 1;
if ($month_end < 1) $month_end = 12;
}
else $month_end = $month_start;
$date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
}
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
$userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int');
$tmps = dol_getdate($date_start);
$year_start = $tmps['year'];
$tmpe = dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1;
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (!empty($conf->accounting->enabled)) $modecompta = 'BOOKKEEPING';
if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta", 'alpha');
// Security check
if ($user->socid > 0) $socid = $user->socid;
if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
/*
* View
*/
llxHeader();
$form = new Form($db);
// Affiche en-tete du rapport
if ($modecompta == "CREANCES-DETTES")
{
$name = $langs->trans("PurchaseTurnover");
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPING">', '</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesPurchaseTurnoverDue");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta == "RECETTES-DEPENSES")
{
$name = $langs->trans("PurchaseTurnoverCollected");
$calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
//$calcmode.='<br>('.$langs->trans("SeeReportInBookkeepingMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=BOOKKEEPINGCOLLECTED">','</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesPurchaseTurnoverIn");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta == "BOOKKEEPING")
{
$name = $langs->trans("PurchaseTurnover");
$calcmode = $langs->trans("CalcModeBookkeeping");
$calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">', '</a>').')';
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
$periodlink = ($year_start ? "<a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear - 2)."&modecompta=".$modecompta."'>".img_previous()."</a> <a href='".$_SERVER["PHP_SELF"]."?year=".($year_start + $nbofyear)."&modecompta=".$modecompta."'>".img_next()."</a>" : "");
$description = $langs->trans("RulesPurchaseTurnoverTotalPurchaseJournal");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
$moreparam = array();
if (!empty($modecompta)) $moreparam['modecompta'] = $modecompta;
report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $moreparam, $calcmode);
if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
}
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= " WHERE f.fk_statut in (1,2)";
$sql .= " AND f.type IN (0,2)";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
}
elseif ($modecompta == "RECETTES-DEPENSES")
{
$sql = "SELECT date_format(p.datep,'%Y-%m') as dm, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
$sql .= " WHERE p.rowid = pf.fk_paiementfourn";
$sql .= " AND pf.fk_facturefourn = f.rowid";
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
}
elseif ($modecompta == "BOOKKEEPING")
{
$sql = "SELECT date_format(b.doc_date,'%Y-%m') as dm, sum(b.debit) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b, ".MAIN_DB_PREFIX."accounting_journal as aj";
$sql .= " WHERE b.entity = ".$conf->entity; // In module double party accounting, we never share entities
$sql .= " AND aj.entity = ".$conf->entity;
$sql .= " AND b.code_journal = aj.code AND aj.nature = 3"; // @todo currently count amount in sale journal, but we need to define a category group for turnover
}
$sql .= " GROUP BY dm";
$sql .= " ORDER BY dm";
// TODO Add a filter on $date_start and $date_end to reduce quantity on data
//print $sql;
$minyearmonth = $maxyearmonth = 0;
$result = $db->query($sql);
if ($result)
{
$num = $db->num_rows($result);
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($result);
$cum_ht[$obj->dm] = !empty($obj->amount) ? $obj->amount : 0;
$cum[$obj->dm] = $obj->amount_ttc;
if ($obj->amount_ttc)
{
$minyearmonth = ($minyearmonth ? min($minyearmonth, $obj->dm) : $obj->dm);
$maxyearmonth = max($maxyearmonth, $obj->dm);
}
$i++;
}
$db->free($result);
}
else {
dol_print_error($db);
}
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
print '<tr class="liste_titre"><td>&nbsp;</td>';
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td align="center" width="10%" colspan="3">';
else print '<td align="center" width="10%" colspan="2" class="borderrightlight">';
if ($modecompta != 'BOOKKEEPING') print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee.($modecompta ? '&modecompta='.$modecompta : '').'">';
print $annee;
if ($conf->global->SOCIETE_FISCAL_MONTH_START > 1) print '-'.($annee + 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
print '</td>';
if ($annee != $year_end) print '<td width="15">&nbsp;</td>';
}
print '</tr>';
print '<tr class="liste_titre"><td class="liste_titre">'.$langs->trans("Month").'</td>';
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') print '<td class="liste_titre right">'.$langs->trans("AmountHT").'</td>';
print '<td class="liste_titre right">'.$langs->trans("AmountTTC").'</td>';
print '<td class="liste_titre right borderrightlight">'.$langs->trans("Delta").'</td>';
if ($annee != $year_end) print '<td class="liste_titre" width="15">&nbsp;</td>';
}
print '</tr>';
$now_show_delta = 0;
$minyear = substr($minyearmonth, 0, 4);
$maxyear = substr($maxyearmonth, 0, 4);
$nowyear = strftime("%Y", dol_now());
$nowyearmonth = strftime("%Y-%m", dol_now());
$maxyearmonth = max($maxyearmonth, $nowyearmonth);
$now = dol_now();
$casenow = dol_print_date($now, "%Y-%m");
// Loop on each month
$nb_mois_decalage = $conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START - 1) : 0;
for ($mois = 1 + $nb_mois_decalage; $mois <= 12 + $nb_mois_decalage; $mois++)
{
$mois_modulo = $mois; // ajout
if ($mois > 12) {$mois_modulo = $mois - 12; } // ajout
if ($year_start == $year_end) {
if ($mois > $date_endmonth && $year_end >= $date_endyear) {
break;
}
}
print '<tr class="oddeven">';
// Month
print "<td>".dol_print_date(dol_mktime(12, 0, 0, $mois_modulo, 1, 2000), "%B")."</td>";
for ($annee = $year_start - 1; $annee <= $year_end; $annee++) // We start one year before to have data to be able to make delta
{
$annee_decalage = $annee;
if ($mois > 12) {$annee_decalage = $annee + 1; }
$case = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage), "%Y-%m");
$caseprev = dol_print_date(dol_mktime(1, 1, 1, $mois_modulo, 1, $annee_decalage - 1), "%Y-%m");
if ($annee >= $year_start) // We ignore $annee < $year_start, we loop on it to be able to make delta, nothing is output.
{
if ($modecompta == 'CREANCES-DETTES') {
// Valeur CA du mois w/o VAT
print '<td class="right">';
if ($cum_ht[$case])
{
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">'.price($cum_ht[$case], 1).'</a>';
}
else
{
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; }
else { print '&nbsp;'; }
}
print "</td>";
}
// Valeur CA du mois
print '<td class="right">';
if ($cum[$case])
{
$now_show_delta = 1; // On a trouve le premier mois de la premiere annee generant du chiffre.
if ($modecompta != 'BOOKKEEPING') print '<a href="supplier_turnover_by_thirdparty.php?year='.$annee_decalage.'&month='.$mois_modulo.($modecompta ? '&modecompta='.$modecompta : '').'">';
print price($cum[$case], 1);
if ($modecompta != 'BOOKKEEPING') print '</a>';
}
else
{
if ($minyearmonth < $case && $case <= max($maxyearmonth, $nowyearmonth)) { print '0'; }
else { print '&nbsp;'; }
}
print "</td>";
// Pourcentage du mois
if ($annee_decalage > $minyear && $case <= $casenow)
{
if ($cum[$caseprev] && $cum[$case])
{
$percent = (round(($cum[$case] - $cum[$caseprev]) / $cum[$caseprev], 4) * 100);
//print "X $cum[$case] - $cum[$caseprev] - $cum[$caseprev] - $percent X";
print '<td class="borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
}
if ($cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">-100%</td>';
}
if (!$cum[$caseprev] && $cum[$case])
{
//print '<td class="right">+Inf%</td>';
print '<td class="borderrightlight right">-</td>';
}
if (isset($cum[$caseprev]) && !$cum[$caseprev] && !$cum[$case])
{
print '<td class="borderrightlight right">+0%</td>';
}
if (!isset($cum[$caseprev]) && !$cum[$case])
{
print '<td class="borderrightlight right">-</td>';
}
}
else
{
print '<td class="borderrightlight right">';
if ($minyearmonth <= $case && $case <= $maxyearmonth) { print '-'; }
else { print '&nbsp;'; }
print '</td>';
}
if ($annee_decalage < $year_end || ($annee_decalage == $year_end && $mois > 12 && $annee < $year_end)) print '<td width="15">&nbsp;</td>';
}
$total_ht[$annee] += ((!empty($cum_ht[$case])) ? $cum_ht[$case] : 0);
$total[$annee] += $cum[$case];
}
print '</tr>';
}
// Affiche total
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td>';
for ($annee = $year_start; $annee <= $year_end; $annee++)
{
if ($modecompta == 'CREANCES-DETTES') {
// Montant total HT
if ($total_ht[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total_ht[$annee] ?price($total_ht[$annee]) : "0")."</td>";
}
else
{
print '<td>&nbsp;</td>';
}
}
// Montant total
if ($total[$annee] || ($annee >= $minyear && $annee <= max($nowyear, $maxyear)))
{
print '<td class="nowrap right">'.($total[$annee] ?price($total[$annee]) : "0")."</td>";
}
else
{
print '<td>&nbsp;</td>';
}
// Pourcentage total
if ($annee > $minyear && $annee <= max($nowyear, $maxyear))
{
if ($total[$annee - 1] && $total[$annee]) {
$percent = (round(($total[$annee] - $total[$annee - 1]) / $total[$annee - 1], 4) * 100);
print '<td class="nowrap borderrightlight right">'.($percent >= 0 ? "+$percent" : "$percent").'%</td>';
}
if ($total[$annee - 1] && !$total[$annee])
{
print '<td class="borderrightlight right">-100%</td>';
}
if (!$total[$annee - 1] && $total[$annee])
{
print '<td class="borderrightlight right">+'.$langs->trans('Inf').'%</td>';
}
if (!$total[$annee - 1] && !$total[$annee])
{
print '<td class="borderrightlight right">+0%</td>';
}
}
else
{
print '<td class="borderrightlight right">';
if ($total[$annee] || ($minyear <= $annee && $annee <= max($nowyear, $maxyear))) { print '-'; }
else { print '&nbsp;'; }
print '</td>';
}
if ($annee != $year_end) print '<td width="15">&nbsp;</td>';
}
print "</tr>\n";
print "</table>";
print '</div>';
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,450 @@
<?php
/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/stats/supplier_turnover_by_prodserv.php
* \brief Page reporting purchase turnover by Products & Services
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
$langs->loadLangs(array("products", "categories", "errors", 'accountancy'));
// Security pack (data & check)
$socid = GETPOST('socid', 'int');
if ($user->socid > 0) $socid = $user->socid;
if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta");
$sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"];
$sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"];
if (!$sortorder) $sortorder = "asc";
if (!$sortfield) $sortfield = "ref";
// Category
$selected_cat = (int) GETPOST('search_categ', 'int');
$selected_soc = (int) GETPOST('search_soc', 'int');
$subcat = false;
if (GETPOST('subcat', 'alpha') === 'yes') {
$subcat = true;
}
// product/service
$selected_type = GETPOST('search_type', 'int');
if ($selected_type == '') $selected_type = -1;
// Date range
$year = GETPOST("year");
$month = GETPOST("month");
$date_startyear = GETPOST("date_startyear");
$date_startmonth = GETPOST("date_startmonth");
$date_startday = GETPOST("date_startday");
$date_endyear = GETPOST("date_endyear");
$date_endmonth = GETPOST("date_endmonth");
$date_endday = GETPOST("date_endday");
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now());
$year_start = $year_current;
} else {
$year_current = $year;
$month_current = strftime("%m", dol_now());
$year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q = GETPOST("q", "int");
if (empty($q))
{
// We define date_start and date_end
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_end = $year_start;
$month_end = $month_start;
if (!GETPOST("month")) // If month not forced
{
if (!GETPOST('year') && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end = $month_start - 1;
if ($month_end < 1) $month_end = 12;
else $year_end++;
}
$date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
}
else
{
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
} else {
// TODO We define q
}
// $date_start and $date_end are defined. We force $year_start and $nbofyear
$tmps = dol_getdate($date_start);
$year_start = $tmps['year'];
$tmpe = dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1;
$commonparams = array();
if (!empty($modecompta)) $commonparams['modecompta'] = $modecompta;
if (!empty($sortorder)) $commonparams['sortorder'] = $sortorder;
if (!empty($sortfield)) $commonparams['sortfield'] = $sortfield;
$headerparams = array();
if (!empty($date_startyear)) $headerparams['date_startyear'] = $date_startyear;
if (!empty($date_startmonth)) $headerparams['date_startmonth'] = $date_startmonth;
if (!empty($date_startday)) $headerparams['date_startday'] = $date_startday;
if (!empty($date_endyear)) $headerparams['date_endyear'] = $date_endyear;
if (!empty($date_endmonth)) $headerparams['date_endmonth'] = $date_endmonth;
if (!empty($date_endday)) $headerparams['date_endday'] = $date_endday;
if (!empty($year)) $headerparams['year'] = $year;
if (!empty($month)) $headerparams['month'] = $month;
$headerparams['q'] = $q;
$tableparams = array();
if (!empty($selected_cat)) $tableparams['search_categ'] = $selected_cat;
if (!empty($selected_soc)) $tableparams['search_soc'] = $selected_soc;
if (!empty($selected_type)) $tableparams['search_type'] = $selected_type;
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);
foreach ($allparams as $key => $value) {
$paramslink .= '&'.$key.'='.$value;
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$formother = new FormOther($db);
// TODO Report from bookkeeping not yet available, so we switch on report on business events
if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES";
if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES";
// Show report header
if ($modecompta == "CREANCES-DETTES") {
$name = $langs->trans("PurchaseTurnover").', '.$langs->trans("ByProductsAndServices");
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverDue");
$builddate = dol_now();
}
elseif ($modecompta == "RECETTES-DEPENSES")
{
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByProductsAndServices");
$calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");
$builddate = dol_now();
}
elseif ($modecompta == "BOOKKEEPING")
{
}
elseif ($modecompta == "BOOKKEEPINGCOLLECTED")
{
}
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start - 1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start + 1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
else $periodlink = '';
report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
}
$name = array();
// SQL request
$catotal = 0;
$catotal_ht = 0;
$qtytotal = 0;
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT DISTINCT p.rowid as rowid, p.ref as ref, p.label as label, p.fk_product_type as product_type,";
$sql .= " SUM(l.total_ht) as amount, SUM(l.total_ttc) as amount_ttc,";
$sql .= " SUM(CASE WHEN f.type = 2 THEN -l.qty ELSE l.qty END) as qty";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
if ($selected_soc > 0) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as soc ON (soc.rowid = f.fk_soc)";
$sql .= ",".MAIN_DB_PREFIX."facture_fourn_det as l";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid";
if ($selected_cat === -2) // Without any category
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
}
elseif ($selected_cat) // Into a specific category
{
$sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp";
}
$sql .= " WHERE l.fk_facture_fourn = f.rowid";
$sql .= " AND f.fk_statut in (1,2)";
$sql .= " AND f.type IN (0,2)";
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
if ($selected_type >= 0)
{
$sql .= " AND l.product_type = ".$selected_type;
}
if ($selected_cat === -2) // Without any category
{
$sql .= " AND cp.fk_product is null";
}
elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat;
$sql .= ")";
$sql .= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid";
}
if ($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc;
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
$sql .= " GROUP BY p.rowid, p.ref, p.label, p.fk_product_type";
$sql .= $db->order($sortfield, $sortorder);
dol_syslog("supplier_turnover_by_prodserv", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount_ht[$obj->rowid] = $obj->amount;
$amount[$obj->rowid] = $obj->amount_ttc;
$qty[$obj->rowid] = $obj->qty;
$name[$obj->rowid] = $obj->ref.'&nbsp;-&nbsp;'.$obj->label;
$type[$obj->rowid] = $obj->product_type;
$catotal_ht += $obj->amount;
$catotal += $obj->amount_ttc;
$qtytotal += $obj->qty;
$i++;
}
} else {
dol_print_error($db);
}
// Show Array
$i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
// Extra parameters management
foreach ($headerparams as $key => $value)
{
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Category filter
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans("Category").': '.$formother->select_categories(Categorie::TYPE_PRODUCT, $selected_cat, 'search_categ', true);
print ' ';
print $langs->trans("SubCats").'? ';
print '<input type="checkbox" name="subcat" value="yes"';
if ($subcat) {
print ' checked';
}
print '>';
// type filter (produit/service)
print ' ';
print $langs->trans("Type").': ';
$form->select_type_of_lines(isset($selected_type) ? $selected_type : -1, 'search_type', 1, 1, 1);
//select thirdparty
print '</br>';
print $langs->trans("ThirdParty").': '.$form->select_thirdparty_list($selected_soc, 'search_soc', '', 1);
print '</td>';
print '<td colspan="5" class="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td></tr>';
// Array header
print "<tr class=\"liste_titre\">";
print_liste_field_titre(
$langs->trans("Product"),
$_SERVER["PHP_SELF"],
"ref",
"",
$paramslink,
"",
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('Quantity'),
$_SERVER["PHP_SELF"],
"qty",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Percentage"),
$_SERVER["PHP_SELF"],
"qty",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans('AmountHT'),
$_SERVER["PHP_SELF"],
"amount",
"",
$classslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("AmountTTC"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Percentage"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print "</tr>\n";
if (count($name)) {
foreach ($name as $key=>$value) {
print '<tr class="oddeven">';
// Product
print "<td>";
$fullname = $name[$key];
if ($key > 0) {
$linkname = '<a href="'.DOL_URL_ROOT.'/product/card.php?id='.$key.'">'.img_object($langs->trans("ShowProduct"), $type[$key] == 0 ? 'product' : 'service').' '.$fullname.'</a>';
} else {
$linkname = $langs->trans("PaymentsNotLinkedToProduct");
}
print $linkname;
print "</td>\n";
// Quantity
print '<td class="right">';
print $qty[$key];
print '</td>';
// Percent;
print '<td class="right">'.($qtytotal > 0 ? round(100 * $qty[$key] / $qtytotal, 2).'%' : '&nbsp;').'</td>';
// Amount w/o VAT
print '<td class="right">';
print price($amount_ht[$key]);
//print '</a>';
print '</td>';
// Amount with VAT
print '<td class="right">';
print price($amount[$key]);
//print '</a>';
print '</td>';
// Percent;
print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
// TODO: statistics?
print "</tr>\n";
$i++;
}
// Total
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td class="right">'.$qtytotal.'</td>';
print '<td class="right">100%</td>';
print '<td class="right">'.price($catotal_ht).'</td>';
print '<td class="right">'.price($catotal).'</td>';
print '<td class="right">100%</td>';
print '</tr>';
$db->free($result);
}
print "</table>";
print '</div>';
print '</form>';
} else {
// $modecompta != 'CREANCES-DETTES'
// "Calculation of part of each product for accountancy in this mode is not possible. When a partial payment (for example 5 euros) is done on an
// invoice with 2 product (product A for 10 euros and product B for 20 euros), what is part of paiment for product A and part of paiment for product B ?
// Because there is no way to know this, this report is not relevant.
print '<br>'.$langs->trans("TurnoverPerProductInCommitmentAccountingNotRelevant").'<br>';
}
// End of page
llxFooter();
$db->close();

View File

@ -0,0 +1,595 @@
<?php
/* Copyright (C) 2020 Maxime Kohlhaas <maxime@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/compta/stats/supplier_ca_by_thirdparty.php
* \brief Page reporting purchase turnover by thirdparty
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
// Load translation files required by the page
$langs->loadLangs(array('companies', 'categories', 'bills', 'compta'));
// Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES')
$modecompta = $conf->global->ACCOUNTING_MODE;
if (GETPOST("modecompta")) $modecompta = GETPOST("modecompta");
$sortorder = isset($_GET["sortorder"]) ? $_GET["sortorder"] : $_POST["sortorder"];
$sortfield = isset($_GET["sortfield"]) ? $_GET["sortfield"] : $_POST["sortfield"];
if (!$sortorder) $sortorder = "asc";
if (!$sortfield) $sortfield = "nom";
$socid = GETPOST('socid', 'int');
// Category
$selected_cat = (int) GETPOST('search_categ', 'int');
$subcat = false;
if (GETPOST('subcat', 'alpha') === 'yes') {
$subcat = true;
}
// Security check
if ($user->socid > 0) $socid = $user->socid;
if (!empty($conf->comptabilite->enabled)) $result = restrictedArea($user, 'compta', '', '', 'resultat');
if (!empty($conf->accounting->enabled)) $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
// Date range
$year = GETPOST("year", 'int');
$month = GETPOST("month", 'int');
$search_societe = GETPOST("search_societe", 'alpha');
$search_zip = GETPOST("search_zip", 'alpha');
$search_town = GETPOST("search_town", 'alpha');
$search_country = GETPOST("search_country", 'alpha');
$date_startyear = GETPOST("date_startyear", 'alpha');
$date_startmonth = GETPOST("date_startmonth", 'alpha');
$date_startday = GETPOST("date_startday", 'alpha');
$date_endyear = GETPOST("date_endyear", 'alpha');
$date_endmonth = GETPOST("date_endmonth", 'alpha');
$date_endday = GETPOST("date_endday", 'alpha');
if (empty($year))
{
$year_current = strftime("%Y", dol_now());
$month_current = strftime("%m", dol_now());
$year_start = $year_current;
} else {
$year_current = $year;
$month_current = strftime("%m", dol_now());
$year_start = $year;
}
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear"));
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear"));
// Quarter
if (empty($date_start) || empty($date_end)) // We define date_start and date_end
{
$q = GETPOST("q", "int") ?GETPOST("q", "int") : 0;
if (empty($q))
{
// We define date_start and date_end
$month_start = GETPOST("month") ?GETPOST("month") : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_end = $year_start;
$month_end = $month_start;
if (!GETPOST("month")) // If month not forced
{
if (!GETPOST('year') && $month_start > $month_current)
{
$year_start--;
$year_end--;
}
$month_end = $month_start - 1;
if ($month_end < 1) $month_end = 12;
else $year_end++;
}
$date_start = dol_get_first_day($year_start, $month_start, false); $date_end = dol_get_last_day($year_end, $month_end, false);
}
if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); }
if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); }
if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); }
if ($q == 4) { $date_start = dol_get_first_day($year_start, 10, false); $date_end = dol_get_last_day($year_start, 12, false); }
}
else
{
// TODO We define q
}
// $date_start and $date_end are defined. We force $year_start and $nbofyear
$tmps = dol_getdate($date_start);
$year_start = $tmps['year'];
$tmpe = dol_getdate($date_end);
$year_end = $tmpe['year'];
$nbofyear = ($year_end - $year_start) + 1;
$commonparams = array();
$commonparams['modecompta'] = $modecompta;
$commonparams['sortorder'] = $sortorder;
$commonparams['sortfield'] = $sortfield;
$headerparams = array();
$headerparams['date_startyear'] = $date_startyear;
$headerparams['date_startmonth'] = $date_startmonth;
$headerparams['date_startday'] = $date_startday;
$headerparams['date_endyear'] = $date_endyear;
$headerparams['date_endmonth'] = $date_endmonth;
$headerparams['date_endday'] = $date_endday;
$headerparams['q'] = $q;
$tableparams = array();
$tableparams['search_categ'] = $selected_cat;
$tableparams['search_societe'] = $search_societe;
$tableparams['search_zip'] = $search_zip;
$tableparams['search_town'] = $search_town;
$tableparams['search_country'] = $search_country;
$tableparams['subcat'] = ($subcat === true) ? 'yes' : '';
// Adding common parameters
$allparams = array_merge($commonparams, $headerparams, $tableparams);
$headerparams = array_merge($commonparams, $headerparams);
$tableparams = array_merge($commonparams, $tableparams);
foreach ($allparams as $key => $value) {
$paramslink .= '&'.$key.'='.$value;
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$thirdparty_static = new Societe($db);
$formother = new FormOther($db);
// TODO Report from bookkeeping not yet available, so we switch on report on business events
if ($modecompta == "BOOKKEEPING") $modecompta = "CREANCES-DETTES";
if ($modecompta == "BOOKKEEPINGCOLLECTED") $modecompta = "RECETTES-DEPENSES";
// Show report header
if ($modecompta == "CREANCES-DETTES")
{
$name = $langs->trans("PurchaseTurnover").', '.$langs->trans("ByThirdParties");
$calcmode = $langs->trans("CalcModeDebt");
//$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverDue");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta == "RECETTES-DEPENSES")
{
$name = $langs->trans("PurchaseTurnoverCollected").', '.$langs->trans("ByThirdParties");
$calcmode = $langs->trans("CalcModeEngagement");
//$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
$description = $langs->trans("RulesPurchaseTurnoverIn");
$builddate = dol_now();
//$exportlink=$langs->trans("NotYetAvailable");
}
elseif ($modecompta == "BOOKKEEPING")
{
}
elseif ($modecompta == "BOOKKEEPINGCOLLECTED")
{
}
$period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) $periodlink = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start - 1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year_start + 1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
else $periodlink = '';
report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode);
if (!empty($conf->accounting->enabled) && $modecompta != 'BOOKKEEPING')
{
print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
}
$name = array();
// Show Array
$catotal = 0;
if ($modecompta == 'CREANCES-DETTES') {
$sql = "SELECT DISTINCT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays,";
$sql .= " sum(f.total_ht) as amount, sum(f.total_ttc) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f, ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) // Without any category
{
$sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
}
elseif ($selected_cat) // Into a specific category
{
$sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
}
$sql .= " WHERE f.fk_statut in (1,2)";
$sql .= " AND f.type IN (0,2)";
$sql .= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
}
if ($selected_cat === -2) // Without any category
{
$sql .= " AND cs.fk_soc is null";
}
elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$db->escape($selected_cat);
if ($subcat) $sql .= " OR c.fk_parent = ".$db->escape($selected_cat);
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
} else {
$sql = "SELECT s.rowid as socid, s.nom as name, s.zip, s.town, s.fk_pays, sum(pf.amount) as amount_ttc";
$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
$sql .= ", ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf";
$sql .= ", ".MAIN_DB_PREFIX."paiementfourn as p";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if ($selected_cat === -2) // Without any category
{
$sql .= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc";
}
elseif ($selected_cat) // Into a specific category
{
$sql .= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_societe as cs";
}
$sql .= " WHERE p.rowid = pf.fk_paiementfourn";
$sql .= " AND pf.fk_facturefourn = f.rowid";
$sql .= " AND f.fk_soc = s.rowid";
if ($date_start && $date_end) {
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
if ($selected_cat === -2) // Without any category
{
$sql .= " AND cs.fk_soc is null";
}
elseif ($selected_cat) { // Into a specific category
$sql .= " AND (c.rowid = ".$selected_cat;
if ($subcat) $sql .= " OR c.fk_parent = ".$selected_cat;
$sql .= ")";
$sql .= " AND cs.fk_categorie = c.rowid AND cs.fk_soc = s.rowid";
}
}
if (!empty($search_societe)) $sql .= natural_search('s.nom', $search_societe);
if (!empty($search_zip)) $sql .= natural_search('s.zip', $search_zip);
if (!empty($search_town)) $sql .= natural_search('s.town', $search_town);
if ($search_country > 0) $sql .= ' AND s.fk_pays = '.$search_country.'';
$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
if ($socid) $sql .= " AND f.fk_soc = ".$socid;
$sql .= " GROUP BY s.rowid, s.nom, s.zip, s.town, s.fk_pays";
$sql .= " ORDER BY s.rowid";
//echo $sql;
dol_syslog("supplier_turnover_by_thirdparty", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($result);
$amount_ht[$obj->socid] = $obj->amount;
$amount[$obj->socid] = $obj->amount_ttc;
$name[$obj->socid] = $obj->name.' '.$obj->firstname;
$address_zip[$obj->socid] = $obj->zip;
$address_town[$obj->socid] = $obj->town;
$address_pays[$obj->socid] = getCountry($obj->fk_pays);
$catotal_ht += $obj->amount;
$catotal += $obj->amount_ttc;
$i++;
}
} else {
dol_print_error($db);
}
// Show array
$i = 0;
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
// Extra parameters management
foreach ($headerparams as $key => $value)
{
print '<input type="hidden" name="'.$key.'" value="'.$value.'">';
}
$moreforfilter = '';
print '<div class="div-table-responsive">';
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
// Category filter
print '<tr class="liste_titre">';
print '<td>';
print $langs->trans("Category").': '.$formother->select_categories(Categorie::TYPE_SUPPLIER, $selected_cat, 'search_categ', true);
print ' ';
print $langs->trans("SubCats").'? ';
print '<input type="checkbox" name="subcat" value="yes"';
if ($subcat) {
print ' checked';
}
print'></td>';
print '<td colspan="7" class="right">';
print '<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans("Search"), 'search.png', '', '', 1).'" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>';
print '</tr>';
print '<tr class="liste_titre">';
print '<td class="liste_titre left">';
print '<input class="flat" size="6" type="text" name="search_societe" value="'.$search_societe.'">';
print '</td>';
print '<td class="liste_titre left">';
print '<input class="flat" size="6" type="text" name="search_zip" value="'.$search_zip.'">';
print '</td>';
print '<td class="liste_titre left">';
print '<input class="flat" size="6" type="text" name="search_town" value="'.$search_town.'">';
print '</td>';
print '<td class="liste_titre left">';
print $form->select_country($search_country, 'search_country');
//print '<input class="flat" size="6" type="text" name="search_country" value="'.$search_country.'">';
print '</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre">&nbsp;</td>';
print '</tr>';
// Array titles
print "<tr class='liste_titre'>";
print_liste_field_titre(
$langs->trans("Company"),
$_SERVER["PHP_SELF"],
"nom",
"",
$paramslink,
"",
$sortfield, $sortorder
);
print_liste_field_titre(
$langs->trans("Zip"),
$_SERVER["PHP_SELF"],
"zip",
"",
$paramslink,
"",
$sortfield, $sortorder
);
print_liste_field_titre(
$langs->trans("Town"),
$_SERVER["PHP_SELF"],
"town",
"",
$paramslink,
"",
$sortfield, $sortorder
);
print_liste_field_titre(
$langs->trans("Country"),
$_SERVER["PHP_SELF"],
"country",
"",
$paramslink,
"",
$sortfield, $sortorder
);
if ($modecompta == 'CREANCES-DETTES') {
print_liste_field_titre(
$langs->trans('AmountHT'),
$_SERVER["PHP_SELF"],
"amount_ht",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
} else {
print_liste_field_titre('');
}
print_liste_field_titre(
$langs->trans("AmountTTC"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("Percentage"),
$_SERVER["PHP_SELF"],
"amount_ttc",
"",
$paramslink,
'class="right"',
$sortfield,
$sortorder
);
print_liste_field_titre(
$langs->trans("OtherStatistics"),
$_SERVER["PHP_SELF"],
"",
"",
"",
'align="center" width="20%"'
);
print "</tr>\n";
if (count($amount)) {
$arrayforsort = $name;
// Defining array arrayforsort
if ($sortfield == 'nom' && $sortorder == 'asc') {
asort($name);
$arrayforsort = $name;
}
if ($sortfield == 'nom' && $sortorder == 'desc') {
arsort($name);
$arrayforsort = $name;
}
if ($sortfield == 'amount_ht' && $sortorder == 'asc') {
asort($amount_ht);
$arrayforsort = $amount_ht;
}
if ($sortfield == 'amount_ht' && $sortorder == 'desc') {
arsort($amount_ht);
$arrayforsort = $amount_ht;
}
if ($sortfield == 'amount_ttc' && $sortorder == 'asc') {
asort($amount);
$arrayforsort = $amount;
}
if ($sortfield == 'amount_ttc' && $sortorder == 'desc') {
arsort($amount);
$arrayforsort = $amount;
}
if ($sortfield == 'zip' && $sortorder == 'asc') {
asort($address_zip);
$arrayforsort = $address_zip;
}
if ($sortfield == 'zip' && $sortorder == 'desc') {
arsort($address_zip);
$arrayforsort = $address_zip;
}
if ($sortfield == 'town' && $sortorder == 'asc') {
asort($address_town);
$arrayforsort = $address_town;
}
if ($sortfield == 'town' && $sortorder == 'desc') {
arsort($address_town);
$arrayforsort = $address_town;
}
if ($sortfield == 'country' && $sortorder == 'asc') {
asort($address_pays);
$arrayforsort = $address_town;
}
if ($sortfield == 'country' && $sortorder == 'desc') {
arsort($address_pays);
$arrayforsort = $address_town;
}
foreach ($arrayforsort as $key=>$value) {
print '<tr class="oddeven">';
// Third party
$fullname = $name[$key];
if ($key > 0) {
$thirdparty_static->id = $key;
$thirdparty_static->name = $fullname;
$thirdparty_static->client = 1;
$linkname = $thirdparty_static->getNomUrl(1, 'supplier');
} else {
$linkname = $langs->trans("PaymentsNotLinkedToInvoice");
}
print "<td>".$linkname."</td>\n";
print '<td>';
print $address_zip[$key];
print '</td>';
print '<td>';
print $address_town[$key];
print '</td>';
print '<td>';
print $address_pays[$key];
print '</td>';
// Amount w/o VAT
print '<td class="right">';
if ($modecompta != 'CREANCES-DETTES') {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
} else {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid=-1">';
}
} else {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
} else {
print '<a href="#">';
}
print price($amount_ht[$key]);
}
print '</td>';
// Amount with VAT
print '<td class="right">';
if ($modecompta != 'CREANCES-DETTES') {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?socid='.$key.'">';
} else {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/paiement/list.php?orphelins=1">';
}
} else {
if ($key > 0) {
print '<a href="'.DOL_URL_ROOT.'/fourn/facture/list.php?socid='.$key.'">';
} else {
print '<a href="#">';
}
}
print price($amount[$key]);
print '</a>';
print '</td>';
// Percent;
print '<td class="right">'.($catotal > 0 ? round(100 * $amount[$key] / $catotal, 2).'%' : '&nbsp;').'</td>';
// Other stats
print '<td class="center">';
if (!empty($conf->supplier_proposal->enabled) && $key > 0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/comm/propal/stats/index.php?socid='.$key.'">'.img_picto($langs->trans("ProposalStats"), "stats").'</a>&nbsp;';
}
if (!empty($conf->fournisseur->enabled) && $key > 0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/commande/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("OrderStats"), "stats").'</a>&nbsp;';
}
if (!empty($conf->fournisseur->enabled) && $key > 0) {
print '&nbsp;<a href="'.DOL_URL_ROOT.'/compta/facture/stats/index.php?mode=supplier&socid='.$key.'">'.img_picto($langs->trans("InvoiceStats"), "stats").'</a>&nbsp;';
}
print '</td>';
print "</tr>\n";
$i++;
}
// Total
print '<tr class="liste_total">';
print '<td>'.$langs->trans("Total").'</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
if ($modecompta != 'CREANCES-DETTES') {
print '<td colspan="1"></td>';
} else {
print '<td class="right">'.price($catotal_ht).'</td>';
}
print '<td class="right">'.price($catotal).'</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$db->free($result);
}
print "</table>";
print "</div>";
print '</form>';
// End of page
llxFooter();
$db->close();

View File

@ -39,165 +39,165 @@
*/
function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = '', $addfieldentry = array(), $delfieldentry = '')
{
global $db, $langs;
global $db, $langs;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
{
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval']))
{
dol_print_error('', 'Bad parameter addfieldentry with a property arrayofkeyval defined but that is not an array.');
return -1;
}
// Check parameters
if (count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
}
// Check parameters
if (count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration)/', $addfieldentry['type'])
&& !preg_match('/^(boolean|real|date|datetime|timestamp)$/', $addfieldentry['type']))
{
setEventMessages($langs->trans('BadValueForType', $objectname), null, 'errors');
return -2;
}
}
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -3;
}
$pathoffiletoeditsrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoedittarget = $destdir.'/class/'.strtolower($objectname).'.class.php'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -3;
}
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
//dol_delete_file($pathoffiletoedittmp, 0, 1, 1);
try
{
include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -4;
try
{
include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -4;
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Edit class files
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
// Edit class files
$contentclass = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
// Update ->fields (add or remove entries)
if (count($object->fields))
{
if (is_array($addfieldentry) && count($addfieldentry))
{
// Update ->fields (add or remove entries)
if (count($object->fields))
{
if (is_array($addfieldentry) && count($addfieldentry))
{
$name = $addfieldentry['name'];
unset($addfieldentry['name']);
unset($addfieldentry['name']);
$object->fields[$name] = $addfieldentry;
}
if (!empty($delfieldentry))
{
$name = $delfieldentry;
unset($object->fields[$name]);
}
}
$object->fields[$name] = $addfieldentry;
}
if (!empty($delfieldentry))
{
$name = $delfieldentry;
unset($object->fields[$name]);
}
}
dol_sort_array($object->fields, 'position');
dol_sort_array($object->fields, 'position');
$i = 0;
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
$texttoinsert .= "\t".'/**'."\n";
$texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
$texttoinsert .= "\t".' */'."\n";
$texttoinsert .= "\t".'public $fields=array('."\n";
$i = 0;
$texttoinsert = '// BEGIN MODULEBUILDER PROPERTIES'."\n";
$texttoinsert .= "\t".'/**'."\n";
$texttoinsert .= "\t".' * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.'."\n";
$texttoinsert .= "\t".' */'."\n";
$texttoinsert .= "\t".'public $fields=array('."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
if ($val['arrayofkeyval'])
{
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if ($i) $texttoinsert .= ", ";
$texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert .= "),";
}
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',";
$texttoinsert .= " 'enabled'=>".($val['enabled'] !== '' ? $val['enabled'] : 1).",";
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
if ($val['noteditable']) $texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
if ($val['default']) $texttoinsert .= " 'default'=>'".$val['default']."',";
if ($val['index']) $texttoinsert .= " 'index'=>".$val['index'].",";
if ($val['foreignkey']) $texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
if ($val['searchall']) $texttoinsert .= " 'searchall'=>".$val['searchall'].",";
if ($val['isameasure']) $texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
if ($val['css']) $texttoinsert .= " 'css'=>'".$val['css']."',";
if ($val['help']) $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
if ($val['showoncombobox']) $texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
if ($val['disabled']) $texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
if ($val['arrayofkeyval'])
{
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
foreach ($val['arrayofkeyval'] as $key2 => $val2)
{
if ($i) $texttoinsert .= ", ";
$texttoinsert .= "'".$key2."'=>'".$val2."'";
$i++;
}
$texttoinsert .= "),";
}
if ($val['comment']) $texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
$texttoinsert .= "),\n";
}
}
$texttoinsert .= "),\n";
}
}
$texttoinsert .= "\t".');'."\n";
$texttoinsert .= "\t".');'."\n";
//print ($texttoinsert);exit;
if (count($object->fields))
{
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
if (count($object->fields))
{
//$typetotypephp=array('integer'=>'integer', 'duration'=>'integer', 'varchar'=>'string');
foreach ($object->fields as $key => $val)
{
$i++;
//$typephp=$typetotypephp[$val['type']];
$texttoinsert .= "\t".'public $'.$key.";";
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
//if ($i < count($object->fields)) $texttoinsert.=";";
$texttoinsert .= "\n";
}
}
foreach ($object->fields as $key => $val)
{
$i++;
//$typephp=$typetotypephp[$val['type']];
$texttoinsert .= "\t".'public $'.$key.";";
//if ($key == 'rowid') $texttoinsert.= ' AUTO_INCREMENT PRIMARY KEY';
//if ($key == 'entity') $texttoinsert.= ' DEFAULT 1';
//$texttoinsert.= ($val['notnull']?' NOT NULL':'');
//if ($i < count($object->fields)) $texttoinsert.=";";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
$texttoinsert .= "\t".'// END MODULEBUILDER PROPERTIES';
//print($texttoinsert);exit;
//print($texttoinsert);exit;
$contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass);
$contentclass = preg_replace('/\/\/ BEGIN MODULEBUILDER PROPERTIES.*END MODULEBUILDER PROPERTIES/ims', $texttoinsert, $contentclass);
dol_mkdir(dirname($pathoffiletoedittarget));
dol_mkdir(dirname($pathoffiletoedittarget));
//file_put_contents($pathoffiletoedittmp, $contentclass);
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
@chmod($pathoffiletoedittarget, octdec($newmask));
//file_put_contents($pathoffiletoedittmp, $contentclass);
file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
@chmod($pathoffiletoedittarget, octdec($newmask));
return $object;
}
catch (Exception $e)
{
print $e->getMessage();
return -5;
}
return $object;
}
catch (Exception $e)
{
print $e->getMessage();
return -5;
}
}
/**
@ -214,134 +214,134 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
*/
function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '', $object = null)
{
global $db, $langs;
global $db, $langs;
$error = 0;
$error = 0;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
if (empty($objectname)) return -1;
if (empty($readdir)) $readdir = $destdir;
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
$pathoffiletoclasssrc = $readdir.'/class/'.strtolower($objectname).'.class.php';
// Edit .sql file
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
// Edit .sql file
$pathoffiletoeditsrc = $readdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.sql'.($readdir != $destdir ? '.new' : '');
if (!dol_is_file($pathoffiletoeditsrc))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
}
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
}
// Load object from myobject.class.php
try
{
if (!is_object($object))
{
include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -1;
}
}
catch (Exception $e)
{
print $e->getMessage();
}
// Load object from myobject.class.php
try
{
if (!is_object($object))
{
include_once $pathoffiletoclasssrc;
if (class_exists($objectname)) $object = new $objectname($db);
else return -1;
}
}
catch (Exception $e)
{
print $e->getMessage();
}
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER FIELDS'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
$type = $val['type'];
$type = preg_replace('/:.*$/', '', $type); // For case type = 'integer:Societe:societe/class/societe.class.php'
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
else
{
if ($val['default'] != '')
{
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) $texttoinsert .= ", ";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
if ($type == 'html') $type = 'text'; // html modulebuilder type is a text type in database
elseif ($type == 'price') $type = 'double'; // html modulebuilder type is a text type in database
elseif (in_array($type, array('link', 'sellist', 'duration'))) $type = 'integer';
$texttoinsert .= "\t".$key." ".$type;
if ($key == 'rowid') $texttoinsert .= ' AUTO_INCREMENT PRIMARY KEY';
if ($key == 'entity') $texttoinsert .= ' DEFAULT 1';
else
{
if ($val['default'] != '')
{
if (preg_match('/^null$/i', $val['default'])) $texttoinsert .= " DEFAULT NULL";
elseif (preg_match('/varchar/', $type)) $texttoinsert .= " DEFAULT '".$db->escape($val['default'])."'";
else $texttoinsert .= (($val['default'] > 0) ? ' DEFAULT '.$val['default'] : '');
}
}
$texttoinsert .= (($val['notnull'] > 0) ? ' NOT NULL' : '');
if ($i < count($object->fields)) $texttoinsert .= ", ";
$texttoinsert .= "\n";
}
}
$texttoinsert .= "\t".'-- END MODULEBUILDER FIELDS';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
$result = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
// Edit .key.sql file
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
// Edit .key.sql file
$pathoffiletoeditsrc = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql';
$pathoffiletoedittarget = $destdir.'/sql/llx_'.strtolower($module).'_'.strtolower($objectname).'.key.sql'.($readdir != $destdir ? '.new' : '');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$contentsql = file_get_contents(dol_osencode($pathoffiletoeditsrc), 'r');
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
if (!empty($val['index']))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "\n";
}
if (!empty($val['foreignkey']))
{
$tmp = explode('.', $val['foreignkey']);
if (!empty($tmp[0]) && !empty($tmp[1]))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
$texttoinsert .= "\n";
}
}
}
}
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
$i = 0;
$texttoinsert = '-- BEGIN MODULEBUILDER INDEXES'."\n";
if (count($object->fields))
{
foreach ($object->fields as $key => $val)
{
$i++;
if (!empty($val['index']))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD INDEX idx_".strtolower($module).'_'.strtolower($objectname)."_".$key." (".$key.");";
$texttoinsert .= "\n";
}
if (!empty($val['foreignkey']))
{
$tmp = explode('.', $val['foreignkey']);
if (!empty($tmp[0]) && !empty($tmp[1]))
{
$texttoinsert .= "ALTER TABLE llx_".strtolower($module).'_'.strtolower($objectname)." ADD CONSTRAINT llx_".strtolower($module).'_'.strtolower($objectname)."_".$key." FOREIGN KEY (".$key.") REFERENCES llx_".preg_replace('/^llx_/', '', $tmp[0])."(".$tmp[1].");";
$texttoinsert .= "\n";
}
}
}
}
$texttoinsert .= '-- END MODULEBUILDER INDEXES';
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
$contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
dol_mkdir(dirname($pathoffiletoedittarget));
dol_mkdir(dirname($pathoffiletoedittarget));
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
$result2 = file_put_contents($pathoffiletoedittarget, $contentsql);
if ($result)
{
@chmod($pathoffiletoedittarget, octdec($newmask));
}
else
{
$error++;
}
return $error ? -1 : 1;
return $error ? -1 : 1;
}

View File

@ -1376,6 +1376,27 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
//$newmenu->add("/compta/stats/byratecountry.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByVatRate"),3,$user->rights->accounting->comptarapport->lire);
}
}
$modecompta = 'CREANCES-DETTES';
if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta = 'BOOKKEEPING'; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
if ($modecompta && $conf->fournisseur->enabled)
{
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
$newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnover"), 2, $user->rights->accounting->comptarapport->lire);
$newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
$newmenu->add("/compta/stats/supplier_turnover_by_prodserv.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByProductsAndServices"), 3, $user->rights->accounting->comptarapport->lire);
}
}
$modecompta = 'RECETTES-DEPENSES';
//if (! empty($conf->accounting->enabled) && ! empty($user->rights->accounting->comptarapport->lire) && $mainmenu == 'accountancy') $modecompta=''; // Not yet implemented. Should be BOOKKEEPINGCOLLECTED
if ($modecompta && $conf->fournisseur->enabled)
{
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_report/', $leftmenu)) {
$newmenu->add("/compta/stats/supplier_turnover.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ReportPurchaseTurnoverCollected"), 2, $user->rights->accounting->comptarapport->lire);
$newmenu->add("/compta/stats/supplier_turnover_by_thirdparty.php?leftmenu=accountancy_report&modecompta=".$modecompta, $langs->trans("ByCompanies"), 3, $user->rights->accounting->comptarapport->lire);
}
}
}
// Accountancy (simple)

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/bom/modules_bom.php';
class mod_bom_standard extends ModeleNumRefboms
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='BOM';
@ -48,16 +48,16 @@ class mod_bom_standard extends ModeleNumRefboms
public $name='standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_bom_standard extends ModeleNumRefboms
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,8 +140,8 @@ class mod_bom_standard extends ModeleNumRefboms
$date=$object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_bom_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFBom extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'bom';
@ -110,7 +110,7 @@ abstract class ModeleNumRefBoms
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php
class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='CHK';
@ -45,16 +45,16 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
public $name='Mint';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -69,8 +69,8 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -137,15 +137,15 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
$date=$object->date_bordereau;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -155,7 +155,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
*/
public function chequereceipt_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -76,11 +76,11 @@ abstract class ModeleNumRefChequeReceipts
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
@ -128,17 +128,17 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='chequereceipt';

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/commande/modules_commande.php';
class mod_commande_marbre extends ModeleNumRefCommandes
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='CO';
@ -48,16 +48,16 @@ class mod_commande_marbre extends ModeleNumRefCommandes
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_commande_marbre extends ModeleNumRefCommandes
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,15 +140,15 @@ class mod_commande_marbre extends ModeleNumRefCommandes
$date=$object->date;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -158,7 +158,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
*/
public function commande_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -40,17 +40,17 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
abstract class ModelePDFCommandes extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'order';
@ -111,7 +111,7 @@ abstract class ModeleNumRefCommandes
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -34,32 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
*/
abstract class ModeleDon extends CommonDocGenerator
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='donation';
$liste=array();
$type='donation';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
@ -68,81 +68,81 @@ abstract class ModeleDon extends CommonDocGenerator
*/
abstract class ModeleNumRefDons
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}

View File

@ -29,9 +29,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/expensereport/modules_expenserepo
class mod_expensereport_jade extends ModeleNumRefExpenseReport
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='ER';
@ -54,16 +54,16 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
public $name='Jade';
/**
* Return description of numbering model
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering model
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -71,19 +71,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
*
* @return string Example
*/
public function getExample()
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
public function canBeActivated()
{
global $conf,$langs,$db;
@ -117,7 +117,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($object)
public function getNextValue($object)
{
global $db,$conf;
@ -139,19 +139,19 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
$result = $db->query($sql);
if ($db->num_rows($result) > 0) {
$objp = $db->fetch_object($result);
$newref = $objp->max;
$newref++;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
} else {
$newref = 1;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
}
if ($db->num_rows($result) > 0) {
$objp = $db->fetch_object($result);
$newref = $objp->max;
$newref++;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
} else {
$newref = 1;
while (strlen($newref) < $num_car) {
$newref = "0".$newref;
}
}
$ref_number_int = ($newref+1)-1;
@ -202,8 +202,8 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog("mod_expensereport_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -46,17 +46,17 @@ abstract class ModelePDFFactures extends CommonDocGenerator
public $atleastoneratenotnull = 0;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'invoice';
@ -114,8 +114,8 @@ abstract class ModeleNumRefFactures
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -40,17 +40,17 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='ficheinter';
@ -109,8 +109,8 @@ abstract class ModeleNumRefFicheinter
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -164,7 +164,7 @@ abstract class ModeleNumRefFicheinter
*/
function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
// phpcs:enable
// phpcs:enable
global $conf,$langs,$user;
$langs->load("ficheinter");
@ -187,11 +187,11 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0,
// If selected modele is a filename template (then $modele="modelname:filename")
$tmp=explode(':', $modele, 2);
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
if (! empty($tmp[1]))
{
$modele=$tmp[0];
$srctemplatepath=$tmp[1];
}
// Search template files
$file=''; $classname=''; $filefound=0;
@ -199,21 +199,21 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails = 0,
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels, $conf->modules_parts['models']);
foreach($dirmodels as $reldir)
{
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
foreach(array('doc','pdf') as $prefix)
{
$file = $prefix."_".$modele.".modules.php";
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
}
// On verifie l'emplacement du modele
$file=dol_buildpath($reldir."core/modules/fichinter/doc/".$file, 0);
if (file_exists($file))
{
$filefound=1;
$classname=$prefix.'_'.$modele;
break;
}
}
if ($filefound) break;
}
// Charge le modele
if ($filefound)

View File

@ -35,9 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
class mod_livraison_jade extends ModeleNumRefDeliveryOrder
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
@ -57,7 +57,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
*/
public $name = 'Jade';
public $prefix = 'BL';
public $prefix = 'BL';
/**
@ -74,103 +74,103 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $langs, $conf, $db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $langs, $conf, $db;
$langs->load("bills");
$langs->load("bills");
// Check invoice num
$fayymm = ''; $max = '';
// Check invoice num
$fayymm = ''; $max = '';
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
}
if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
{
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
$resql = $db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $fayymm = substr($row[0], 0, 6); $max = $row[0]; }
}
if ($fayymm && !preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $fayymm))
{
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
return true;
}
return true;
}
/**
/**
* Return next free value
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db, $conf;
public function getNextValue($objsoc, $object)
{
global $db, $conf;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql .= " AND entity = ".$conf->entity;
$resql = $db->query($sql);
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
return -1;
}
$resql = $db->query($sql);
dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max = 0;
}
else
{
return -1;
}
$date = $object->date_delivery;
if (empty($date)) $date = dol_now();
$yymm = strftime("%y%m", $date);
$date = $object->date_delivery;
if (empty($date)) $date = dol_now();
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
dol_syslog("mod_livraison_jade::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free ref
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object livraison
* @return string Texte descriptif
*/
public function livraison_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free ref
*
* @param Societe $objsoc Object thirdparty
* @param Object $object Object livraison
* @return string Texte descriptif
*/
public function livraison_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -36,32 +36,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='delivery';
$liste=array();
$type='delivery';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
@ -72,83 +72,83 @@ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator
*/
abstract class ModeleNumRefDeliveryOrder
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("deliveries");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Object $object Object delivery
* @return string Valeur
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Object $object Object delivery
* @return string Valeur
*/
public function getNextValue($objsoc, $object)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental");
elseif ($this->version == 'dolibarr') return DOL_VERSION;
elseif ($this->version) return $this->version;
else return $langs->trans("NotAvailable");
}
}

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/mrp/modules_mo.php';
class mod_mo_standard extends ModeleNumRefMos
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'MO';
@ -48,16 +48,16 @@ class mod_mo_standard extends ModeleNumRefMos
public $name = 'standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -72,8 +72,8 @@ class mod_mo_standard extends ModeleNumRefMos
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -140,8 +140,8 @@ class mod_mo_standard extends ModeleNumRefMos
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_mo_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -39,17 +39,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFMo extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'mo';
@ -110,7 +110,7 @@ abstract class ModeleNumRefMos
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/payment/modules_payment.php';
class mod_payment_cicada extends ModeleNumRefPayments
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PAY';
@ -55,16 +55,16 @@ class mod_payment_cicada extends ModeleNumRefPayments
public $name='Cicada';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -79,8 +79,8 @@ class mod_payment_cicada extends ModeleNumRefPayments
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -147,15 +147,15 @@ class mod_payment_cicada extends ModeleNumRefPayments
$date=$object->datepaye;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -165,7 +165,7 @@ class mod_payment_cicada extends ModeleNumRefPayments
*/
public function payment_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -63,11 +63,11 @@ abstract class ModeleNumRefPayments
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;

View File

@ -33,226 +33,226 @@
*/
abstract class ModelePDFProduct extends CommonDocGenerator
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='product';
$liste=array();
$type='product';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
}
abstract class ModeleProductCode
{
/**
* @var string Error code (or message)
*/
public $error='';
/**
* @var string Error code (or message)
*/
public $error='';
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi nom module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return empty($this->name)?$this->nom:$this->name;
}
/** Renvoi nom module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return empty($this->name)?$this->nom:$this->name;
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return next value available
*
* @param Product $objproduct Object product
* @param int $type Type
* @return string Value
*/
public function getNextValue($objproduct = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return next value available
*
* @param Product $objproduct Object product
* @param int $type Type
* @return string Value
*/
public function getNextValue($objproduct = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/** Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/** Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoi la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Product $product Product object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $product, $type)
{
global $conf;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Product $product Product object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $product, $type)
{
global $conf;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) {
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
}
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfProduct").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == 1)
{
$s.=$langs->trans("RequiredIfService").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($product, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($product, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) {
$s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
$s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
}
if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfProduct").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == 1)
{
$s.=$langs->trans("RequiredIfService").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
elseif ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($product, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Product").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($product, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Service").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
}

View File

@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/modules_project.php';
class mod_project_simple extends ModeleNumRefProjects
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PJ';
/**
/**
* @var string Error code (or message)
*/
public $error='';
@ -57,74 +57,74 @@ class mod_project_simple extends ModeleNumRefProjects
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " FROM ".MAIN_DB_PREFIX."projet";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $project)
{
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $project)
{
global $db,$conf;
// D'abord on recupere la valeur max
@ -157,20 +157,20 @@ class mod_project_simple extends ModeleNumRefProjects
dol_syslog("mod_project_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Next not used reference
*/
public function project_get_num($objsoc = 0, $project = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $project);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Next not used reference
*/
public function project_get_num($objsoc = 0, $project = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $project);
}
}

View File

@ -32,14 +32,14 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/project/task/modules_task.php';
class mod_task_simple extends ModeleNumRefTask
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='TK';
/**
/**
* @var string Error code (or message)
*/
public $error='';
@ -57,40 +57,40 @@ class mod_task_simple extends ModeleNumRefTask
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM " . $posindice . ") AS SIGNED)) as max";
@ -98,34 +98,34 @@ class mod_task_simple extends ModeleNumRefTask
$sql .= MAIN_DB_PREFIX . "projet AS project WHERE task.fk_projet=project.rowid";
$sql .= " AND task.ref LIKE '" . $db->escape($this->prefix) . "____-%'";
$sql .= " AND project.entity = " . $conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Task $object Object Task
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Task $object Object Task
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $object)
{
global $db,$conf;
// D'abord on recupere la valeur max
@ -157,19 +157,19 @@ class mod_task_simple extends ModeleNumRefTask
dol_syslog("mod_task_simple::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Task $object Object task
* @return string Next not used reference
*/
public function task_get_num($objsoc = 0, $object = '')
{
return $this->getNextValue($objsoc, $object);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next reference not yet used as a reference
*
* @param Societe $objsoc Object third party
* @param Task $object Object task
* @return string Next not used reference
*/
public function task_get_num($objsoc = 0, $object = '')
{
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
class mod_propale_marbre extends ModeleNumRefPropales
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='PR';
@ -57,16 +57,16 @@ class mod_propale_marbre extends ModeleNumRefPropales
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -81,8 +81,8 @@ class mod_propale_marbre extends ModeleNumRefPropales
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -33,32 +33,32 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
*/
abstract class ModeleThirdPartyDoc extends CommonDocGenerator
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
global $conf;
$type='company';
$liste=array();
$type='company';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste = getListOfModels($db, $type, $maxfilenamelength);
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste = getListOfModels($db, $type, $maxfilenamelength);
return $liste;
}
return $liste;
}
}
/**
@ -67,197 +67,197 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator
*/
abstract class ModeleThirdPartyCode
{
/**
* @var string Error code (or message)
/**
* @var string Error code (or message)
*/
public $error='';
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Renvoi la description par defaut du modele de numerotation
*
* @param Translate $langs Object langs
* @return string Texte descripif
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/** Return name of module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return $this->name;
}
/** Return name of module
*
* @param Translate $langs Object langs
* @return string Nom du module
*/
public function getNom($langs)
{
return $this->name;
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/** Return an example of numbering
*
* @param Translate $langs Object langs
* @return string Example
*/
public function getExample($langs)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return next value available
*
* @param Societe $objsoc Object thirdparty
* @param int $type Type
* @return string Value
*/
public function getNextValue($objsoc = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return next value available
*
* @param Societe $objsoc Object thirdparty
* @param int $type Type
* @return string Value
*/
public function getNextValue($objsoc = 0, $type = -1)
{
global $langs;
return $langs->trans("Function_getNextValue_InModuleNotWorking");
}
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la liste des modeles de numérotation
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
$liste=array();
$sql ="";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($resql);
$liste[$row[0]]=$row[1];
$i++;
}
}
else
{
return -1;
}
return $liste;
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfCustomer").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == 1)
{
$s.=$langs->trans("RequiredIfSupplier").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($soc, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($soc, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->getNom($langs).'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
if ($type == 0) $s.=$langs->trans("CustomerCodeDesc").'<br>';
if ($type == 1) $s.=$langs->trans("SupplierCodeDesc").'<br>';
if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': <b>'.$this->getNom($langs).'</b><br>';
$s.='<br>';
$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
if ($type == 0)
{
$s.=$langs->trans("RequiredIfCustomer").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == 1)
{
$s.=$langs->trans("RequiredIfSupplier").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
if ($type == -1)
{
$s.=$langs->trans("Required").': ';
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='<strike>';
$s.=yn(!$this->code_null, 1, 2);
if (! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED) && ! empty($this->code_null)) $s.='</strike> '.yn(1, 1, 2).' ('.$langs->trans("ForcedToByAModule", $langs->transnoentities("yes")).')';
$s.='<br>';
}
$s.=$langs->trans("CanBeModifiedIfOk").': ';
$s.=yn($this->code_modifiable, 1, 2);
$s.='<br>';
$s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide, 1, 2).'<br>';
$s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto, 1, 2).'<br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$nextval=$this->getNextValue($soc, 0);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$nextval=$this->getNextValue($soc, 1);
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Check if mask/numbering use prefix
*
* @return int 0=no, 1=yes
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
*/
public function verif_prefixIsUsed()
{
// phpcs:enable
return 0;
}
}
@ -266,119 +266,119 @@ abstract class ModeleThirdPartyCode
*/
abstract class ModeleAccountancyCode
{
/**
/**
* @var string Error code (or message)
*/
public $error='';
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return description of module
*
* @param Translate $langs Object langs
* @return string Description of module
*/
public function info($langs)
{
$langs->load("bills");
return $langs->trans("NoDescription");
}
/**
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Example
*/
public function getExample($langs, $objsoc = 0, $type = -1)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Return an example of result returned by getNextValue
*
* @param Translate $langs Object langs
* @param societe $objsoc Object thirdparty
* @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect)
* @return string Example
*/
public function getExample($langs, $objsoc = 0, $type = -1)
{
$langs->load("bills");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Return version of module
*
* @return string Version
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf,$db;
/**
* Return description of module parameters
*
* @param Translate $langs Output language
* @param Societe $soc Third party object
* @param int $type -1=Nothing, 0=Customer, 1=Supplier
* @return string HTML translated description
*/
public function getToolTip($langs, $soc, $type)
{
global $conf,$db;
$langs->load("admin");
$langs->load("admin");
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
//$s.='<br>';
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$result=$this->get_code($db, $soc, 'customer');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$result=$this->get_code($db, $soc, 'supplier');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
$s='';
if ($type == -1) $s.=$langs->trans("Name").': <b>'.$this->name.'</b><br>';
if ($type == -1) $s.=$langs->trans("Version").': <b>'.$this->getVersion().'</b><br>';
//$s.='<br>';
//$s.='<u>'.$langs->trans("ThisIsModuleRules").':</u><br>';
$s.='<br>';
if ($type == 0 || $type == -1)
{
$result=$this->get_code($db, $soc, 'customer');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Customer").')':'').': <b>'.$nextval.'</b><br>';
}
if ($type == 1 || $type == -1)
{
$result=$this->get_code($db, $soc, 'supplier');
$nextval=$this->code;
if (empty($nextval)) $nextval=$langs->trans("Undefined");
$s.=$langs->trans("NextValue").($type == -1?' ('.$langs->trans("Supplier").')':'').': <b>'.$nextval.'</b>';
}
return $s;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set accountancy account code for a third party into this->code
*
* @param DoliDB $db Database handler
* @param Societe $societe Third party object
* @param int $type 'customer' or 'supplier'
* @return int >=0 if OK, <0 if KO
*/
public function get_code($db, $societe, $type = '')
{
// phpcs:enable
global $langs;
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Set accountancy account code for a third party into this->code
*
* @param DoliDB $db Database handler
* @param Societe $societe Third party object
* @param int $type 'customer' or 'supplier'
* @return int >=0 if OK, <0 if KO
*/
public function get_code($db, $societe, $type = '')
{
// phpcs:enable
global $langs;
return $langs->trans("NotAvailable");
}
return $langs->trans("NotAvailable");
}
}
@ -399,7 +399,7 @@ abstract class ModeleAccountancyCode
*/
function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING);
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View File

@ -32,15 +32,15 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_order/modules_commandefo
class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
* @var string Error code (or message)
*/
public $error = '';
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Nom du modele
@ -62,118 +62,118 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
*/
public function __construct()
{
global $conf;
global $conf;
if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order"
if ((float) $conf->global->MAIN_VERSION_LAST_INSTALL >= 5.0) $this->prefix = 'PO'; // We use correct standard code "PO = Purchase Order"
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf,$langs,$db;
$coyymm=''; $max='';
$coyymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $coyymm = substr($row[0], 0, 6); $max=$row[0]; }
}
if (! $coyymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i', $coyymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel', $max);
return false;
}
}
return false;
}
}
/**
* Return next value
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc = 0, $object = '')
{
global $db,$conf;
*/
public function getNextValue($objsoc = 0, $object = '')
{
global $db,$conf;
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
$sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
//$date=time();
$date=$object->date_commande; // Not always defined
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
$yymm = strftime("%y%m", $date);
$date=$object->date_commande; // Not always defined
if (empty($date)) $date=$object->date; // Creation date is order date for suppliers orders
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
return $this->prefix.$yymm."-".$num;
}
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la reference de commande suivante non utilisee
*
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Renvoie la reference de commande suivante non utilisee
*
* @param Societe $objsoc Object third party
* @param Object $object Object
* @return string Texte descripif
*/
public function commande_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
* @return string Texte descripif
*/
public function commande_get_num($objsoc = 0, $object = '')
{
// phpcs:enable
return $this->getNextValue($objsoc, $object);
}
}

View File

@ -30,9 +30,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier
class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='SPAY';
@ -55,16 +55,16 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
public $name='Bronan';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -79,8 +79,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
@ -147,15 +147,15 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
$date=$object->datepaye;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max+1);
dol_syslog(__METHOD__." return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return next free value
*
@ -165,7 +165,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
*/
public function payment_get_num($objsoc, $objforref)
{
// phpcs:enable
// phpcs:enable
return $this->getNextValue($objsoc, $objforref);
}
}

View File

@ -28,17 +28,17 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator
public $error='';
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation models
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of numbers
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type='supplier_payment';
@ -98,11 +98,11 @@ abstract class ModeleNumRefSupplierPayments
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;

View File

@ -32,9 +32,9 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_proposal/modules_supplie
class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix='RQ'; // RQ = Request for quotation
@ -57,16 +57,16 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
public $name='Marbre';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -81,8 +81,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/

View File

@ -47,21 +47,21 @@ abstract class ModeleNumRefTakepos
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("cashdesk@cashdesk");
return $langs->trans("NoDescription");
}
public function info()
{
global $langs;
$langs->load("cashdesk@cashdesk");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
@ -69,11 +69,11 @@ abstract class ModeleNumRefTakepos
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load('cashdesk@cashdesk');
return $langs->trans('NoExample');
}
{
global $langs;
$langs->load('cashdesk@cashdesk');
return $langs->trans('NoExample');
}
/**
* Checks if the numbers already in the database do not
@ -82,20 +82,20 @@ abstract class ModeleNumRefTakepos
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
/**
* Renvoi prochaine valeur attribuee
*
* @return string Valeur
*/
public function getNextValue()
{
global $langs;
return $langs->trans('NotAvailable');
}
{
global $langs;
return $langs->trans('NotAvailable');
}
/**
* Renvoi version du modele de numerotation
@ -103,14 +103,14 @@ abstract class ModeleNumRefTakepos
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans('VersionDevelopment');
if ($this->version == 'experimental') return $langs->trans('VersionExperimental');
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans('NotAvailable');
}
if ($this->version == 'development') return $langs->trans('VersionDevelopment');
if ($this->version == 'experimental') return $langs->trans('VersionExperimental');
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans('NotAvailable');
}
}

View File

@ -30,20 +30,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/ticket/modules_ticket.php';
*/
class mod_ticket_simple extends ModeleNumRefTicket
{
/**
* Dolibarr version of the loaded document
* @var string
*/
/**
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'TS';
public $prefix = 'TS';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
/**
* @var string Nom du modele
* @deprecated
* @see $name
@ -55,108 +55,108 @@ class mod_ticket_simple extends ModeleNumRefTicket
*/
public $name='Simple';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix . "0501-0001";
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
public function getExample()
{
return $this->prefix . "0501-0001";
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf, $langs, $db;
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
global $conf, $langs, $db;
$coyymm = '';
$max = '';
$coyymm = '';
$max = '';
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) {
$coyymm = substr($row[0], 0, 6);
$max = $row[0];
}
}
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
}
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$row = $db->fetch_row($resql);
if ($row) {
$coyymm = substr($row[0], 0, 6);
$max = $row[0];
}
}
if (!$coyymm || preg_match('/' . $this->prefix . '[0-9][0-9][0-9][0-9]/i', $coyymm)) {
return true;
} else {
$langs->load("errors");
$this->error = $langs->trans('ErrorNumRefModel', $max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $ticket Object ticket
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $ticket)
{
global $db, $conf;
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Project $ticket Object ticket
* @return string Value if OK, 0 if KO
*/
public function getNextValue($objsoc, $ticket)
{
global $db, $conf;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
// D'abord on recupere la valeur max
$posindice = 8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM " . $posindice . ") AS SIGNED)) as max";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket";
$search = $this->prefix . "____-%";
$sql .= " WHERE ref LIKE '" . $search ."'";
$sql .= " AND entity = " . $conf->entity;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
return -1;
}
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$max = intval($obj->max);
} else {
$max = 0;
}
} else {
dol_syslog("mod_ticket_simple::getNextValue", LOG_DEBUG);
return -1;
}
$date = empty($ticket->datec) ? dol_now() : $ticket->datec;
$date = empty($ticket->datec) ? dol_now() : $ticket->datec;
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m", $date);
//$yymm = strftime("%y%m",time());
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;
} // If counter > 9999, we do not format on 4 chars, we take number as it is
else {
$num = sprintf("%04s", $max + 1);
}
if ($max >= (pow(10, 4) - 1)) {
$num = $max + 1;
} // If counter > 9999, we do not format on 4 chars, we take number as it is
else {
$num = sprintf("%04s", $max + 1);
}
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
return $this->prefix . $yymm . "-" . $num;
}
dol_syslog("mod_ticket_simple::getNextValue return " . $this->prefix . $yymm . "-" . $num);
return $this->prefix . $yymm . "-" . $num;
}
}

View File

@ -29,95 +29,95 @@
*/
abstract class ModeleNumRefTicket
{
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* @var string Error code (or message)
*/
public $error = '';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
public function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoDescription");
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
public function info()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoDescription");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoExample");
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $langs;
$langs->load("ticket");
return $langs->trans("NoExample");
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @return boolean false if conflict, true if ok
*/
public function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Valeur
*/
public function getNextValue($objsoc, $project)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Project $project Object project
* @return string Valeur
*/
public function getNextValue($objsoc, $project)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
public function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'development') {
return $langs->trans("VersionDevelopment");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'experimental') {
return $langs->trans("VersionExperimental");
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version == 'dolibarr') {
return DOL_VERSION;
}
if ($this->version) {
return $this->version;
}
if ($this->version) {
return $this->version;
}
return $langs->trans("NotAvailable");
}
return $langs->trans("NotAvailable");
}
}

View File

@ -28,8 +28,8 @@
// Protection to avoid direct call of template
if (empty($conf) || ! is_object($conf)) {
print "Error, template page can't be called as URL";
exit;
print "Error, template page can't be called as URL";
exit;
}
@ -54,7 +54,7 @@ if ($action == 'presend')
}
else
{
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
}
$file = $fileparams['fullname'];
@ -102,11 +102,11 @@ if ($action == 'presend')
}
if ($object->element == 'invoice_supplier')
{
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
$fileparams = dol_most_recent_file($diroutput . '/' . get_exdir($object->id, 2, 0, 0, $object, $object->element).$ref, preg_quote($ref, '/').'([^\-])+');
}
else
{
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
$fileparams = dol_most_recent_file($diroutput . '/' . $ref, preg_quote($ref, '/').'[^\-]+');
}
$file = $fileparams['fullname'];
@ -212,51 +212,51 @@ if ($action == 'presend')
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
// Find the good contact address
$tmpobject = $object;
if (($object->element == 'shipping'|| $object->element == 'reception')) {
$origin = $object->origin;
$origin_id = $object->origin_id;
$tmpobject = $object;
if (($object->element == 'shipping'|| $object->element == 'reception')) {
$origin = $object->origin;
$origin_id = $object->origin_id;
if (!empty($origin) && !empty($origin_id)) {
$element = $subelement = $origin;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
}
if ($element == 'order_supplier') {
$element = 'fourn';
$subelement = 'fournisseur.commande';
}
if ($element == 'project') {
$element = 'projet';
}
if (!empty($origin) && !empty($origin_id)) {
$element = $subelement = $origin;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal';
$subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
if ($element == 'inter') {
$element = $subelement = 'ficheinter';
}
if ($element == 'shipping') {
$element = $subelement = 'expedition';
}
if ($element == 'order_supplier') {
$element = 'fourn';
$subelement = 'fournisseur.commande';
}
if ($element == 'project') {
$element = 'projet';
}
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($origin_id);
dol_include_once('/' . $element . '/class/' . $subelement . '.class.php');
$classname = ucfirst($origin);
$objectsrc = new $classname($db);
$objectsrc->fetch($origin_id);
$tmpobject = $objectsrc;
}
}
$tmpobject = $objectsrc;
}
}
$custcontact = '';
$contactarr = array();
@ -264,11 +264,11 @@ if ($action == 'presend')
if (is_array($contactarr) && count($contactarr) > 0) {
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
$contactstatic = new Contact($db);
$contactstatic = new Contact($db);
foreach ($contactarr as $contact) {
$contactstatic->fetch($contact['id']);
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
$contactstatic->fetch($contact['id']);
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
}
}

View File

@ -33,6 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
// Load translation files required by the page
$langs->loadLangs(array("sendings", "deliveries", 'companies', 'bills'));
@ -89,6 +90,7 @@ $viewstatut = GETPOST('viewstatut');
$diroutputmassaction = $conf->expedition->dir_output.'/sending/temp/massgeneration/'.$user->id;
$object = new Expedition($db);
$form = new Form($db);
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('shipmentlist'));
@ -118,6 +120,7 @@ $arrayfields = array(
'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0),
'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers),
'e.date_delivery'=>array('label'=>$langs->trans("DateDeliveryPlanned"), 'checked'=>1),
'e.weight'=>array('label'=>$langs->trans("Weight"), 'checked'=>0),
'e.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
'e.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
'e.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
@ -183,13 +186,13 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
if (empty($reshook))
{
$objectclass = 'Expedition';
$objectlabel = 'Sendings';
$permissiontoread = $user->rights->expedition->lire;
$permissiontoadd = $user->rights->expedition->creer;
$permissiontodelete = $user->rights->expedition->supprimer;
$uploaddir = $conf->expedition->dir_output.'/sending';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
$objectclass = 'Expedition';
$objectlabel = 'Sendings';
$permissiontoread = $user->rights->expedition->lire;
$permissiontoadd = $user->rights->expedition->creer;
$permissiontodelete = $user->rights->expedition->supprimer;
$uploaddir = $conf->expedition->dir_output.'/sending';
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@ -211,7 +214,7 @@ llxHeader('', $langs->trans('ListOfSendings'), $helpurl);
$sql = 'SELECT';
if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
$sql .= " e.rowid, e.ref, e.ref_customer, e.date_expedition as date_expedition, e.weight, e.weight_units, e.date_delivery as date_livraison, l.date_delivery as date_reception, e.fk_statut, e.billed,";
$sql .= " s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client, ";
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
@ -313,7 +316,7 @@ if ($resql)
{
$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
$arrayofselected = is_array($toselect) ? $toselect : array();
$expedition = new Expedition($db);
@ -341,18 +344,18 @@ if ($resql)
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
$arrayofmassactions = array(
'builddoc' => $langs->trans("PDFMerge"),
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
'presend' => $langs->trans("SendByMail"),
);
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$arrayofmassactions = array(
'builddoc' => $langs->trans("PDFMerge"),
//'classifyclose'=>$langs->trans("Close"), TODO massive close shipment ie: when truck is charged
'presend' => $langs->trans("SendByMail"),
);
if (in_array($massaction, array('presend'))) $arrayofmassactions = array();
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
$newcardbutton = '';
if ($user->rights->expedition->creer)
{
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewSending'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/expedition/card.php?action=create2');
}
$i = 0;
@ -367,11 +370,11 @@ if ($resql)
print_barre_liste($langs->trans('ListOfSendings'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, $newcardbutton, '', $limit);
$topicmail = "SendShippingRef";
$modelmail = "shipping_send";
$objecttmp = new Expedition($db);
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
$topicmail = "SendShippingRef";
$modelmail = "shipping_send";
$objecttmp = new Expedition($db);
$trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($sall)
{
@ -483,6 +486,13 @@ if ($resql)
print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
print '</td>';
}
// Weight
if (!empty($arrayfields['e.weight']['checked']))
{
print '<td class="liste_titre maxwidthonsmartphone center">';
print '</td>';
}
// Date delivery planned
if (!empty($arrayfields['e.date_delivery']['checked']))
{
@ -567,6 +577,7 @@ if ($resql)
if (!empty($arrayfields['state.nom']['checked'])) print_liste_field_titre($arrayfields['state.nom']['label'], $_SERVER["PHP_SELF"], "state.nom", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['e.weight']['checked'])) print_liste_field_titre($arrayfields['e.weight']['label'], $_SERVER["PHP_SELF"], "e.weight", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['e.date_delivery']['checked'])) print_liste_field_titre($arrayfields['e.date_delivery']['label'], $_SERVER["PHP_SELF"], "e.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
if (!empty($arrayfields['l.ref']['checked'])) print_liste_field_titre($arrayfields['l.ref']['label'], $_SERVER["PHP_SELF"], "l.ref", "", $param, '', $sortfield, $sortorder);
if (!empty($arrayfields['l.date_delivery']['checked'])) print_liste_field_titre($arrayfields['l.date_delivery']['label'], $_SERVER["PHP_SELF"], "l.date_delivery", "", $param, '', $sortfield, $sortorder, 'center ');
@ -583,7 +594,7 @@ if ($resql)
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
print "</tr>\n";
$typenArray = $formcompany->typent_array(1);
$typenArray = $formcompany->typent_array(1);
$i = 0;
$totalarray = array();
while ($i < min($num, $limit))
@ -597,7 +608,8 @@ if ($resql)
$companystatic->ref = $obj->name;
$companystatic->name = $obj->name;
$object = new Expedition($db);
$object->fetch($obj->rowid);
print '<tr class="oddeven">';
// Ref
@ -665,7 +677,24 @@ if ($resql)
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Weight
if (!empty($arrayfields['e.weight']['checked']))
{
print '<td class="center">';
if (empty($object->trueWeight))
{
$tmparray = $object->getTotalWeightVolume();
print showDimensionInBestUnit($tmparray['weight'], 0, "weight", $langs, isset($conf->global->MAIN_WEIGHT_DEFAULT_ROUND)?$conf->global->MAIN_WEIGHT_DEFAULT_ROUND:-1, isset($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?$conf->global->MAIN_WEIGHT_DEFAULT_UNIT:'no');
print $form->textwithpicto('', $langs->trans('EstimatedWeight'), 1);
}
else
{
print $object->trueWeight;
print ($object->trueWeight && $object->weight_units!='')?' '.measuringUnitString(0, "weight", $object->weight_units):'';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
}
// Date delivery planed
if (!empty($arrayfields['e.date_delivery']['checked']))
{
@ -736,48 +765,48 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
// Action column
print '<td class="nowrap" align="center">';
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($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
// Action column
print '<td class="nowrap" align="center">';
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($obj->rowid, $arrayofselected)) $selected = 1;
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
}
print '</td>';
if (!$i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
}
$db->free($resql);
$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>";
print "</div>";
print '</form>';
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
$hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
// Show list of available documents
$urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource .= str_replace('&amp;', '&', $param);
$filedir = $diroutputmassaction;
$genallowed = $user->rights->expedition->lire;
$delallowed = $user->rights->expedition->creer;
$title = '';
$filedir = $diroutputmassaction;
$genallowed = $user->rights->expedition->lire;
$delallowed = $user->rights->expedition->creer;
$title = '';
print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
print $formfile->showdocuments('massfilesarea_sendings', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty);
}
else
{
dol_print_error($db);
dol_print_error($db);
}
// End of page

View File

@ -159,7 +159,7 @@ SeeReportInBookkeepingMode=See <b>%sBookeeping report%s</b> for a calculation on
RulesAmountWithTaxIncluded=- Amounts shown are with all taxes included
RulesResultDue=- It includes outstanding invoices, expenses, VAT, donations whether they are paid or not. Is also includes paid salaries.<br>- It is based on the validation date of invoices and VAT and on the due date for expenses. For salaries defined with Salary module, the value date of payment is used.
RulesResultInOut=- It includes the real payments made on invoices, expenses, VAT and salaries. <br>- It is based on the payment dates of the invoices, expenses, VAT and salaries. The donation date for donation.
RulesCADue=- It includes the customer's due invoices whether they are paid or not. <br>- It is based on the validation date of these invoices.<br>
RulesCADue=- It includes the customer's due invoices whether they are paid or not. <br>- It is based on the invoice date of these invoices.<br>
RulesCAIn=- It includes all the effective payments of invoices received from customers.<br>- It is based on the payment date of these invoices<br>
RulesCATotalSaleJournal=It includes all credit lines from the Sale journal.
RulesAmountOnInOutBookkeepingRecord=It includes record in your Ledger with accounting accounts that has the group "EXPENSE" or "INCOME"
@ -254,4 +254,11 @@ ByVatRate=By sale tax rate
TurnoverbyVatrate=Turnover invoiced by sale tax rate
TurnoverCollectedbyVatrate=Turnover collected by sale tax rate
PurchasebyVatrate=Purchase by sale tax rate
LabelToShow=Short label
LabelToShow=Short label
PurchaseTurnover=Purchase turnover
PurchaseTurnoverCollected=Purchase turnover collected
RulesPurchaseTurnoverDue=- It includes the supplier's due invoices whether they are paid or not. <br>- It is based on the invoice date of these invoices.<br>
RulesPurchaseTurnoverIn=- It includes all the effective payments of invoices done to suppliers.<br>- It is based on the payment date of these invoices<br>
RulesPurchaseTurnoverTotalPurchaseJournal=It includes all debit lines from the purchase journal.
ReportPurchaseTurnover=Purchase turnover invoiced
ReportPurchaseTurnoverCollected=Purchase turnover collected

File diff suppressed because it is too large Load Diff

View File

@ -35,9 +35,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
class mod_myobject_advanced extends ModeleNumRefMyObject
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
/**
@ -51,14 +51,14 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
public $name = 'advanced';
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
/**
* Returns the description of the numbering model
*
* @return string Texte descripif
*/
public function info()
{
global $conf, $langs, $db;
$langs->load("bills");
@ -89,28 +89,28 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$texte .= '</form>';
return $texte;
}
}
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
/**
* Return an example of numbering
*
* @return string Example
*/
public function getExample()
{
global $conf, $langs, $mysoc;
$object = new MyObject($this->db);
$object->initAsSpecimen();
$object = new MyObject($this->db);
$object->initAsSpecimen();
/*$old_code_client = $mysoc->code_client;
/*$old_code_client = $mysoc->code_client;
$old_code_type = $mysoc->typent_code;
$mysoc->code_client = 'CCCCCCCCCC';
$mysoc->typent_code = 'TTTTTTTTTT';*/
$numExample = $this->getNextValue($object);
$numExample = $this->getNextValue($object);
/*$mysoc->code_client = $old_code_client;
/*$mysoc->code_client = $old_code_client;
$mysoc->typent_code = $old_code_type;*/
if (!$numExample)
@ -118,7 +118,7 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
$numExample = $langs->trans('NotConfigured');
}
return $numExample;
}
}
/**
* Return next free value
@ -126,8 +126,8 @@ class mod_myobject_advanced extends ModeleNumRefMyObject
* @param Object $object Object we need next value for
* @return string Value if KO, <0 if KO
*/
public function getNextValue($object)
{
public function getNextValue($object)
{
global $db, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';

View File

@ -31,9 +31,9 @@ dol_include_once('/mymodule/core/modules/mymodule/modules_myobject.php');
class mod_myobject_standard extends ModeleNumRefMyObject
{
/**
* Dolibarr version of the loaded document
* @var string
*/
* Dolibarr version of the loaded document
* @var string
*/
public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr'
public $prefix = 'MYOBJECT';
@ -49,16 +49,16 @@ class mod_myobject_standard extends ModeleNumRefMyObject
public $name = 'standard';
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
* Return description of numbering module
*
* @return string Text with description
*/
public function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc", $this->prefix);
}
/**
@ -73,8 +73,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok
@ -151,8 +151,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
$date = $object->date_creation;
$yymm = strftime("%y%m", $date);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
if ($max >= (pow(10, 4) - 1)) $num = $max + 1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s", $max + 1);
dol_syslog("mod_myobject_standard::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;

View File

@ -38,17 +38,17 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
abstract class ModelePDFMyObject extends CommonDocGenerator
{
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param integer $maxfilenamelength Max length of value to show
* @return array List of templates
*/
public static function liste_modeles($db, $maxfilenamelength = 0)
{
// phpcs:enable
// phpcs:enable
global $conf;
$type = 'mymodule_myobject';
@ -109,7 +109,7 @@ abstract class ModeleNumRefMyObject
/**
* Checks if the numbers already in the database do not
* cause conflicts that would prevent this numbering working.
* cause conflicts that would prevent this numbering working.
*
* @param Object $object Object we need next value for
* @return boolean false if conflict, true if ok

View File

@ -870,11 +870,13 @@ if ($conf->global->TAKEPOS_BAR_RESTAURANT)
{
$menus[$r++] = array('title'=>$langs->trans("Order"), 'action'=>'TakeposPrintingOrder();');
}
//add temp ticket button
//Button to print receipt before payment
if ($conf->global->TAKEPOS_BAR_RESTAURANT)
{
if ($conf->global->TAKEPOS_PRINT_METHOD == "takeposconnector") {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'TakeposPrinting(placeid);');
} elseif ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'DolibarrTakeposPrinting(placeid);');
} else {
$menus[$r++] = array('title'=>'<span class="fa fa-receipt paddingrightonly"></span><div class="trunc">'.$langs->trans("Receipt").'</div>', 'action'=>'Print(placeid);');
}

View File

@ -201,7 +201,7 @@ $sql = "SELECT DISTINCT u.rowid, u.lastname, u.firstname, u.admin, u.fk_soc, u.l
$sql .= " u.datelastlogin, u.datepreviouslogin,";
$sql .= " u.ldap_sid, u.statut, u.entity,";
$sql .= " u.tms as date_update, u.datec as date_creation,";
$sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2,";
$sql .= " u2.rowid as id2, u2.login as login2, u2.firstname as firstname2, u2.lastname as lastname2, u2.admin as admin2, u2.fk_soc as fk_soc2, u2.email as email2, u2.gender as gender2, u2.photo as photo2, u2.entity as entity2, u2.statut as statut2,";
$sql .= " s.nom as name, s.canvas";
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@ -625,6 +625,7 @@ while ($i < min($num, $limit))
$user2->admin = $obj->admin2;
$user2->email = $obj->email2;
$user2->socid = $obj->fk_soc2;
$user2->statut = $obj->statut2;
print $user2->getNomUrl(-1, '', 0, 0, 24, 0, '', '', 1);
if (!empty($conf->multicompany->enabled) && $obj->admin2 && !$obj->entity2)
{