Merge github.com:Dolibarr/dolibarr into dev_add_dict_NatureOfProductType
This commit is contained in:
commit
bcb98d1d67
@ -558,13 +558,13 @@ $langs->load("companies");
|
|||||||
|
|
||||||
// Managing Director(s)
|
// Managing Director(s)
|
||||||
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="director">'.$langs->trans("ManagingDirectors").'</label></td><td>';
|
||||||
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="director" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS).'"></td></tr>';
|
print '<input name="MAIN_INFO_SOCIETE_MANAGERS" id="directors" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_MANAGERS).'"></td></tr>';
|
||||||
|
|
||||||
// GDPR contact
|
// GDPR contact
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
|
print $form->textwithpicto($langs->trans("GDPRContact"), $langs->trans("GDPRContactDesc"));
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print '<input name="MAIN_INFO_GDPR" id="director" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_GDPR).'"></td></tr>';
|
print '<input name="MAIN_INFO_GDPR" id="infodirector" class="minwidth500" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_GDPR).'"></td></tr>';
|
||||||
|
|
||||||
// Capital
|
// Capital
|
||||||
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
|
print '<tr class="oddeven"><td><label for="capital">'.$langs->trans("Capital").'</label></td><td>';
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
* Copyright (C) 2011-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
||||||
|
* Copyright (C) 2020 Tobias Sekan <tobias.sekan@startmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -19,12 +20,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/compta/tva/list.php
|
* \file htdocs/compta/tva/list.php
|
||||||
* \ingroup tax
|
* \ingroup tax
|
||||||
* \brief List of VAT payments
|
* \brief List of VAT payments
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
$socid = GETPOST('socid', 'int');
|
||||||
|
if ($user->socid) $socid = $user->socid;
|
||||||
|
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
@ -34,61 +41,79 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
|
|||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('compta', 'bills'));
|
$langs->loadLangs(array('compta', 'bills'));
|
||||||
|
|
||||||
// Security check
|
$action = GETPOST('action', 'alpha');
|
||||||
$socid = GETPOST('socid', 'int');
|
$massaction = GETPOST('massaction', 'alpha');
|
||||||
if ($user->socid) $socid = $user->socid;
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
$optioncss = GETPOST('optioncss', 'alpha');
|
||||||
|
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'salestaxeslist';
|
||||||
|
|
||||||
$search_ref = GETPOST('search_ref', 'int');
|
$search_ref = GETPOST('search_ref', 'alpha');
|
||||||
$search_label = GETPOST('search_label', 'alpha');
|
$search_label = GETPOST('search_label', 'alpha');
|
||||||
$search_account = GETPOST('search_account', 'int');
|
$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
|
||||||
$search_dateend_start = dol_mktime(0, 0, 0, GETPOST('search_dateend_startmonth', 'int'), GETPOST('search_dateend_startday', 'int'), GETPOST('search_dateend_startyear', 'int'));
|
$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
|
||||||
$search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', 'int'), GETPOST('search_dateend_endday', 'int'), GETPOST('search_dateend_endyear', 'int'));
|
$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int'));
|
||||||
$search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int'));
|
$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int'));
|
||||||
$search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int'));
|
$search_type = GETPOST('search_type', 'int');
|
||||||
$search_amount = GETPOST('search_amount', 'alpha');
|
$search_cheque = GETPOST('search_cheque', 'alpha');
|
||||||
$month = GETPOST("month", "int");
|
$search_account = GETPOST('search_account', 'int');
|
||||||
$year = GETPOST("year", "int");
|
$search_amount = GETPOST('search_amount', 'alpha');
|
||||||
|
|
||||||
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST('sortfield', 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST('sortorder', 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST('page', 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
|
||||||
|
if (empty($page) || $page == -1) $page = 0; // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortfield) $sortfield = "t.datev";
|
|
||||||
if (!$sortorder) $sortorder = "DESC";
|
|
||||||
|
|
||||||
$filtre = $_GET["filtre"];
|
if (!$sortfield) $sortfield = 't.datev';
|
||||||
|
if (!$sortorder) $sortorder = 'DESC';
|
||||||
|
|
||||||
if (empty($_REQUEST['typeid']))
|
$arrayfields = array(
|
||||||
{
|
't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",),
|
||||||
$newfiltre = str_replace('filtre=', '', $filtre);
|
't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"),
|
||||||
$filterarray = explode('-', $newfiltre);
|
't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"),
|
||||||
foreach ($filterarray as $val)
|
't.datep' =>array('checked'=>1, 'position'=>40, 'label'=>"DatePayment"),
|
||||||
|
't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"Type"),
|
||||||
|
't.num_payment' =>array('checked'=>1, 'position'=>60, 'label'=>"Numero", 'tooltip'=>"ChequeOrTransferNumber"),
|
||||||
|
'transaction' =>array('checked'=>1, 'position'=>70, 'label'=>"BankTransactionLine", 'enabled'=>(!empty($conf->banque->enabled))),
|
||||||
|
'ba.label' =>array('checked'=>1, 'position'=>80, 'label'=>"Account", 'enable'=>(!empty($conf->banque->enabled))),
|
||||||
|
't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"PayedByThisPayment"),
|
||||||
|
);
|
||||||
|
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
|
$hookmanager->initHooks(array('salestaxeslist'));
|
||||||
|
$object = new Tva($db);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
$parameters = array('socid'=>$socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
|
||||||
|
if (empty($reshook)) {
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
|
||||||
|
|
||||||
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
||||||
{
|
{
|
||||||
$part = explode(':', $val);
|
$search_ref = '';
|
||||||
if ($part[0] == 't.fk_typepayment') $typeid = $part[1];
|
$search_label = '';
|
||||||
|
$search_dateend_start = '';
|
||||||
|
$search_dateend_end = '';
|
||||||
|
$search_datepayment_start = '';
|
||||||
|
$search_datepayment_end = '';
|
||||||
|
$search_type = '';
|
||||||
|
$search_cheque = '';
|
||||||
|
$search_account = '';
|
||||||
|
$search_amount = '';
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$typeid = $_REQUEST['typeid'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
|
||||||
{
|
|
||||||
$search_ref = "";
|
|
||||||
$search_label = "";
|
|
||||||
$search_dateend_start = '';
|
|
||||||
$search_dateend_end = '';
|
|
||||||
$search_datepayment_start = '';
|
|
||||||
$search_datepayment_end = '';
|
|
||||||
$search_account = '';
|
|
||||||
$search_amount = "";
|
|
||||||
$year = "";
|
|
||||||
$month = "";
|
|
||||||
$typeid = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,194 +121,325 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
llxHeader('', $langs->trans("VATPayments"));
|
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formother = new FormOther($db);
|
$formother = new FormOther($db);
|
||||||
$tva_static = new Tva($db);
|
$tva_static = new Tva($db);
|
||||||
$bankstatic = new Account($db);
|
$bankstatic = new Account($db);
|
||||||
|
$accountingjournal = new AccountingJournal($db);
|
||||||
|
$bankline = new AccountLine($db);
|
||||||
|
|
||||||
|
llxHeader('', $langs->trans("VATPayments"));
|
||||||
|
|
||||||
|
$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank';
|
||||||
|
$sql .= ', ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel';
|
||||||
|
$sql .= ', pst.code as payment_code';
|
||||||
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t';
|
||||||
|
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON t.fk_typepayment = pst.id';
|
||||||
|
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
|
||||||
|
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
|
||||||
|
$sql .= ' WHERE t.entity IN ('.getEntity($object->element).')';
|
||||||
|
|
||||||
|
if (!empty($search_ref)) $sql .= natural_search('t.rowid', $search_ref);
|
||||||
|
if (!empty($search_label)) $sql .= natural_search('t.label', $search_label);
|
||||||
|
if (!empty($search_dateend_start)) $sql .= ' AND t.datev >= "'.$db->idate($search_dateend_start).'"';
|
||||||
|
if (!empty($search_dateend_end)) $sql .= ' AND t.datev <= "'.$db->idate($search_dateend_end).'"';
|
||||||
|
if (!empty($search_datepayment_start)) $sql .= ' AND t.datep >= "'.$db->idate($search_datepayment_start).'"';
|
||||||
|
if (!empty($search_datepayment_end)) $sql .= ' AND t.datep <= "'.$db->idate($search_datepayment_end).'"';
|
||||||
|
if (!empty($search_type) && $search_type > 0) $sql .= ' AND t.fk_typepayment='.$search_type;
|
||||||
|
if (!empty($search_cheque)) $sql .= natural_search('t.num_payment', $search_cheque);
|
||||||
|
if (!empty($search_account) && $search_account > 0) $sql .= ' AND b.fk_account='.$search_account;
|
||||||
|
if (!empty($search_amount)) $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1);
|
||||||
|
|
||||||
$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,";
|
|
||||||
$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
|
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id";
|
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
|
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid";
|
|
||||||
$sql .= " WHERE t.entity IN (".getEntity('tax').")";
|
|
||||||
if ($search_ref) $sql .= natural_search("t.rowid", $search_ref);
|
|
||||||
if ($search_label) $sql .= natural_search("t.label", $search_label);
|
|
||||||
if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account;
|
|
||||||
if ($search_amount) $sql .= natural_search("t.amount", price2num(trim($search_amount)), 1);
|
|
||||||
if ($search_dateend_start) $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'";
|
|
||||||
if ($search_dateend_end) $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'";
|
|
||||||
if ($search_datepayment_start) $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'";
|
|
||||||
if ($search_datepayment_end) $sql .= " AND t.datep <= '".$db->idate($search_datepayment_end)."'";
|
|
||||||
if ($filtre) {
|
|
||||||
$filtre = str_replace(":", "=", $filtre);
|
|
||||||
$sql .= " AND ".$filtre;
|
|
||||||
}
|
|
||||||
if ($typeid) {
|
|
||||||
$sql .= " AND t.fk_typepayment=".$typeid;
|
|
||||||
}
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
$totalnboflines = 0;
|
|
||||||
$result = $db->query($sql);
|
$nbtotalofrecords = '';
|
||||||
if ($result)
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
{
|
$result = $db->query($sql);
|
||||||
$totalnboflines = $db->num_rows($result);
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
|
|
||||||
|
// if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
|
if (($page * $limit) > $nbtotalofrecords) {
|
||||||
|
$page = 0;
|
||||||
|
$offset = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
dol_print_error($db);
|
||||||
$i = 0;
|
llxFooter();
|
||||||
$total = 0;
|
$db->close();
|
||||||
|
exit;
|
||||||
$param = '';
|
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage;
|
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
|
||||||
if ($typeid) $param .= '&typeid='.$typeid;
|
|
||||||
|
|
||||||
$url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
|
|
||||||
if (!empty($socid)) $url .= '&socid='.$socid;
|
|
||||||
$newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
|
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
|
||||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
|
||||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
|
||||||
|
|
||||||
print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
|
||||||
|
|
||||||
print '<div class="div-table-responsive">';
|
|
||||||
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
|
|
||||||
|
|
||||||
print '<tr class="liste_titre_filter">';
|
|
||||||
// Ref
|
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
|
|
||||||
// Label
|
|
||||||
print '<td class="liste_titre"><input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'"></td>';
|
|
||||||
// Date end period
|
|
||||||
print '<td class="liste_titre center">';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
|
||||||
print '</div>';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
|
||||||
print '</div>';
|
|
||||||
// Date payment
|
|
||||||
print '<td class="liste_titre center">';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('From'));
|
|
||||||
print '</div>';
|
|
||||||
print '<div class="nowrap">';
|
|
||||||
print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans('to'));
|
|
||||||
print '</div>';
|
|
||||||
// Type
|
|
||||||
print '<td class="liste_titre left">';
|
|
||||||
$form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16);
|
|
||||||
print '</td>';
|
|
||||||
// Account
|
|
||||||
if (!empty($conf->banque->enabled))
|
|
||||||
{
|
|
||||||
print '<td class="liste_titre">';
|
|
||||||
$form->select_comptes($search_account, 'search_account', 0, '', 1);
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
// Amount
|
|
||||||
print '<td class="liste_titre right"><input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'"></td>';
|
|
||||||
print '<td class="liste_titre maxwidthsearch">';
|
|
||||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
|
||||||
print $searchpicto;
|
|
||||||
print '</td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "t.rowid", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "t.label", "", $param, 'align="left"', $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "t.datev", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "t.datep", "", $param, 'align="center"', $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left ');
|
|
||||||
if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder);
|
|
||||||
print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "t.amount", "", $param, '', $sortfield, $sortorder, 'right ');
|
|
||||||
print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch ');
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
while ($i < min($num, $limit))
|
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($result);
|
|
||||||
|
|
||||||
if ($obj->payment_code <> '')
|
|
||||||
{
|
|
||||||
$type = '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.'</td>';
|
|
||||||
} else {
|
|
||||||
$type = '<td> </td>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
|
||||||
|
|
||||||
$tva_static->id = $obj->rowid;
|
|
||||||
$tva_static->ref = $obj->rowid;
|
|
||||||
|
|
||||||
// Ref
|
|
||||||
print "<td>".$tva_static->getNomUrl(1)."</td>\n";
|
|
||||||
// Label
|
|
||||||
print "<td>".dol_trunc($obj->label, 40)."</td>\n";
|
|
||||||
// Date end period
|
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day')."</td>\n";
|
|
||||||
// Date payment
|
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day')."</td>\n";
|
|
||||||
// Type
|
|
||||||
print $type;
|
|
||||||
// Account
|
|
||||||
if (!empty($conf->banque->enabled))
|
|
||||||
{
|
|
||||||
print '<td>';
|
|
||||||
if ($obj->fk_bank > 0)
|
|
||||||
{
|
|
||||||
$bankstatic->id = $obj->bid;
|
|
||||||
$bankstatic->ref = $obj->bref;
|
|
||||||
$bankstatic->number = $obj->bnumber;
|
|
||||||
$bankstatic->account_number = $obj->account_number;
|
|
||||||
|
|
||||||
$accountingjournal = new AccountingJournal($db);
|
|
||||||
$accountingjournal->fetch($obj->fk_accountancy_journal);
|
|
||||||
$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
|
|
||||||
|
|
||||||
$bankstatic->label = $obj->blabel;
|
|
||||||
print $bankstatic->getNomUrl(1);
|
|
||||||
} else print ' ';
|
|
||||||
print '</td>';
|
|
||||||
}
|
|
||||||
// Amount
|
|
||||||
$total = $total + $obj->amount;
|
|
||||||
print '<td class="nowrap right">'.price($obj->amount)."</td>";
|
|
||||||
print "<td> </td>";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$colspan = 5;
|
|
||||||
if (!empty($conf->banque->enabled)) $colspan++;
|
|
||||||
print '<tr class="liste_total"><td colspan="'.$colspan.'">'.$langs->trans("Total").'</td>';
|
|
||||||
print '<td class="right">'.price($total).'</td>';
|
|
||||||
print "<td> </td></tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
print '</div>';
|
|
||||||
|
|
||||||
print '</form>';
|
|
||||||
|
|
||||||
$db->free($result);
|
|
||||||
} else {
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
|
||||||
|
$param = '';
|
||||||
|
if (!empty($contextpage) && $contextpage != $_SERVER['PHP_SELF']) $param .= '&contextpage='.$contextpage;
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit;
|
||||||
|
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
|
||||||
|
if (!empty($search_ref)) $param .= '&search_ref="'.$search_ref.'"';
|
||||||
|
if (!empty($search_label)) $param .= '&search_label="'.$search_label.'"';
|
||||||
|
if (!empty($search_dateend_start)) $param .= '&search_dateend_startyear='.GETPOST('search_dateend_startyear', 'int');
|
||||||
|
if (!empty($search_dateend_start)) $param .= '&search_dateend_startmonth='.GETPOST('search_dateend_startmonth', 'int');
|
||||||
|
if (!empty($search_dateend_start)) $param .= '&search_dateend_startday='.GETPOST('search_dateend_startday', 'int');
|
||||||
|
if (!empty($search_dateend_end)) $param .= '&search_dateend_endyear='.GETPOST('search_dateend_endyear', 'int');
|
||||||
|
if (!empty($search_dateend_end)) $param .= '&search_dateend_endmonth='.GETPOST('search_dateend_endmonth', 'int');
|
||||||
|
if (!empty($search_dateend_end)) $param .= '&search_dateend_endday='.GETPOST('search_dateend_endday', 'int');
|
||||||
|
if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startyear='.GETPOST('search_datepayment_startyear', 'int');
|
||||||
|
if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startmonth='.GETPOST('search_datepayment_startmonth', 'int');
|
||||||
|
if (!empty($search_datepayment_start)) $param .= '&search_datepayment_startday='.GETPOST('search_datepayment_startday', 'int');
|
||||||
|
if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endyear='.GETPOST('search_datepayment_endyear', 'int');
|
||||||
|
if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endmonth='.GETPOST('search_datepayment_endmonth', 'int');
|
||||||
|
if (!empty($search_datepayment_end)) $param .= '&search_datepayment_endday='.GETPOST('search_datepayment_endday', 'int');
|
||||||
|
if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.$search_type;
|
||||||
|
if (!empty($search_cheque)) $param .= '&search_cheque="'.$search_cheque.'"';
|
||||||
|
if (!empty($search_account) && $search_account > 0) $param .= '&search_account='.$search_account;
|
||||||
|
if (!empty($search_amount)) $param .= '&search_amount="'.$search_amount.'"';
|
||||||
|
|
||||||
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||||
|
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="action" value="list">';
|
||||||
|
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||||
|
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||||
|
|
||||||
|
$url = DOL_URL_ROOT.'/compta/tva/card.php?action=create';
|
||||||
|
if (!empty($socid)) $url .= '&socid='.$socid;
|
||||||
|
$newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer);
|
||||||
|
print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
|
$varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage;
|
||||||
|
$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
|
||||||
|
if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : '').'">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre_filter">';
|
||||||
|
|
||||||
|
// Filters: Lines (placeholder)
|
||||||
|
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Ref
|
||||||
|
if (!empty($arrayfields['t.rowid']['checked'])) {
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '<input type="text" class="flat" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Label
|
||||||
|
if (!empty($arrayfields['t.label']['checked'])) {
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '<input type="text" class="flat" size="10" name="search_label" value="'.dol_escape_htmltag($search_label).'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Date end period
|
||||||
|
if (!empty($arrayfields['t.datev']['checked'])) {
|
||||||
|
print '<td class="liste_titre center">';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $form->selectDate($search_dateend_start ? $search_dateend_start : -1, 'search_dateend_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
|
||||||
|
print '</div>';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
|
||||||
|
print '</div>';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Date payment
|
||||||
|
if (!empty($arrayfields['t.datep']['checked'])) {
|
||||||
|
print '<td class="liste_titre center">';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
|
||||||
|
print '</div>';
|
||||||
|
print '<div class="nowrap">';
|
||||||
|
print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
|
||||||
|
print '</div>';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Type
|
||||||
|
if (!empty($arrayfields['t.fk_typepayment']['checked'])) {
|
||||||
|
print '<td class="liste_titre left">';
|
||||||
|
$form->select_types_paiements($search_type, 'search_type', '', 0, 1, 1, 16);
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Cheque number
|
||||||
|
if (!empty($arrayfields['t.num_payment']['checked'])) {
|
||||||
|
print '<td class="liste_titre left">';
|
||||||
|
print '<input name="search_cheque" class="flat" type="text" size="8" value="'.$search_cheque.'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Bank transaction number (placeholder)
|
||||||
|
if (!empty($arrayfields['transaction']['checked'])) {
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Bank account
|
||||||
|
if (!empty($arrayfields['ba.label']['checked'])) {
|
||||||
|
print '<td class="liste_titre">';
|
||||||
|
$form->select_comptes($search_account, 'search_account', 0, '', 1);
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter: Amount
|
||||||
|
if (!empty($arrayfields['t.amount']['checked'])) {
|
||||||
|
print '<td class="liste_titre right">';
|
||||||
|
print '<input name="search_amount" class="flat" type="text" size="8" value="'.$search_amount.'">';
|
||||||
|
print '</td>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fields from hook
|
||||||
|
$parameters = array('arrayfields'=>$arrayfields);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
|
// Filter: Buttons
|
||||||
|
print '<td class="liste_titre maxwidthsearch">';
|
||||||
|
print $form->showFilterAndCheckAddButtons(0);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titre('#', $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['t.rowid']['checked'])) print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['t.datev']['checked'])) print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['t.datep']['checked'])) print_liste_field_titre($arrayfields['t.datep']['label'], $_SERVER['PHP_SELF'], 't.datep', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['t.fk_typepayment']['checked'])) print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||||
|
if (!empty($arrayfields['t.num_payment']['checked'])) print_liste_field_titre($arrayfields['t.num_payment']['label'], $_SERVER['PHP_SELF'], 't.num_payment', '', $param, '', $sortfield, $sortorder, '', $arrayfields['t.num_payment']['tooltip']);
|
||||||
|
if (!empty($arrayfields['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder);
|
||||||
|
if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER['PHP_SELF'], 'ba.label', '', $param, '', $sortfield, $sortorder, 'left ');
|
||||||
|
if (!empty($arrayfields['t.amount']['checked'])) print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right ');
|
||||||
|
|
||||||
|
// Hook fields
|
||||||
|
$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
|
||||||
|
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
|
||||||
|
print_liste_field_titre($selectedfields, $_SERVER['PHP_SELF'], '', '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
$totalarray = array();
|
||||||
|
while ($i < min($num, $limit)) {
|
||||||
|
$obj = $db->fetch_object($result);
|
||||||
|
|
||||||
|
$tva_static->id = $obj->rowid;
|
||||||
|
$tva_static->ref = $obj->rowid;
|
||||||
|
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
|
// No
|
||||||
|
if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
|
||||||
|
print '<td>'.(($offset * $limit) + $i).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ref
|
||||||
|
if (!empty($arrayfields['t.rowid']['checked'])) {
|
||||||
|
print '<td>'.$tva_static->getNomUrl(1).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Label
|
||||||
|
if (!empty($arrayfields['t.label']['checked'])) {
|
||||||
|
print '<td>'.dol_trunc($obj->label, 40).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Date end period
|
||||||
|
if (!empty($arrayfields['t.datev']['checked'])) {
|
||||||
|
print '<td class="center">'.dol_print_date($db->jdate($obj->datev), 'day').'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Date payment
|
||||||
|
if (!empty($arrayfields['t.datep']['checked'])) {
|
||||||
|
print '<td class="center">'.dol_print_date($db->jdate($obj->datep), 'day').'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
if (!empty($arrayfields['t.fk_typepayment']['checked']))
|
||||||
|
{
|
||||||
|
print '<td>'.$langs->trans("PaymentTypeShort".$obj->payment_code).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cheque number
|
||||||
|
if (!empty($arrayfields['t.num_payment']['checked'])) {
|
||||||
|
print '<td>'.$obj->num_payment.'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bank transaction
|
||||||
|
if (!empty($arrayfields['transaction']['checked'])) {
|
||||||
|
$bankline->fetch($obj->fk_bank);
|
||||||
|
print '<td>'.$bankline->getNomUrl(1, 0).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Account
|
||||||
|
if (!empty($arrayfields['ba.label']['checked'])) {
|
||||||
|
print '<td>';
|
||||||
|
if ($obj->fk_bank > 0) {
|
||||||
|
$bankstatic->id = $obj->bid;
|
||||||
|
$bankstatic->ref = $obj->bref;
|
||||||
|
$bankstatic->number = $obj->bnumber;
|
||||||
|
$bankstatic->account_number = $obj->account_number;
|
||||||
|
|
||||||
|
$accountingjournal->fetch($obj->fk_accountancy_journal);
|
||||||
|
$bankstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
|
||||||
|
|
||||||
|
$bankstatic->label = $obj->blabel;
|
||||||
|
print $bankstatic->getNomUrl(1);
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Amount
|
||||||
|
$total = $total + $obj->amount;
|
||||||
|
print '<td class="nowrap right">'.price($obj->amount).'</td>';
|
||||||
|
if (!$i) $totalarray['nbfield']++;
|
||||||
|
$totalarray['pos'][$totalarray['nbfield']] = 'amount';
|
||||||
|
$totalarray['val']['amount'] += $objp->amount;
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
print '<td></td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a buttons placeholder for the total line
|
||||||
|
$totalarray['nbfield']++;
|
||||||
|
|
||||||
|
// Show total line
|
||||||
|
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
print '</form>';
|
||||||
|
|
||||||
|
$db->free($result);
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -74,7 +74,7 @@ if ($action == 'add' && !empty($permissiontoadd))
|
|||||||
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
|
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
|
||||||
$value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
|
$value = price2num(GETPOST($key, 'alphanohtml')); // To fix decimal separator according to lang setup
|
||||||
} elseif ($object->fields[$key]['type'] == 'boolean') {
|
} elseif ($object->fields[$key]['type'] == 'boolean') {
|
||||||
$value = (GETPOST($key) == 'on' ? 1 : 0);
|
$value = ((GETPOST($key) == '1' || GETPOST($key) == 'on') ? 1 : 0);
|
||||||
} else {
|
} else {
|
||||||
$value = GETPOST($key, 'alphanohtml');
|
$value = GETPOST($key, 'alphanohtml');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,10 +56,10 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
|
|||||||
|
|
||||||
if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
|
||||||
{
|
{
|
||||||
$result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
|
$result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object);
|
||||||
} elseif (!empty($upload_dir))
|
} elseif (!empty($upload_dir))
|
||||||
{
|
{
|
||||||
$result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
|
$result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs, $object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,7 +235,7 @@ class Conf
|
|||||||
$filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
|
$filesList = explode(":", $this->global->LOCAL_CONSTS_FILES);
|
||||||
foreach ($filesList as $file) {
|
foreach ($filesList as $file) {
|
||||||
$file = dol_sanitizeFileName($file);
|
$file = dol_sanitizeFileName($file);
|
||||||
include_once DOL_DOCUMENT_ROOT."/".$file."/".$file."_consts.php"; // This file can run code like setting $this->global->XXX vars.
|
dol_include_once($file."/".$file."_consts.php"); // This file can run code like setting $this->global->XXX vars.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1506,9 +1506,10 @@ function dol_init_file_process($pathtoscan = '', $trackid = '')
|
|||||||
* @param string $link Link to add (to add a link instead of a file)
|
* @param string $link Link to add (to add a link instead of a file)
|
||||||
* @param string $trackid Track id (used to prefix name of session vars to avoid conflict)
|
* @param string $trackid Track id (used to prefix name of session vars to avoid conflict)
|
||||||
* @param int $generatethumbs 1=Generate also thumbs for uploaded image files
|
* @param int $generatethumbs 1=Generate also thumbs for uploaded image files
|
||||||
|
* @param Object $object Object used to set 'src_object_*' fields
|
||||||
* @return int <=0 if KO, >0 if OK
|
* @return int <=0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null, $trackid = '', $generatethumbs = 1)
|
function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesession = 0, $varfiles = 'addedfile', $savingdocmask = '', $link = null, $trackid = '', $generatethumbs = 1, $object = null)
|
||||||
{
|
{
|
||||||
global $db, $user, $conf, $langs;
|
global $db, $user, $conf, $langs;
|
||||||
|
|
||||||
@ -1602,7 +1603,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite = 0, $donotupdatesess
|
|||||||
// Update index table of files (llx_ecm_files)
|
// Update index table of files (llx_ecm_files)
|
||||||
if ($donotupdatesession == 1)
|
if ($donotupdatesession == 1)
|
||||||
{
|
{
|
||||||
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0);
|
$result = addFileIntoDatabaseIndex($upload_dir, basename($destfile).($resupload == 2 ? '.noexe' : ''), $TFile['name'][$i], 'uploaded', 0, $object);
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
if ($allowoverwrite) {
|
if ($allowoverwrite) {
|
||||||
@ -1718,9 +1719,10 @@ function dol_remove_file_process($filenb, $donotupdatesession = 0, $donotdeletef
|
|||||||
* @param string $fullpathorig Full path of origin for file (can be '')
|
* @param string $fullpathorig Full path of origin for file (can be '')
|
||||||
* @param string $mode How file was created ('uploaded', 'generated', ...)
|
* @param string $mode How file was created ('uploaded', 'generated', ...)
|
||||||
* @param int $setsharekey Set also the share key
|
* @param int $setsharekey Set also the share key
|
||||||
|
* @param Object $object Object used to set 'src_object_*' fields
|
||||||
* @return int <0 if KO, 0 if nothing done, >0 if OK
|
* @return int <0 if KO, 0 if nothing done, >0 if OK
|
||||||
*/
|
*/
|
||||||
function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uploaded', $setsharekey = 0)
|
function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uploaded', $setsharekey = 0, $object = null)
|
||||||
{
|
{
|
||||||
global $db, $user;
|
global $db, $user;
|
||||||
|
|
||||||
@ -1743,6 +1745,12 @@ function addFileIntoDatabaseIndex($dir, $file, $fullpathorig = '', $mode = 'uplo
|
|||||||
$ecmfile->gen_or_uploaded = $mode;
|
$ecmfile->gen_or_uploaded = $mode;
|
||||||
$ecmfile->description = ''; // indexed content
|
$ecmfile->description = ''; // indexed content
|
||||||
$ecmfile->keyword = ''; // keyword content
|
$ecmfile->keyword = ''; // keyword content
|
||||||
|
|
||||||
|
if (is_object($object) && $object->id > 0) {
|
||||||
|
$ecmfile->src_object_id = $object->id;
|
||||||
|
$ecmfile->src_object_type = $object->element;
|
||||||
|
}
|
||||||
|
|
||||||
if ($setsharekey)
|
if ($setsharekey)
|
||||||
{
|
{
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
|
||||||
|
|||||||
@ -2045,13 +2045,12 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array with locale date info.
|
* Return an array with locale date info.
|
||||||
* PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
|
* WARNING: This function use PHP server timezone by default to return locale informations.
|
||||||
* WARNING: This function always use PHP server timezone to return locale informations !!!
|
* Be aware to add the third parameter to "UTC" if you need to work on UTC.
|
||||||
* Usage must be avoid.
|
|
||||||
* FIXME: Replace this with PHP date function and a parameter $gm
|
|
||||||
*
|
*
|
||||||
* @param int $timestamp Timestamp
|
* @param int $timestamp Timestamp
|
||||||
* @param boolean $fast Fast mode
|
* @param boolean $fast Fast mode. deprecated.
|
||||||
|
* @param string $forcetimezone '' to use the PHP server timezone. Or use a form like 'Europe/Paris' or '+0200' to force timezone.
|
||||||
* @return array Array of informations
|
* @return array Array of informations
|
||||||
* If no fast mode:
|
* If no fast mode:
|
||||||
* 'seconds' => $secs,
|
* 'seconds' => $secs,
|
||||||
@ -2061,34 +2060,40 @@ function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlang
|
|||||||
* 'wday' => $dow, 0=sunday, 6=saturday
|
* 'wday' => $dow, 0=sunday, 6=saturday
|
||||||
* 'mon' => $month,
|
* 'mon' => $month,
|
||||||
* 'year' => $year,
|
* 'year' => $year,
|
||||||
* 'yday' => floor($secsInYear/$_day_power),
|
* 'yday' => floor($secsInYear/$_day_power)
|
||||||
* 'weekday' => gmdate('l',$_day_power*(3+$dow)),
|
|
||||||
* 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)),
|
|
||||||
* If fast mode:
|
|
||||||
* 'seconds' => $secs,
|
|
||||||
* 'minutes' => $min,
|
|
||||||
* 'hours' => $hour,
|
|
||||||
* 'mday' => $day,
|
|
||||||
* 'mon' => $month,
|
|
||||||
* 'year' => $year,
|
|
||||||
* 'yday' => floor($secsInYear/$_day_power),
|
|
||||||
* 'leap' => $leaf,
|
|
||||||
* 'ndays' => $ndays
|
|
||||||
* @see dol_print_date(), dol_stringtotime(), dol_mktime()
|
* @see dol_print_date(), dol_stringtotime(), dol_mktime()
|
||||||
*/
|
*/
|
||||||
function dol_getdate($timestamp, $fast = false)
|
function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$usealternatemethod = false;
|
if (empty($conf->global->MAIN_USE_OLD_FUNCTIONS_FOR_GETDATE)) {
|
||||||
if ($timestamp <= 0) $usealternatemethod = true; // <= 1970
|
//$datetimeobj = new DateTime('@'.$timestamp);
|
||||||
if ($timestamp >= 2145913200) $usealternatemethod = true; // >= 2038
|
$datetimeobj = new DateTime();
|
||||||
|
$datetimeobj->setTimestamp($timestamp); // Use local PHP server timezone
|
||||||
if ($usealternatemethod)
|
if ($forcetimezone) $datetimeobj->setTimezone(new DateTimeZone($forcetimezone)); // (add timezone relative to the date entered)
|
||||||
{
|
$arrayinfo = array(
|
||||||
$arrayinfo = adodb_getdate($timestamp, $fast);
|
'year'=>((int) date_format($datetimeobj, 'Y')),
|
||||||
|
'mon'=>((int) date_format($datetimeobj, 'm')),
|
||||||
|
'mday'=>((int) date_format($datetimeobj, 'd')),
|
||||||
|
'wday'=>((int) date_format($datetimeobj, 'w')),
|
||||||
|
'yday'=>((int) date_format($datetimeobj, 'z')),
|
||||||
|
'hours'=>((int) date_format($datetimeobj, 'H')),
|
||||||
|
'minutes'=>((int) date_format($datetimeobj, 'i')),
|
||||||
|
'seconds'=>((int) date_format($datetimeobj, 's'))
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$arrayinfo = getdate($timestamp);
|
// PHP getdate is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
|
||||||
|
$usealternatemethod = false;
|
||||||
|
if ($timestamp <= 0) $usealternatemethod = true; // <= 1970
|
||||||
|
if ($timestamp >= 2145913200) $usealternatemethod = true; // >= 2038
|
||||||
|
|
||||||
|
if ($usealternatemethod)
|
||||||
|
{
|
||||||
|
$arrayinfo = adodb_getdate($timestamp, $fast);
|
||||||
|
} else {
|
||||||
|
$arrayinfo = getdate($timestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $arrayinfo;
|
return $arrayinfo;
|
||||||
|
|||||||
@ -346,6 +346,7 @@ function product_lot_admin_prepare_head()
|
|||||||
function show_stats_for_company($product, $socid)
|
function show_stats_for_company($product, $socid)
|
||||||
{
|
{
|
||||||
global $conf, $langs, $user, $db;
|
global $conf, $langs, $user, $db;
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
$nblines = 0;
|
$nblines = 0;
|
||||||
|
|
||||||
@ -356,25 +357,7 @@ function show_stats_for_company($product, $socid)
|
|||||||
print '<td class="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
|
print '<td class="right" width="25%">'.$langs->trans("TotalQuantity").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
// MO
|
// Customer proposals
|
||||||
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read)
|
|
||||||
{
|
|
||||||
$nblines++;
|
|
||||||
//$ret = $product->load_stats_mo($socid);
|
|
||||||
if ($ret < 0) dol_print_error($db);
|
|
||||||
$langs->load("orders");
|
|
||||||
print '<tr><td>';
|
|
||||||
print '<a href="mo.php?id='.$product->id.'">'.img_object('', 'mrp').' '.$langs->trans("MO").'</a>';
|
|
||||||
print '</td><td class="right">';
|
|
||||||
print $product->stats_mo['suppliers'];
|
|
||||||
print '</td><td class="right">';
|
|
||||||
print $product->stats_mo['nb'];
|
|
||||||
print '</td><td class="right">';
|
|
||||||
print $product->stats_mo['qty'];
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
}
|
|
||||||
// Customer proposals
|
|
||||||
if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
|
if (!empty($conf->propal->enabled) && $user->rights->propale->lire)
|
||||||
{
|
{
|
||||||
$nblines++;
|
$nblines++;
|
||||||
@ -502,6 +485,61 @@ function show_stats_for_company($product, $socid)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BOM
|
||||||
|
if (!empty($conf->bom->enabled) && $user->rights->bom->read)
|
||||||
|
{
|
||||||
|
$nblines++;
|
||||||
|
$ret = $product->load_stats_bom($socid);
|
||||||
|
if ($ret < 0) {
|
||||||
|
setEventMessage($product->error, 'errors');
|
||||||
|
}
|
||||||
|
$langs->load("mrp");
|
||||||
|
|
||||||
|
print '<tr><td>';
|
||||||
|
print '<a href="bom.php?id='.$product->id.'">'.img_object('', 'mrp').' '.$langs->trans("BOM").'</a>';
|
||||||
|
print '</td><td class="right">';
|
||||||
|
|
||||||
|
print '</td><td class="right">';
|
||||||
|
print $form->textwithpicto($product->stats_bom['nb_toproduce'], $langs->trans("QtyToProduce"));
|
||||||
|
print $form->textwithpicto($product->stats_bom['nb_toconsume'], $langs->trans("ToConsume"));
|
||||||
|
print '</td><td class="right">';
|
||||||
|
print $form->textwithpicto($product->stats_bom['qty_toproduce'], $langs->trans("QtyToProduce"));
|
||||||
|
print $form->textwithpicto($product->stats_bom['qty_toconsume'], $langs->trans("ToConsume"));
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// MO
|
||||||
|
if (!empty($conf->mrp->enabled) && $user->rights->mrp->read)
|
||||||
|
{
|
||||||
|
$nblines++;
|
||||||
|
$ret = $product->load_stats_mo($socid);
|
||||||
|
if ($ret < 0) {
|
||||||
|
setEventMessage($product->error, 'errors');
|
||||||
|
}
|
||||||
|
$langs->load("mrp");
|
||||||
|
print '<tr><td>';
|
||||||
|
print '<a href="mo.php?id='.$product->id.'">'.img_object('', 'mrp').' '.$langs->trans("MO").'</a>';
|
||||||
|
print '</td><td class="right">';
|
||||||
|
print $form->textwithpicto($product->stats_mo['customers_toconsume'], $langs->trans("ToConsume"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['customers_consumed'], $langs->trans("QtyAlreadyConsumed"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['customers_toproduce'], $langs->trans("QtyToProduce"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['customers_produced'], $langs->trans("QtyAlreadyProduced"));
|
||||||
|
print '</td><td class="right">';
|
||||||
|
print $form->textwithpicto($product->stats_mo['nb_toconsume'], $langs->trans("ToConsume"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['nb_consumed'], $langs->trans("QtyAlreadyConsumed"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['nb_toproduce'], $langs->trans("QtyToProduce"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['nb_produced'], $langs->trans("QtyAlreadyProduced"));
|
||||||
|
print '</td><td class="right">';
|
||||||
|
print $form->textwithpicto($product->stats_mo['qty_toconsume'], $langs->trans("ToConsume"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['qty_consumed'], $langs->trans("QtyAlreadyConsumed"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['qty_toproduce'], $langs->trans("QtyToProduce"));
|
||||||
|
print $form->textwithpicto($product->stats_mo['qty_produced'], $langs->trans("QtyAlreadyProduced"));
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
return $nblines++;
|
return $nblines++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -568,7 +568,7 @@ class MyObject extends CommonObject
|
|||||||
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
|
||||||
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
$sql .= " SET ref = '".$this->db->escape($num)."',";
|
||||||
$sql .= " status = ".self::STATUS_VALIDATED;
|
$sql .= " status = ".self::STATUS_VALIDATED;
|
||||||
if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."',";
|
if (!empty($this->fields['date_validation'])) $sql .= ", date_validation = '".$this->db->idate($now)."'";
|
||||||
if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
|
if (!empty($this->fields['fk_user_valid'])) $sql .= ", fk_user_valid = ".$user->id;
|
||||||
$sql .= " WHERE rowid = ".$this->id;
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
|
|||||||
@ -2357,6 +2357,129 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* Charge tableau des stats OF pour le produit/service
|
||||||
|
*
|
||||||
|
* @param int $socid Id societe
|
||||||
|
* @return integer Tableau des stats dans $this->stats_mo, <0 if ko >0 if ok
|
||||||
|
*/
|
||||||
|
public function load_stats_mo($socid = 0)
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
global $user, $hookmanager;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
foreach (array('toconsume','consumed','toproduce','produced') as $role) {
|
||||||
|
$this->stats_mo['customers_'.$role] = 0;
|
||||||
|
$this->stats_mo['nb_'.$role] = 0;
|
||||||
|
$this->stats_mo['qty_'.$role] = 0;
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
||||||
|
$sql .= " SUM(mp.qty) as qty";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as c";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."mrp_production as mp ON mp.fk_mo=c.rowid";
|
||||||
|
if (!$user->rights->societe->client->voir && !$socid) {
|
||||||
|
$sql .= "INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc=c.fk_soc AND sc.fk_user = ".$user->id;
|
||||||
|
}
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " c.entity IN (".getEntity('mo').")";
|
||||||
|
|
||||||
|
$sql .= " AND mp.fk_product =".$this->id;
|
||||||
|
$sql .= " AND mp.role ='".$this->db->escape($role)."'";
|
||||||
|
if ($socid > 0) {
|
||||||
|
$sql .= " AND c.fk_soc = ".$socid;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
$this->stats_mo['customers_'.$role] = $obj->nb_customers ? $obj->nb_customers : 0;
|
||||||
|
$this->stats_mo['nb_'.$role] = $obj->nb ? $obj->nb : 0;
|
||||||
|
$this->stats_mo['qty_'.$role] = $obj->qty ? $obj->qty : 0;
|
||||||
|
} else {
|
||||||
|
$this->error = $this->db->error();
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($error)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action);
|
||||||
|
if ($reshook > 0) $this->stats_mo = $hookmanager->resArray['stats_mo'];
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
/**
|
||||||
|
* Charge tableau des stats OF pour le produit/service
|
||||||
|
*
|
||||||
|
* @param int $socid Id societe
|
||||||
|
* @return integer Tableau des stats dans $this->stats_mo, <0 if ko >0 if ok
|
||||||
|
*/
|
||||||
|
public function load_stats_bom($socid = 0)
|
||||||
|
{
|
||||||
|
// phpcs:enable
|
||||||
|
global $user, $hookmanager;
|
||||||
|
|
||||||
|
$error=0;
|
||||||
|
|
||||||
|
$this->stats_bom['nb_toproduce'] = 0;
|
||||||
|
$this->stats_bom['nb_toconsume'] = 0;
|
||||||
|
$this->stats_bom['qty_toproduce'] = 0;
|
||||||
|
$this->stats_bom['qty_toconsume'] = 0;
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(DISTINCT b.rowid) as nb_toproduce,";
|
||||||
|
$sql .= " b.qty as qty_toproduce";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
||||||
|
$sql .= " AND b.fk_product =".$this->id;
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
$this->stats_bom['nb_toproduce'] = $obj->nb_toproduce ? $obj->nb_toproduce : 0;
|
||||||
|
$this->stats_bom['qty_toproduce'] = $obj->qty_toproduce ? price2num($obj->qty_toproduce) : 0;
|
||||||
|
} else {
|
||||||
|
$this->error = $this->db->error();
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "SELECT COUNT(DISTINCT bl.rowid) as nb_toconsume,";
|
||||||
|
$sql .= " SUM(bl.qty) as qty_toconsume";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
||||||
|
$sql .= " AND bl.fk_product =".$this->id;
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$obj = $this->db->fetch_object($result);
|
||||||
|
$this->stats_bom['nb_toconsume'] = $obj->nb_toconsume ? $obj->nb_toconsume : 0;
|
||||||
|
$this->stats_bom['qty_toconsume'] = $obj->qty_toconsume ? price2num($obj->qty_toconsume) : 0;
|
||||||
|
} else {
|
||||||
|
$this->error = $this->db->error();
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($error)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters = array('socid' => $socid);
|
||||||
|
$reshook = $hookmanager->executeHooks('loadStatsCustomerMO', $parameters, $this, $action);
|
||||||
|
if ($reshook > 0) $this->stats_bom = $hookmanager->resArray['stats_bom'];
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
/**
|
/**
|
||||||
|
|||||||
277
htdocs/product/stats/bom.php
Normal file
277
htdocs/product/stats/bom.php
Normal file
@ -0,0 +1,277 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||||
|
* Copyright (C) 2020 Floiran Henry <florian.henry@scopen.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/product/stats/mo.php
|
||||||
|
* \ingroup product mo
|
||||||
|
* \brief Page of MO referring product
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
|
|
||||||
|
// Load translation files required by the page
|
||||||
|
$langs->loadLangs(array('mrp', 'products', 'companies'));
|
||||||
|
|
||||||
|
$id = GETPOST('id', 'int');
|
||||||
|
$ref = GETPOST('ref', 'alpha');
|
||||||
|
|
||||||
|
// Security check
|
||||||
|
$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref : ''));
|
||||||
|
$fieldtype = (!empty($ref) ? 'ref' : 'rowid');
|
||||||
|
if ($user->socid) $socid = $user->socid;
|
||||||
|
$result = restrictedArea($user, 'produit|service', $fieldvalue, 'product&product', '', '', $fieldtype);
|
||||||
|
|
||||||
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||||
|
$hookmanager->initHooks(array('productstatscontract'));
|
||||||
|
|
||||||
|
$mesg = '';
|
||||||
|
$option = '';
|
||||||
|
|
||||||
|
// Load variable for pagination
|
||||||
|
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
||||||
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
|
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||||
|
$offset = $limit * $page;
|
||||||
|
$pageprev = $page - 1;
|
||||||
|
$pagenext = $page + 1;
|
||||||
|
if (!$sortorder) $sortorder = "DESC";
|
||||||
|
if (!$sortfield) $sortfield = "b.date_valid";
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
if ($id > 0 || !empty($ref))
|
||||||
|
{
|
||||||
|
$product = new Product($db);
|
||||||
|
$result = $product->fetch($id, $ref);
|
||||||
|
|
||||||
|
$object = $product;
|
||||||
|
|
||||||
|
$parameters = array('id'=>$id);
|
||||||
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $product, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
llxHeader("", "", $langs->trans("CardProduct".$product->type));
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$head = product_prepare_head($product);
|
||||||
|
$titre = $langs->trans("CardProduct".$product->type);
|
||||||
|
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
||||||
|
print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
|
||||||
|
|
||||||
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
|
||||||
|
print $hookmanager->resPrint;
|
||||||
|
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
|
||||||
|
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||||
|
|
||||||
|
$shownav = 1;
|
||||||
|
if ($user->socid && !in_array('product', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
|
||||||
|
|
||||||
|
dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref');
|
||||||
|
|
||||||
|
print '<div class="fichecenter">';
|
||||||
|
|
||||||
|
print '<div class="underbanner clearboth"></div>';
|
||||||
|
print '<table class="border tableforfield" width="100%">';
|
||||||
|
|
||||||
|
$nboflines = show_stats_for_company($product, $socid);
|
||||||
|
|
||||||
|
print "</table>";
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
print '<div style="clear:both"></div>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
$now = dol_now();
|
||||||
|
|
||||||
|
//Calcul total qty and amount for global if full scan list
|
||||||
|
$total_qty_toconsume = 0;
|
||||||
|
$total_qty_toproduce = 0;
|
||||||
|
$bom_data_result=array();
|
||||||
|
|
||||||
|
|
||||||
|
//Qauntity to produce
|
||||||
|
$sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,";
|
||||||
|
$sql .= " b.qty as qty_toproduce";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
||||||
|
$sql .= " AND b.fk_product =".$product->id;
|
||||||
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
// Count total nb of records
|
||||||
|
$totalofrecords = '';
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$totalofrecords = $db->num_rows($result);
|
||||||
|
while ($objp = $db->fetch_object($result)) {
|
||||||
|
$total_qty_toproduce += $objp->qty_toproduce;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$bomtmp = new BOM($db);
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
if ($num > 0) {
|
||||||
|
while ($i < min($num, $limit)) {
|
||||||
|
$objp = $db->fetch_object($result);
|
||||||
|
$bomtmp->id = $objp->rowid;
|
||||||
|
$bomtmp->ref = $objp->ref;
|
||||||
|
$bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production');
|
||||||
|
$bom_data_result[$objp->rowid]['qty_toproduce']+=($objp->qty_toproduce > 0 ? $objp->qty_toproduce : 0);
|
||||||
|
$bom_data_result[$objp->rowid]['qty_toconsume']=0;
|
||||||
|
$bom_data_result[$objp->rowid]['date_valid']=dol_print_date($db->jdate($objp->date_valid), 'dayhour');
|
||||||
|
$bom_data_result[$objp->rowid]['status']=$bomtmp->LibStatut($objp->status, 5);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$db->free($result);
|
||||||
|
|
||||||
|
//Qauntity to consume
|
||||||
|
$sql = "SELECT b.rowid as rowid, b.ref, b.status, b.date_valid,";
|
||||||
|
$sql .= " SUM(bl.qty) as qty_toconsume";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as b";
|
||||||
|
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."bom_bomline as bl ON bl.fk_bom=b.rowid";
|
||||||
|
$sql .= " WHERE ";
|
||||||
|
$sql .= " b.entity IN (".getEntity('bom').")";
|
||||||
|
$sql .= " AND bl.fk_product=".$product->id;
|
||||||
|
$sql .= " GROUP BY b.rowid, b.ref, b.date_valid, b.status";
|
||||||
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
|
// Count total nb of records
|
||||||
|
$totalofrecords = '';
|
||||||
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||||
|
{
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$totalofrecords = $db->num_rows($result);
|
||||||
|
while ($objp = $db->fetch_object($result)) {
|
||||||
|
$total_qty_toconsume += $objp->qty_toconsume;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
|
$result = $db->query($sql);
|
||||||
|
if ($result) {
|
||||||
|
$bomtmp = new BOM($db);
|
||||||
|
$num = $db->num_rows($result);
|
||||||
|
$i = 0;
|
||||||
|
if ($num > 0) {
|
||||||
|
while ($i < min($num, $limit)) {
|
||||||
|
$objp = $db->fetch_object($result);
|
||||||
|
$bomtmp->id = $objp->rowid;
|
||||||
|
$bomtmp->ref = $objp->ref;
|
||||||
|
|
||||||
|
if (!array_key_exists($objp->rowid, $bom_data_result)) {
|
||||||
|
$bom_data_result[$objp->rowid]['link'] = $bomtmp->getNomUrl(1, 'production');
|
||||||
|
$bom_data_result[$objp->rowid]['qty_toproduce']=0;
|
||||||
|
$bom_data_result[$objp->rowid]['qty_toconsume']+=($objp->qty_toconsume > 0 ? $objp->qty_toconsume : 0);
|
||||||
|
$bom_data_result[$objp->rowid]['date_valid']=dol_print_date($db->jdate($objp->date_valid), 'dayhour');
|
||||||
|
$bom_data_result[$objp->rowid]['status']=$bomtmp->LibStatut($objp->status, 5);
|
||||||
|
} else {
|
||||||
|
$bom_data_result[$objp->rowid]['qty_toconsume']+=($objp->qty_toconsume > 0 ? $objp->qty_toconsume : 0);
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
$db->free($result);
|
||||||
|
|
||||||
|
|
||||||
|
if ($limit > 0 && $limit != $conf->liste_limit) $option .= '&limit='.urlencode($limit);
|
||||||
|
if (!empty($id)) $option .= '&id='.$product->id;
|
||||||
|
if (!empty($search_month)) $option .= '&search_month='.urlencode($search_month);
|
||||||
|
if (!empty($search_year)) $option .= '&search_year='.urlencode($search_year);
|
||||||
|
|
||||||
|
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$product->id.'" name="search_form">'."\n";
|
||||||
|
if (!empty($sortfield))
|
||||||
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'"/>';
|
||||||
|
if (!empty($sortorder))
|
||||||
|
print '<input type="hidden" name="sortorder" value="'.$sortorder.'"/>';
|
||||||
|
|
||||||
|
print_barre_liste($langs->trans("BOMs"), $page, $_SERVER["PHP_SELF"], $option, $sortfield, $sortorder, '', count($bom_data_result), count($bom_data_result), '', 0, '', '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
|
if (!empty($page)) $option .= '&page='.urlencode($page);
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="tagtable liste listwithfilterbefore" width="100%">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "b.rowid", "", "&id=".$product->id, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "b.date_valid", "", "&id=".$product->id, 'align="center"', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("ToConsume", $_SERVER["PHP_SELF"], "", "", "&id=".$product->id, '', $sortfield, $sortorder, 'center ');
|
||||||
|
print_liste_field_titre("QtyToProduce", $_SERVER["PHP_SELF"], "", "", "&id=".$product->id, '', $sortfield, $sortorder, 'center ');
|
||||||
|
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "b.status", "", "&id=".$product->id, '', $sortfield, $sortorder, 'center ');
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
if (!empty($bom_data_result)) {
|
||||||
|
foreach ($bom_data_result as $data)
|
||||||
|
{
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
print '<td>';
|
||||||
|
print $data['link'];
|
||||||
|
print "</td>\n";
|
||||||
|
print "<td align=\"center\">";
|
||||||
|
print $data['date_valid']."</td>";
|
||||||
|
print '<td class="center">'.$data['qty_toconsume'].'</td>';
|
||||||
|
print '<td class="center">'.$data['qty_toproduce'].'</td>';
|
||||||
|
print '<td class="center">'.$data['status'].'</td>';
|
||||||
|
print "</tr>\n";
|
||||||
|
}
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of page
|
||||||
|
llxFooter();
|
||||||
|
$db->close();
|
||||||
@ -85,7 +85,7 @@ if ($id > 0 || !empty($ref))
|
|||||||
$head = product_prepare_head($product);
|
$head = product_prepare_head($product);
|
||||||
$titre = $langs->trans("CardProduct".$product->type);
|
$titre = $langs->trans("CardProduct".$product->type);
|
||||||
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
$picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product');
|
||||||
dol_fiche_head($head, 'referers', $titre, -1, $picto);
|
print dol_get_fiche_head($head, 'referers', $titre, -1, $picto);
|
||||||
|
|
||||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
"nightwatch-api": "^3.0.1"
|
"nightwatch-api": "^3.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"
|
"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/setup.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cucumber-pretty": "^6.0.0",
|
"cucumber-pretty": "^6.0.0",
|
||||||
|
|||||||
@ -24,7 +24,7 @@ We can run selenium by two ways:
|
|||||||
|
|
||||||
###Run the acceptance tests
|
###Run the acceptance tests
|
||||||
|
|
||||||
* In `nightwatch.conf.js` file inside the root directory of the project and inside the configuration file following environment variable has been specified. We can change the default values according to our local configuration.
|
* In `nightwatch.conf.js` file inside the root directory of the project and inside the configuration file following environment variable has been specified. We can change the default values according to our local configuration.
|
||||||
|
|
||||||
```
|
```
|
||||||
const admin_username = process.env.ADMIN_USERNAME || 'dolibarr';
|
const admin_username = process.env.ADMIN_USERNAME || 'dolibarr';
|
||||||
@ -33,24 +33,23 @@ We can run selenium by two ways:
|
|||||||
|
|
||||||
const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/';
|
const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/';
|
||||||
```
|
```
|
||||||
* You can run test using following commands
|
|
||||||
|
* You can run test using following commands
|
||||||
|
|
||||||
`yarn run test:e2e test/acceptance/features/<feature_file>`
|
`yarn run test:e2e test/acceptance/features/<feature_file>`
|
||||||
|
|
||||||
For example: `yarn run test:e2e test/acceptance/features/addUsers.feature`
|
For example: `yarn run test:e2e test/acceptance/features/addUsers.feature`
|
||||||
|
|
||||||
OR
|
Or: `LAUNCH_URL='<launch_url>'; ADMIN_USERNAME='<admin_username>'; ADMIN_PASSWORD='<admin_password>'; yarn run test:e2e test/acceptance/features/`
|
||||||
|
|
||||||
`LAUNCH_URL='<launch_url>' ADMIN_USERNAME='<admin_username>' ADMIN_PASSWORD='<admin_password>' yarn run test:e2e test/acceptance/features/`
|
|
||||||
|
|
||||||
The full script to run the acceptance tests is specified in `scripts` object of `package.json` file inside the project's root directory as :
|
The full script to run the acceptance tests is specified in `scripts` object of `package.json` file inside the project's root directory as :
|
||||||
|
|
||||||
`"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"`
|
`"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"`
|
||||||
|
|
||||||
After you run the above command you can see the test running. For that :
|
After you run the above command you can see the test running. For that :
|
||||||
|
|
||||||
* open `Remmina` (Remmina is a Remote Desktop Client and comes installed with Ubuntu)
|
* open `Remmina` (Remmina is a Remote Desktop Client and comes installed with Ubuntu)
|
||||||
|
|
||||||
* choose `VNC` and enter `localhost` on the address bar
|
* choose `VNC` and enter `localhost` on the address bar
|
||||||
|
|
||||||
* enter `secret` as the password
|
* enter `secret` as the password
|
||||||
|
|||||||
67
test/acceptance/features/Api/apiAddUsers.feature
Normal file
67
test/acceptance/features/Api/apiAddUsers.feature
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
Feature: Add user
|
||||||
|
As an admin
|
||||||
|
I want to add users
|
||||||
|
So that the authorized access is possible
|
||||||
|
|
||||||
|
Scenario: Admin adds user without permission
|
||||||
|
Given the user with login "harrypotter@gmail.com" does not exist
|
||||||
|
When the admin creates user with following details using API
|
||||||
|
| last name | Potter |
|
||||||
|
| login | harrypotter@gmail.com |
|
||||||
|
| password | password |
|
||||||
|
Then the response status code should be "200"
|
||||||
|
And user with login "harrypotter@gmail.com" should exist
|
||||||
|
|
||||||
|
Scenario: Admin creates already existing user
|
||||||
|
Given the admin has created the following users
|
||||||
|
| login | last name | password |
|
||||||
|
| Harry | Potter | hello123 |
|
||||||
|
When the admin creates user with following details using API
|
||||||
|
| last name | Potter |
|
||||||
|
| login | Harry |
|
||||||
|
| password | hello123 |
|
||||||
|
Then the response status code should be "500"
|
||||||
|
And the response message should be "ErrorLoginAlreadyExists"
|
||||||
|
|
||||||
|
Scenario Outline: Admin adds user with incomplete essential credentials
|
||||||
|
Given the user with login "Harry" does not exist
|
||||||
|
When the admin creates user with following details using API
|
||||||
|
| last name | <last name> |
|
||||||
|
| login | Harry |
|
||||||
|
| password | <password> |
|
||||||
|
Then the response status code should be "200"
|
||||||
|
And user with login "Harry" should exist
|
||||||
|
Examples:
|
||||||
|
| last name | password |
|
||||||
|
| | |
|
||||||
|
| Manson | |
|
||||||
|
| | 123 |
|
||||||
|
|
||||||
|
Scenario Outline: Admin adds user without login
|
||||||
|
Given the user with login "harrypotter@gmail.com" does not exist
|
||||||
|
When the admin creates user with following details using API
|
||||||
|
| last name | <last name> |
|
||||||
|
| login | |
|
||||||
|
| password | <password> |
|
||||||
|
Then the response status code should be "500"
|
||||||
|
And the response message should be "Field 'Login' is required"
|
||||||
|
Examples:
|
||||||
|
| last name | password |
|
||||||
|
| Potter | Hello123 |
|
||||||
|
| Potter | |
|
||||||
|
| | hello123 |
|
||||||
|
|
||||||
|
Scenario Outline: Admin adds user with last name as special characters
|
||||||
|
Given the user with login "<login>" does not exist
|
||||||
|
When the admin creates user with following details using API
|
||||||
|
| last name | <last name> |
|
||||||
|
| login | <login> |
|
||||||
|
| password | password |
|
||||||
|
Then the response status code should be "200"
|
||||||
|
And user with login "<login>" should exist
|
||||||
|
Examples:
|
||||||
|
| last name | login |
|
||||||
|
| swi@ | s$5^2 |
|
||||||
|
| g!!@%ui | नेपाली |
|
||||||
|
| swikriti@h | सिमप्ले $%#?&@name.txt |
|
||||||
|
| !@#$%^&*()-_+ | España§àôœ€ |
|
||||||
@ -30,7 +30,7 @@ module.exports = {
|
|||||||
|
|
||||||
elements: {
|
elements: {
|
||||||
userRow: {
|
userRow: {
|
||||||
selector: '//table[contains(@class,"tagtable liste")]/tbody/tr[position()>2]',
|
selector: '//table[contains(@class,"tagtable")]/tbody/tr[position()>2]',
|
||||||
locateStrategy: 'xpath'
|
locateStrategy: 'xpath'
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
userList: {
|
userList: {
|
||||||
selector: '//table[contains(@class,"tagtable liste")]/tbody/tr[position()>2]/td/a//span[normalize-space(@class="nopadding usertext")][.="%s"]/../../following-sibling::td[.="%s"]',
|
selector: '//table[contains(@class,"tagtable")]/tbody/tr[position()>2]/td/a//span[normalize-space(@class="nopadding usertext")][.="%s"]/../../following-sibling::td[.="%s"]',
|
||||||
locateStrategy: 'xpath'
|
locateStrategy: 'xpath'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
77
test/acceptance/setup.js
Normal file
77
test/acceptance/setup.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
const { Before, After } = require('cucumber');
|
||||||
|
const { client } = require('nightwatch-api');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
let initialUsers = {};
|
||||||
|
let dolApiKey = '';
|
||||||
|
|
||||||
|
const getUsers = async function () {
|
||||||
|
const header = {};
|
||||||
|
const url = client.globals.backend_url + 'api/index.php/users';
|
||||||
|
const users = {};
|
||||||
|
header['Accept'] = 'application/json';
|
||||||
|
header['DOLAPIKEY'] = dolApiKey;
|
||||||
|
await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: header
|
||||||
|
})
|
||||||
|
.then(async (response) => {
|
||||||
|
const json_response = await response.json();
|
||||||
|
for (const user of json_response) {
|
||||||
|
users[user.id] = user.id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return users;
|
||||||
|
};
|
||||||
|
|
||||||
|
Before(async function getDolApiKey() {
|
||||||
|
const header = {}
|
||||||
|
const adminUsername = client.globals.adminUsername;
|
||||||
|
const adminPassword = client.globals.adminPassword;
|
||||||
|
const params = new URLSearchParams()
|
||||||
|
params.set('login', adminUsername)
|
||||||
|
params.set('password', adminPassword)
|
||||||
|
const apiKey = `http://localhost/dolibarr/htdocs/api/index.php/login?${params.toString()}`;
|
||||||
|
header['Accept'] = 'application/json'
|
||||||
|
await fetch(apiKey, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: header
|
||||||
|
})
|
||||||
|
.then(async (response) => {
|
||||||
|
const jsonResponse = await response.json()
|
||||||
|
dolApiKey = jsonResponse['success']['token']
|
||||||
|
client.globals.dolApiKey = dolApiKey
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
Before(async () => {
|
||||||
|
initialUsers = await getUsers();
|
||||||
|
});
|
||||||
|
|
||||||
|
After(async () => {
|
||||||
|
const finalUsers = await getUsers();
|
||||||
|
const header = {};
|
||||||
|
const url = client.globals.backend_url + 'api/index.php/users/';
|
||||||
|
header['Accept'] = 'application/json';
|
||||||
|
header['DOLAPIKEY'] = dolApiKey;
|
||||||
|
let found;
|
||||||
|
for (const finaluser in finalUsers) {
|
||||||
|
for (const initialuser in initialUsers) {
|
||||||
|
found = false;
|
||||||
|
if (initialuser === finaluser) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
await fetch(url + finaluser, {
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: header
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
if (res.status < 200 || res.status >= 400) {
|
||||||
|
throw new Error("Failed to delete user: " + res.statusText);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -1,142 +1,156 @@
|
|||||||
const { Before, Given, When, Then, After } = require('cucumber');
|
const {Given, When, Then} = require('cucumber');
|
||||||
const { client } = require('nightwatch-api');
|
const {client} = require('nightwatch-api');
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
let initialUsers = {};
|
const assert = require('assert');
|
||||||
let dolApiKey = '';
|
let response;
|
||||||
|
let Login = {};
|
||||||
|
|
||||||
Given('the administrator has logged in using the webUI', async function () {
|
Given('the administrator has logged in using the webUI', async function () {
|
||||||
await client.page.loginPage().navigate().waitForLoginPage();
|
await client.page.loginPage().navigate().waitForLoginPage();
|
||||||
await client.page.loginPage().userLogsInWithUsernameAndPassword(client.globals.adminUsername, client.globals.adminPassword);
|
await client.page.loginPage().userLogsInWithUsernameAndPassword(client.globals.adminUsername, client.globals.adminPassword);
|
||||||
return client.page.loginPage().userIsLoggedIn(client.globals.adminUsername);
|
return client.page.loginPage().userIsLoggedIn(client.globals.adminUsername);
|
||||||
});
|
});
|
||||||
|
|
||||||
Given('the administrator has browsed to the new users page', function () {
|
Given('the administrator has browsed to the new users page', function () {
|
||||||
return client.page.homePage().browsedToNewUserPage();
|
return client.page.homePage().browsedToNewUserPage();
|
||||||
});
|
});
|
||||||
|
|
||||||
When('the admin creates user with following details', function (datatable) {
|
When('the admin creates user with following details', function (datatable) {
|
||||||
return client.page.addUsersPage().adminCreatesUser(datatable);
|
return client.page.addUsersPage().adminCreatesUser(datatable);
|
||||||
});
|
});
|
||||||
|
|
||||||
Then('new user {string} should be created', function (lastname) {
|
Then('new user {string} should be created', function (lastname) {
|
||||||
return client.page.addUsersPage().newUserShouldBeCreated(lastname);
|
return client.page.addUsersPage().newUserShouldBeCreated(lastname);
|
||||||
});
|
});
|
||||||
|
|
||||||
Then('message {string} should be displayed in the webUI', function (message) {
|
Then('message {string} should be displayed in the webUI', function (message) {
|
||||||
return client.page.addUsersPage().noPermissionMessage(message);
|
return client.page.addUsersPage().noPermissionMessage(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
Then('message {string} should not be displayed in the webUI', function (message) {
|
Then('message {string} should not be displayed in the webUI', function (message) {
|
||||||
return client.page.addUsersPage().noPermissionDefinedMessageNotShown(message);
|
return client.page.addUsersPage().noPermissionDefinedMessageNotShown(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
Then('new user {string} should not be created', function (lastname) {
|
Then('new user {string} should not be created', function (lastname) {
|
||||||
return client.page.addUsersPage().userNotCreated(lastname);
|
return client.page.addUsersPage().userNotCreated(lastname);
|
||||||
});
|
});
|
||||||
|
|
||||||
Given('a user has been created with following details', function (dataTable) {
|
Given('a user has been created with following details', function (dataTable) {
|
||||||
return adminHasCreatedUser(dataTable);
|
return adminHasCreatedUser(dataTable);
|
||||||
});
|
});
|
||||||
|
|
||||||
Given('the admin has created the following users', function (dataTable) {
|
Given('the admin has created the following users', function (dataTable) {
|
||||||
return adminHasCreatedUser(dataTable);
|
return adminHasCreatedUser(dataTable);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getUsers = async function () {
|
When('the admin creates user with following details using API', function (dataTable) {
|
||||||
const header = {};
|
return adminCreatesUserWithAPI(dataTable);
|
||||||
const url = client.globals.backend_url + 'api/index.php/users';
|
});
|
||||||
const users = {};
|
|
||||||
header['Accept'] = 'application/json';
|
Given('the user with login {string} does not exist', async function (login) {
|
||||||
header['DOLAPIKEY'] = dolApiKey;
|
await userDoesNotExist(login);
|
||||||
await fetch(url, {
|
});
|
||||||
method: 'GET',
|
|
||||||
headers: header
|
Then('the response status code should be {string}', function (expectedStatusCode) {
|
||||||
})
|
return getStatusCode(expectedStatusCode);
|
||||||
.then(async (response) => {
|
});
|
||||||
const json_response = await response.json();
|
|
||||||
for (const user of json_response) {
|
Then('user with login {string} should exist', function (login) {
|
||||||
users[user.id] = user.id;
|
return userShouldExist(login);
|
||||||
}
|
});
|
||||||
});
|
|
||||||
return users;
|
Then('the response message should be {string}', function (expectedResponseMessage) {
|
||||||
|
return getResponseMessage(expectedResponseMessage);
|
||||||
|
});
|
||||||
|
|
||||||
|
const createUserRequest = function (login, lastname, password) {
|
||||||
|
const header = {};
|
||||||
|
const url = client.globals.backend_url + 'api/index.php/users';
|
||||||
|
header['Accept'] = 'application/json';
|
||||||
|
header['DOLAPIKEY'] = client.globals.dolApiKey;
|
||||||
|
header['Content-Type'] = 'application/json';
|
||||||
|
return fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: header,
|
||||||
|
body: JSON.stringify(
|
||||||
|
{
|
||||||
|
login: login,
|
||||||
|
lastname: lastname,
|
||||||
|
pass: password
|
||||||
|
}
|
||||||
|
)
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const adminCreatesUserWithAPI = function (dataTable) {
|
||||||
|
const userDetails = dataTable.rowsHash();
|
||||||
|
return createUserRequest(userDetails['login'], userDetails['last name'], userDetails['password'])
|
||||||
|
.then((res) => {
|
||||||
|
response = res;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const adminHasCreatedUser = async function (dataTable) {
|
const adminHasCreatedUser = async function (dataTable) {
|
||||||
const header = {};
|
const userDetails = dataTable.hashes();
|
||||||
const url = client.globals.backend_url + 'api/index.php/users';
|
for (const user of userDetails) {
|
||||||
header['Accept'] = 'application/json';
|
await createUserRequest(user['login'], user['last name'], user['password'])
|
||||||
header['DOLAPIKEY'] = dolApiKey;
|
.then((response) => {
|
||||||
header['Content-Type'] = 'application/json';
|
if (response.status < 200 || response.status >= 400) {
|
||||||
const userDetails = dataTable.hashes();
|
throw new Error('Failed to create user: ' + user['login'] +
|
||||||
for (const user of userDetails) {
|
' ' + response.statusText);
|
||||||
await fetch(url, {
|
}
|
||||||
method: 'POST',
|
});
|
||||||
headers: header,
|
}
|
||||||
body: JSON.stringify(
|
|
||||||
{
|
|
||||||
login: user['login'],
|
|
||||||
lastname: user['last name'],
|
|
||||||
pass: user['password']
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
if (response.status < 200 || response.status >= 400) {
|
|
||||||
throw new Error('Failed to create user: ' + user['login'] +
|
|
||||||
' ' + response.statusText);
|
|
||||||
}
|
|
||||||
return response.text();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Before(async () => {
|
const getUsersLogin = async function () {
|
||||||
const header = {}
|
const header = {};
|
||||||
const adminUsername = client.globals.adminUsername;
|
const url = client.globals.backend_url + 'api/index.php/users/';
|
||||||
const adminPassword = client.globals.adminPassword;
|
header['Accept'] = 'application/json';
|
||||||
const params = new URLSearchParams()
|
header['DOLAPIKEY'] = client.globals.dolApiKey;
|
||||||
params.set('login', adminUsername)
|
header['Content-Type'] = 'application/json';
|
||||||
params.set('password', adminPassword)
|
await fetch(url, {
|
||||||
const apiKey = `http://localhost/dolibarr/htdocs/api/index.php/login?${params.toString()}`;
|
method: 'GET',
|
||||||
header['Accept'] = 'application/json'
|
headers: header
|
||||||
await fetch(apiKey, {
|
})
|
||||||
method: 'GET',
|
.then(async (response) => {
|
||||||
headers: header
|
const json_response = await response.json();
|
||||||
})
|
for (const user of json_response) {
|
||||||
.then(async (response) => {
|
Login[user.login] = user.login;
|
||||||
const jsonResponse = await response.json()
|
}
|
||||||
dolApiKey = jsonResponse['success']['token']
|
});
|
||||||
})
|
};
|
||||||
})
|
|
||||||
Before(async () => {
|
|
||||||
initialUsers = await getUsers();
|
|
||||||
});
|
|
||||||
|
|
||||||
After(async () => {
|
const userDoesNotExist = async function (login) {
|
||||||
const finalUsers = await getUsers();
|
await getUsersLogin();
|
||||||
const header = {};
|
if (login in Login) {
|
||||||
const url = client.globals.backend_url + 'api/index.php/users/';
|
Login = {};
|
||||||
header['Accept'] = 'application/json';
|
throw new Error(`user ${login} exists`);
|
||||||
header['DOLAPIKEY'] = dolApiKey;
|
}
|
||||||
let found;
|
Login = {};
|
||||||
for (const finaluser in finalUsers) {
|
return;
|
||||||
for (const initialuser in initialUsers) {
|
};
|
||||||
found = false;
|
|
||||||
if (initialuser === finaluser) {
|
const userShouldExist = async function (login) {
|
||||||
found = true;
|
await getUsersLogin();
|
||||||
break;
|
if (login in Login) {
|
||||||
}
|
Login = {};
|
||||||
}
|
return;
|
||||||
if (!found) {
|
} else {
|
||||||
await fetch(url + finaluser, {
|
Login = {};
|
||||||
method: 'DELETE',
|
throw new Error(`User ${login} does not Exist`);
|
||||||
headers: header
|
}
|
||||||
})
|
};
|
||||||
.then(res => {
|
|
||||||
if (res.status < 200 || res.status >= 400) {
|
const getStatusCode = async function (expectedStatusCode) {
|
||||||
throw new Error("Failed to delete user: " + res.statusText);
|
const actualStatusCode = response.status.toString();
|
||||||
}
|
return assert.strictEqual(actualStatusCode, expectedStatusCode,
|
||||||
});
|
`The expected status code was ${expectedStatusCode} but got ${actualStatusCode}`);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
});
|
const getResponseMessage = async function (expectedResponseMessage) {
|
||||||
|
const json_response = await response.json();
|
||||||
|
const actualResponseMessage = json_response['error']['0'];
|
||||||
|
return assert.strictEqual(actualResponseMessage, expectedResponseMessage,
|
||||||
|
`the expected response message was ${expectedResponseMessage} but got ${actualResponseMessage}`);
|
||||||
|
};
|
||||||
@ -1257,9 +1257,6 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
$conf->global->MAIN_START_WEEK = 0;
|
$conf->global->MAIN_START_WEEK = 0;
|
||||||
|
|
||||||
$tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday
|
|
||||||
$this->assertEquals(4, $tmp['wday']);
|
|
||||||
|
|
||||||
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
|
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
|
||||||
$this->assertEquals(5, $tmp['wday']);
|
$this->assertEquals(5, $tmp['wday']);
|
||||||
|
|
||||||
@ -1271,12 +1268,77 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
|
$tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday
|
||||||
$this->assertEquals(5, $tmp['wday']);
|
$this->assertEquals(5, $tmp['wday']);
|
||||||
|
|
||||||
|
$tmp=dol_getdate(1, false, "Europe/Paris"); // 1/1/1970 and 1 second = thirday
|
||||||
|
$this->assertEquals(1970, $tmp['year']);
|
||||||
|
$this->assertEquals(1, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(4, $tmp['wday']);
|
||||||
|
$this->assertEquals(0, $tmp['yday']);
|
||||||
|
$this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
|
$tmp=dol_getdate(15638401, false, "Europe/Paris"); // 1/7/1970 and 1 second = wednesday
|
||||||
|
$this->assertEquals(1970, $tmp['year']);
|
||||||
|
$this->assertEquals(7, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(3, $tmp['wday']);
|
||||||
|
$this->assertEquals(181, $tmp['yday']);
|
||||||
|
$this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
|
$tmp=dol_getdate(1593561601, false, "Europe/Paris"); // 1/7/2020 and 1 second = wednesday
|
||||||
|
$this->assertEquals(2020, $tmp['year']);
|
||||||
|
$this->assertEquals(7, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(3, $tmp['wday']);
|
||||||
|
$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
|
||||||
|
$this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
|
$conf->global->MAIN_USE_OLD_FUNCTIONS_FOR_GETDATE = 1;
|
||||||
|
|
||||||
|
$tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday
|
||||||
|
$this->assertEquals(1970, $tmp['year']);
|
||||||
|
$this->assertEquals(1, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(4, $tmp['wday']);
|
||||||
|
$this->assertEquals(0, $tmp['yday']);
|
||||||
|
// We must disable this because on CI, timezone is may be UTC or something else
|
||||||
|
//$this->assertEquals(1, $tmp['hours']); // We are winter, so we are GMT+1 even during summer
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
|
$tmp=dol_getdate(15638401); // 1/7/1970 and 1 second = wednesday
|
||||||
|
$this->assertEquals(1970, $tmp['year']);
|
||||||
|
$this->assertEquals(7, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(3, $tmp['wday']);
|
||||||
|
$this->assertEquals(181, $tmp['yday']);
|
||||||
|
// We must disable this because on CI, timezone is may be UTC or something else
|
||||||
|
//$this->assertEquals(1, $tmp['hours']); // There is no daylight in 1970, so we are GMT+1 even during summer
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
|
$tmp=dol_getdate(1593561601); // 1/7/2020 and 1 second = wednesday
|
||||||
|
$this->assertEquals(2020, $tmp['year']);
|
||||||
|
$this->assertEquals(7, $tmp['mon']);
|
||||||
|
$this->assertEquals(1, $tmp['mday']);
|
||||||
|
$this->assertEquals(3, $tmp['wday']);
|
||||||
|
$this->assertEquals(182, $tmp['yday']); // 182 and not 181, due to the 29th february
|
||||||
|
// We must disable this because on CI, timezone is may be UTC or something else
|
||||||
|
//$this->assertEquals(2, $tmp['hours']); // There is a daylight, so we are GMT+2
|
||||||
|
$this->assertEquals(0, $tmp['minutes']);
|
||||||
|
$this->assertEquals(1, $tmp['seconds']);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testDolGetDate
|
* testMakeSubstitutions
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user