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

This commit is contained in:
Regis Houssin 2021-01-02 17:20:24 +01:00
commit 3b7f5a92cb
34 changed files with 394 additions and 445 deletions

View File

@ -25,11 +25,16 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
$socid = GETPOST('socid', 'int');
$action = GETPOST('action', 'aZ09');
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
@ -39,6 +44,7 @@ if ($user->socid > 0)
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$object = new BookKeeping($db);
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
@ -60,14 +66,91 @@ $year_current = $year_start;
/*
* Actions
*/
if ($action == 'validate_movements_confirm' && $user->rights->accounting->fiscalyear->write) {
$result = $object->fetchAll();
if ($result < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
} else {
// Specify as export : update field date_validated on selected month/year
$error = 0;
$db->begin();
$date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
$date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
if (is_array($object->lines))
{
foreach ($object->lines as $movement)
{
$now = dol_now();
$sql = " UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping";
$sql .= " SET date_validated = '".$db->idate($now)."'";
$sql .= " WHERE rowid = ".$movement->id;
$sql .= " AND doc_date >= '" . dol_print_date($date_start, 'dayrfc') . "'";
$sql .= " AND doc_date <= '" . dol_print_date($date_end, 'dayrfc') . "'";
dol_syslog("/accountancy/closure/index.php :: Function validate_movement_confirm Specify movements as validated sql=".$sql, LOG_DEBUG);
$result = $db->query($sql);
if (!$result)
{
$error++;
break;
}
}
}
if (!$error)
{
$db->commit();
setEventMessages($langs->trans("AllMovementsWereRecordedAsValidated"), null, 'mesgs');
} else {
$error++;
$db->rollback();
setEventMessages($langs->trans("NotAllMovementsCouldBeRecordedAsValidated"), null, 'errors');
}
header("Location: ".$_SERVER['PHP_SELF']."?year=".$year_start);
exit;
}
}
/*
* View
*/
$form = new Form($db);
$formaccounting = new FormAccounting($db);
llxHeader('', $langs->trans("Closure"));
if ($action == 'validate_movements') {
$form_question = array();
$month = isset($conf->global->SOCIETE_FISCAL_MONTH_START) ? intval($conf->global->SOCIETE_FISCAL_MONTH_START) : 1;
$date_start = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1));
$date_end = new DateTime(sprintf('%04d-%02d-%02d', $year_start, $month, 1));
$date_end->add(new DateInterval('P1Y'));
$date_end->sub(new DateInterval('P1D'));
$form_question['date_start'] = array(
'name' => 'date_start',
'type' => 'date',
'label' => $langs->trans('DateStart'),
'value' => $date_start->format('Y-m-d')
);
$form_question['date_end'] = array(
'name' => 'date_end',
'type' => 'date',
'label' => $langs->trans('DateEnd'),
'value' => $date_end->format('Y-m-d')
);
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?year='.$year_start, $langs->trans('ValidateMovements'), $langs->trans('DescValidateMovements', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'validate_movements_confirm', $form_question, '', 1, 300);
print $formconfirm;
}
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
@ -80,9 +163,9 @@ print '<br>';
$y = $year_current;
$buttonbind = '<a class="butAction" href="./validate.php">'.$langs->trans("ValidateMovements").'</a>';
$buttonvalidate = '<a class="butAction" name="button_validate_movements" href="'.$_SERVER["PHP_SELF"].'?action=validate_movements&year='.$year_start.'">'.$langs->trans("ValidateMovements").'</a>';
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonbind, '', 0, 1, 1);
print_barre_liste($langs->trans("OverviewOfMovementsNotValidated"), '', '', '', '', '', '', -1, '', '', 0, $buttonvalidate, '', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
@ -104,6 +187,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
$sql .= " AND date_validated IS NULL";
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);

View File

@ -1,156 +0,0 @@
<?php
/* Copyright (C) 2019 Open-DSI <support@open-dsi.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 <http://www.gnu.org/licenses/>.
*
*/
/**
* \file htdocs/accountancy/closure/validate.php
* \ingroup Accountancy
* \brief Validate entries page
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "other", "main", "accountancy"));
// Security check
if (empty($conf->accounting->enabled)) {
accessforbidden();
}
if ($user->socid > 0)
accessforbidden();
if (!$user->rights->accounting->fiscalyear->write)
accessforbidden();
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
if (GETPOST("year", 'int')) $year_start = GETPOST("year", 'int');
else {
$year_start = dol_print_date(dol_now(), '%Y');
if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
}
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
{
$month_end = 12;
$year_end--;
}
$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
$search_date_end = dol_get_last_day($year_end, $month_end);
$year_current = $year_start;
/*
* Actions
*/
if ($action == 'validate')
{
$now = dol_now();
// Update database
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " SET b.date_validated = '".$db->idate($now)."'";
$sql .= ' WHERE b.date_validated IS NULL';
dol_syslog("htdocs/accountancy/closure/validate.php validate", LOG_DEBUG);
$resql = $db->query($sql);
if (!$resql1) {
$error++;
$db->rollback();
setEventMessages($db->lasterror(), null, 'errors');
} else {
$db->commit();
}
// End clean database
}
/*
* View
*/
llxHeader('', $langs->trans("ValidateMovements"));
$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
print load_fiche_titre($langs->trans("ValidateMovements")." ".$textprevyear." ".$langs->trans("Year")." ".$year_start." ".$textnextyear, '', 'title_accountancy');
print $langs->trans("DescValidateMovements").'<br>';
print '<br>';
$y = $year_current;
print_barre_liste($langs->trans("SelectMonthAndValidate"), '', '', '', '', '', '', -1, '', '', 0, '', 'class="right"', 0, 1, 1);
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="oddeven">';
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
print '<td class="center">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
}
print '<td><b>'.$langs->trans("Total").'</b></td></tr>';
print '<tr class="oddeven">';
$sql = "SELECT COUNT(b.rowid) as detail,";
for ($i = 1; $i <= 12; $i++) {
$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
if ($j > 12) $j -= 12;
$sql .= " SUM(".$db->ifsql('MONTH(b.doc_date)='.$j, '1', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
}
$sql .= " COUNT(b.rowid) as total";
$sql .= " FROM ".MAIN_DB_PREFIX."accounting_bookkeeping as b";
$sql .= " WHERE b.doc_date >= '".$db->idate($search_date_start)."'";
$sql .= " AND b.doc_date <= '".$db->idate($search_date_end)."'";
$sql .= " AND b.entity IN (".getEntity('bookkeeping', 0).")"; // We don't share object for accountancy
dol_syslog('htdocs/accountancy/closure/index.php sql='.$sql, LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
while ($row = $db->fetch_row($resql)) {
for ($i = 1; $i <= 12; $i++) {
print '<td class="nowrap center">'.$row[$i].'<br><br>';
print '<input id="cb'.$row[$i].'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$row[$i].'"'.($selected ? ' checked="checked"' : '').'>';
print '</td>';
}
print '<td class="valigntop"><b>'.$row[13].'</b></td>';
}
$db->free($resql);
} else {
print $db->lasterror(); // Show last sql error
}
print '</tr>';
print "</table>\n";
print '<br><div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?month='.$year_current.'&action=validate"">'.$langs->trans("ValidateMovements").'</a></div>';
print '</div>';
// End of page
llxFooter();
$db->close();

View File

@ -1761,7 +1761,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($linktoelem) print ($somethingshown?'':'<br>').$linktoelem;
*/
// Shon online payment link
// Show online payment link
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
if ($useonlinepayment) {

View File

@ -299,7 +299,7 @@ if (empty($mysoc->country_code))
print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
print " x ".$langs->trans("Quantity").": ".$qty;
print " - ".$langs->trans("VAT").": ".$vat.'%';
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
$s = 10 / 3; $qty = 2; $vat = 10;
$tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);

View File

@ -1151,7 +1151,7 @@ if ($mode == 'deploy') {
print '<input class="flat minwidth400" type="file" name="fileinstall" id="fileinstall"> ';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Send")).'" class="button">';
print '<input type="submit" name="send" value="'.dol_escape_htmltag($langs->trans("Upload")).'" class="button">';
if (!empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($user->admin) {

View File

@ -600,6 +600,7 @@ class Propal extends CommonObject
// Clean vat code
$reg = array();
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];
@ -771,7 +772,9 @@ class Propal extends CommonObject
$qty = price2num($qty);
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);

View File

@ -631,9 +631,9 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{

View File

@ -3060,7 +3060,9 @@ class Commande extends CommonOrder
$pu = price2num($pu);
$pa_ht = price2num($pa_ht);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -437,9 +437,9 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = GETPOST('price_ht');
$price_ht_devise = GETPOST('multicurrency_price_ht');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -450,7 +450,7 @@ if (empty($reshook))
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
// Extrafields

View File

@ -853,7 +853,9 @@ class FactureRec extends CommonInvoice
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txtva)) $txtva = 0;
@ -1031,7 +1033,9 @@ class FactureRec extends CommonInvoice
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
if (empty($txlocaltax1)) $txlocaltax1 = 0;
@ -1057,6 +1061,7 @@ class FactureRec extends CommonInvoice
// Clean vat code
$vat_src_code = '';
$reg = array();
if (preg_match('/\((.*)\)/', $txtva, $reg))
{
$vat_src_code = $reg[1];

View File

@ -3283,7 +3283,9 @@ class Facture extends CommonInvoice
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$pa_ht = price2num($pa_ht);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -294,7 +294,7 @@ class Paiement extends CommonObject
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
$sql .= " VALUES (".$conf->entity.", '".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', ".$total.", ".$mtotal.", ".$this->paiementid.", ";
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((int) $this->pos_change).")";
$sql .= "'".$this->db->escape($num_payment)."', '".$this->db->escape($note)."', ".($this->ext_payment_id ? "'".$this->db->escape($this->ext_payment_id)."'" : "null").", ".($this->ext_payment_site ? "'".$this->db->escape($this->ext_payment_site)."'" : "null").", ".$user->id.", ".((float) $this->pos_change).")";
$resql = $this->db->query($sql);
if ($resql)

View File

@ -89,6 +89,7 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem
$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
$error = 0;
/*
@ -383,9 +384,9 @@ if (empty($reshook))
{
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$price_ht = price2num(GETPOST('price_ht'));
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'));
if (GETPOST('prod_entry_mode', 'alpha') == 'free')
{
$idprod = 0;
@ -395,7 +396,7 @@ if (empty($reshook))
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef));
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = ((GETPOST('remise_percent'.$predef) != '') ? GETPOST('remise_percent'.$predef) : 0);
if ($qty == '')

View File

@ -1465,7 +1465,6 @@ class Contrat extends CommonObject
$vat_src_code = $reg[1];
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
}
$txtva = price2num($txtva);
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -33,8 +33,7 @@
/*
* Add file in email form
*/
if (GETPOST('addfile', 'alpha'))
{
if (GETPOST('addfile', 'alpha')) {
$trackid = GETPOST('trackid', 'aZ09');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -50,8 +49,7 @@ if (GETPOST('addfile', 'alpha'))
/*
* Remove file in email form
*/
if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
{
if (!empty($_POST['removedfile']) && empty($_POST['removAll'])) {
$trackid = GETPOST('trackid', 'aZ09');
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -69,24 +67,28 @@ if (!empty($_POST['removedfile']) && empty($_POST['removAll']))
/*
* Remove all files in email form
*/
if (GETPOST('removAll', 'alpha'))
{
if (GETPOST('removAll', 'alpha')) {
$trackid = GETPOST('trackid', 'aZ09');
$listofpaths = array();
$listofnames = array();
$listofmimes = array();
$keytoavoidconflict = empty($trackid) ? '' : '-'.$trackid;
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
$formmail->trackid = $trackid;
foreach ($listofpaths as $key => $value)
{
foreach ($listofpaths as $key => $value) {
$pathtodelete = $value;
$filetodelete = $listofnames[$key];
$result = dol_delete_file($pathtodelete, 1); // Delete uploded Files
@ -101,50 +103,56 @@ if (GETPOST('removAll', 'alpha'))
/*
* Send mail
*/
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected'])
{
if (empty($trackid)) $trackid = GETPOST('trackid', 'aZ09');
if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST['removAll'] && !$_POST['removedfile'] && !$_POST['cancel'] && !$_POST['modelselected']) {
if (empty($trackid)) {
$trackid = GETPOST('trackid', 'aZ09');
}
$subject = ''; $actionmsg = ''; $actionmsg2 = '';
$langs->load('mails');
if (is_object($object))
{
if (is_object($object)) {
$result = $object->fetch($id);
$sendtosocid = 0; // Id of related thirdparty
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact')))
{
if (method_exists($object, "fetch_thirdparty") && !in_array($object->element, array('member', 'user', 'expensereport', 'societe', 'contact'))) {
$resultthirdparty = $object->fetch_thirdparty();
$thirdparty = $object->thirdparty;
if (is_object($thirdparty)) $sendtosocid = $thirdparty->id;
} elseif ($object->element == 'member' || $object->element == 'user')
{
if (is_object($thirdparty)) {
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'member' || $object->element == 'user') {
$thirdparty = $object;
if ($object->socid > 0) $sendtosocid = $object->socid;
} elseif ($object->element == 'expensereport')
{
if ($object->socid > 0) {
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'expensereport') {
$tmpuser = new User($db);
$tmpuser->fetch($object->fk_user_author);
$thirdparty = $tmpuser;
if ($object->socid > 0) $sendtosocid = $object->socid;
} elseif ($object->element == 'societe')
{
if ($object->socid > 0) {
$sendtosocid = $object->socid;
}
} elseif ($object->element == 'societe') {
$thirdparty = $object;
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
} elseif ($object->element == 'contact')
{
if (is_object($thirdparty) && $thirdparty->id > 0) {
$sendtosocid = $thirdparty->id;
}
} elseif ($object->element == 'contact') {
$contact = $object;
if ($contact->id > 0) {
$contact->fetch_thirdparty();
$thirdparty = $contact->thirdparty;
if (is_object($thirdparty) && $thirdparty->id > 0) $sendtosocid = $thirdparty->id;
if (is_object($thirdparty) && $thirdparty->id > 0) {
$sendtosocid = $thirdparty->id;
}
}
} else dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
} else {
dol_print_error('', "Use actions_sendmails.in.php for an element/object '".$object->element."' that is not supported");
}
if (is_object($hookmanager))
{
if (is_object($hookmanager)) {
$parameters = array();
$reshook = $hookmanager->executeHooks('initSendToSocid', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
}
@ -152,8 +160,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$thirdparty = $mysoc;
}
if ($result > 0)
{
if ($result > 0) {
$sendto = '';
$sendtocc = '';
$sendtobcc = '';
@ -163,48 +170,40 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
// Define $sendto
$receiver = $_POST['receiver'];
if (!is_array($receiver))
{
if ($receiver == '-1') $receiver = array();
else $receiver = array($receiver);
if (!is_array($receiver)) {
if ($receiver == '-1') {
$receiver = array();
} else {
$receiver = array($receiver);
}
}
$tmparray = array();
if (trim($_POST['sendto']))
{
if (trim($_POST['sendto'])) {
// Recipients are provided into free text
$tmparray[] = trim($_POST['sendto']);
}
if (count($receiver) > 0)
{
if (count($receiver) > 0) {
// Recipient was provided from combo list
foreach ($receiver as $key=>$val)
{
if ($val == 'thirdparty') // Key selected means current third party ('thirdparty' may be used for current member or current user too)
{
foreach ($receiver as $key => $val) {
if ($val == 'thirdparty') { // Key selected means current third party ('thirdparty' may be used for current member or current user too)
$tmparray[] = dol_string_nospecial($thirdparty->getFullName($langs), ' ', array(",")).' <'.$thirdparty->email.'>';
}
elseif ($val == 'contact') // Key selected means current contact
{
} elseif ($val == 'contact') { // Key selected means current contact
$tmparray[] = dol_string_nospecial($contact->getFullName($langs), ' ', array(",")).' <'.$contact->email.'>';
$sendtoid[] = $contact->id;
} elseif ($val) // $val is the Id of a contact
{
} elseif ($val) { // $val is the Id of a contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
$sendtoid[] = ((int) $val);
}
}
}
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT))
{
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiveruser = $_POST['receiveruser'];
if (is_array($receiveruser) && count($receiveruser) > 0)
{
if (is_array($receiveruser) && count($receiveruser) > 0) {
$fuserdest = new User($db);
foreach ($receiveruser as $key=>$val)
{
foreach ($receiveruser as $key => $val) {
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtouserid[] = $val;
}
@ -215,32 +214,27 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
// Define $sendtocc
$receivercc = $_POST['receivercc'];
if (!is_array($receivercc))
{
if ($receivercc == '-1') $receivercc = array();
else $receivercc = array($receivercc);
if (!is_array($receivercc)) {
if ($receivercc == '-1') {
$receivercc = array();
} else {
$receivercc = array($receivercc);
}
}
$tmparray = array();
if (trim($_POST['sendtocc']))
{
if (trim($_POST['sendtocc'])) {
$tmparray[] = trim($_POST['sendtocc']);
}
if (count($receivercc) > 0)
{
foreach ($receivercc as $key=>$val)
{
// Recipient was provided from combo list
if ($val == 'thirdparty') // Key selected means currentthird party (may be usd for current member or current user too)
{
if (count($receivercc) > 0) {
foreach ($receivercc as $key => $val) {
if ($val == 'thirdparty') { // Key selected means currentthird party (may be usd for current member or current user too)
// Recipient was provided from combo list
$tmparray[] = dol_string_nospecial($thirdparty->name, ' ', array(",")).' <'.$thirdparty->email.'>';
}
// Recipient was provided from combo list
elseif ($val == 'contact') // Key selected means current contact
{
} elseif ($val == 'contact') { // Key selected means current contact
// Recipient was provided from combo list
$tmparray[] = dol_string_nospecial($contact->name, ' ', array(",")).' <'.$contact->email.'>';
//$sendtoid[] = $contact->id; TODO Add also id of contact in CC ?
} elseif ($val) // $val is the Id of a contact
{
} elseif ($val) { // $val is the Id of a contact
$tmparray[] = $thirdparty->contact_get_property((int) $val, 'email');
//$sendtoid[] = ((int) $val); TODO Add also id of contact in CC ?
}
@ -249,11 +243,9 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
if (!empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) {
$receiverccuser = $_POST['receiverccuser'];
if (is_array($receiverccuser) && count($receiverccuser) > 0)
{
if (is_array($receiverccuser) && count($receiverccuser) > 0) {
$fuserdest = new User($db);
foreach ($receiverccuser as $key=>$val)
{
foreach ($receiverccuser as $key => $val) {
$tmparray[] = $fuserdest->user_get_property($val, 'email');
$sendtoccuserid[] = $val;
}
@ -261,8 +253,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
}
$sendtocc = implode(',', $tmparray);
if (dol_strlen($sendto))
{
if (dol_strlen($sendto)) {
// Define $urlwithroot
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
@ -291,8 +282,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$sql .= ' WHERE rowid = '.(int) $reg[1];
$resql = $db->query($sql);
$obj = $db->fetch_object($resql);
if ($obj)
{
if ($obj) {
$from = dol_string_nospecial($obj->label, ' ', array(",")).' <'.$obj->email.'>';
}
} else {
@ -312,21 +302,20 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$sendtobcc = GETPOST('sendtoccc');
// Autocomplete the $sendtobcc
// $autocopy can be MAIN_MAIL_AUTOCOPY_PROPOSAL_TO, MAIN_MAIL_AUTOCOPY_ORDER_TO, MAIN_MAIL_AUTOCOPY_INVOICE_TO, MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO...
if (!empty($autocopy))
{
if (!empty($autocopy)) {
$sendtobcc .= (empty($conf->global->$autocopy) ? '' : (($sendtobcc ? ", " : "").$conf->global->$autocopy));
}
$deliveryreceipt = $_POST['deliveryreceipt'];
if ($action == 'send' || $action == 'relance')
{
if ($action == 'send' || $action == 'relance') {
$actionmsg2 = $langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from, 4, 0, 1).' '.$langs->transnoentities('at').' '.CMailFile::getValidAddress($sendto, 4, 0, 1);
if ($message)
{
if ($message) {
$actionmsg = $langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto));
if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
if ($sendtocc) {
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".dol_escape_htmltag($sendtocc));
}
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject);
$actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":");
$actionmsg = dol_concatdesc($actionmsg, $message);
@ -343,50 +332,6 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
// Feature to push mail sent into Sent folder
/* This code must be now included into the hook mail, method sendMailAfter
if (! empty($conf->dolimail->enabled))
{
$mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
else
{
$mbid = $mailfromid[1];
// IMAP Postbox
$mailboxconfig = new IMAP($db);
$mailboxconfig->fetch($mbid);
if ($mailboxconfig->mailbox_imap_host) $ref=$mailboxconfig->get_ref();
$mailboxconfig->folder_id=$mailboxconfig->mailbox_imap_outbox;
$mailboxconfig->userfolder_fetch();
if ($mailboxconfig->mailbox_save_sent_mails == 1)
{
$folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
if (!$folder) $folder = "Sent"; // Default Sent folder
$mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
if (false === $mailboxconfig->mbox)
{
$info = false;
$err = $langs->trans('Error3_Imap_Connection_Error');
setEventMessages($err,$mailboxconfig->element, null, 'errors');
}
else
{
$mailboxconfig->mailboxid=$_POST['frommail'];
$mailboxconfig->foldername=$folder;
$from = $mailfromid[0] . $mailfromid[2];
$imap=1;
}
}
}
}
*/
// Make substitution in email content
$substitutionarray = getCommonSubstitutionArray($langs, 0, null, $object);
$substitutionarray['__EMAIL__'] = $sendto;
@ -398,38 +343,38 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$subject = make_substitutions($subject, $substitutionarray);
$message = make_substitutions($message, $substitutionarray);
if (method_exists($object, 'makeSubstitution'))
{
if (method_exists($object, 'makeSubstitution')) {
$subject = $object->makeSubstitution($subject);
$message = $object->makeSubstitution($message);
}
// Send mail (substitutionarray must be done just before this)
if (empty($sendcontext)) $sendcontext = 'standard';
if (empty($sendcontext)) {
$sendcontext = 'standard';
}
$mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1, '', '', $trackid, '', $sendcontext);
if ($mailfile->error)
{
if ($mailfile->error) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
$action = 'presend';
} else {
$result = $mailfile->sendfile();
if ($result)
{
if ($result) {
// Initialisation of datas of object to call trigger
if (is_object($object))
{
if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
if (is_object($object)) {
if (empty($actiontypecode)) {
$actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
}
$object->socid = $sendtosocid; // To link to a company
$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
$object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
$object->actionmsg = $actionmsg; // Long text (@todo Replace this with $message, we already have details of email in dedicated properties)
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
$object->actionmsg2 = $actionmsg2; // Short text ($langs->transnoentities('MailSentBy')...);
$object->trackid = $trackid;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
$object->fk_element = $object->id;
$object->elementtype = $object->element;
if (is_array($attachedfiles) && count($attachedfiles) > 0) {
$object->attachedfiles = $attachedfiles;
}
@ -447,11 +392,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$object->email_msgid = $mailfile->msgid;
// Call of triggers (you should have set $triggersendname to execute trigger. $trigger_name is deprecated)
if (!empty($triggersendname) || !empty($trigger_name))
{
if (!empty($triggersendname) || !empty($trigger_name)) {
// Call trigger
$result = $object->call_trigger(empty($triggersendname) ? $trigger_name : $triggersendname, $user);
if ($result < 0) $error++;
if ($result < 0) {
$error++;
}
// End call triggers
if ($error) {
@ -466,10 +412,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
$mesg = $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2));
setEventMessages($mesg, null, 'mesgs');
$moreparam = '';
if (isset($paramname2) || isset($paramval2)) $moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
exit;
$moreparam = '';
if (isset($paramname2) || isset($paramval2)) {
$moreparam .= '&'.($paramname2 ? $paramname2 : 'mid').'='.$paramval2;
}
header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname ? $paramname : 'id').'='.(is_object($object) ? $object->id : '').$moreparam);
exit;
} else {
$langs->load("other");
$mesg = '<div class="error">';

View File

@ -6668,8 +6668,7 @@ class Form
});
</script>';
if ($acceptdelayedhtml)
{
if ($acceptdelayedhtml) {
$delayedhtmlcontent .= $outdelayed;
} else {
$out .= $outdelayed;
@ -6707,24 +6706,20 @@ class Form
}
// Add code for jquery to use multiselect
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT'))
{
if (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')) {
$out .= "\n".'<!-- JS CODE TO ENABLE select for id '.$htmlname.' -->
<script>'."\n";
if ($addjscombo == 1)
{
if ($addjscombo == 1) {
$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
$out .= 'function formatResult(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
}
$out .= '};'."\n";
$out .= 'function formatSelection(record) {'."\n";
if ($elemtype == 'category')
{
if ($elemtype == 'category') {
$out .= 'return \'<span><img src="'.DOL_URL_ROOT.'/theme/eldy/img/object_category.png"> \'+record.text+\'</span>\';';
} else {
$out .= 'return record.text;';
@ -6741,8 +6736,7 @@ class Form
templateSelection: formatSelection /* For 4.0 */
});
});'."\n";
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT'))
{
} elseif ($addjscombo == 2 && !defined('DISABLE_MULTISELECT')) {
// Add other js lib
// TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin
// ...
@ -6763,20 +6757,18 @@ class Form
// Try also magic suggest
$out .= '<select id="'.$htmlname.'" class="multiselect'.($morecss ? ' '.$morecss : '').'" multiple name="'.$htmlname.'[]"'.($moreattrib ? ' '.$moreattrib : '').($width ? ' style="width: '.(preg_match('/%/', $width) ? $width : $width.'px').'"' : '').'>'."\n";
if (is_array($array) && !empty($array))
{
if ($value_as_key) $array = array_combine($array, $array);
if (is_array($array) && !empty($array)) {
if ($value_as_key) {
$array = array_combine($array, $array);
}
if (!empty($array))
{
foreach ($array as $key => $value)
{
if (!empty($array)) {
foreach ($array as $key => $value) {
$newval = ($translate ? $langs->trans($value) : $value);
$newval = ($key_in_label ? $key.' - '.$newval : $newval);
$out .= '<option value="'.$key.'"';
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != ''))
{
if (is_array($selected) && !empty($selected) && in_array((string) $key, $selected) && ((string) $key != '')) {
$out .= ' selected';
}
$out .= ' data-html="'.dol_escape_htmltag($newval).'"';
@ -6805,36 +6797,36 @@ class Form
{
global $conf, $langs, $user, $extrafields;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
return '';
}
$tmpvar = "MAIN_SELECTEDFIELDS_".$varpage; // To get list of saved seleteced properties
if (!empty($user->conf->$tmpvar))
{
if (!empty($user->conf->$tmpvar)) {
$tmparray = explode(',', $user->conf->$tmpvar);
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
//var_dump($key);
//var_dump($tmparray);
if (in_array($key, $tmparray)) $array[$key]['checked'] = 1;
else $array[$key]['checked'] = 0;
if (in_array($key, $tmparray)) {
$array[$key]['checked'] = 1;
} else {
$array[$key]['checked'] = 0;
}
}
}
$lis = '';
$listcheckedstring = '';
foreach ($array as $key => $val)
{
foreach ($array as $key => $val) {
/* var_dump($val);
var_dump(array_key_exists('enabled', $val));
var_dump(!$val['enabled']);*/
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled'])
{
if (array_key_exists('enabled', $val) && isset($val['enabled']) && !$val['enabled']) {
unset($array[$key]); // We don't want this field
continue;
}
if ($val['label'])
{
if ($val['label']) {
if (!empty($val['langfile']) && is_object($langs)) {
$langs->load($val['langfile']);
}

View File

@ -120,8 +120,16 @@ class FormMail extends Form
public $withtocc;
public $withtoccc;
public $withtopic;
public $withfile; // 0=No attaches files, 1=Show attached files, 2=Can add new attached files
public $withmaindocfile; // 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
/**
* @var int 0=No attaches files, 1=Show attached files, 2=Can add new attached files
*/
public $withfile;
/**
* @var int 1=Add a checkbox "Attach also main document" for mass actions (checked by default), -1=Add checkbox (not checked by default)
*/
public $withmaindocfile;
public $withbody;
public $withfromreadonly;
@ -195,7 +203,9 @@ class FormMail extends Form
// Set tmp user directory
$vardir = $conf->user->dir_output."/".$user->id;
$upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
if (is_dir($upload_dir)) {
dol_delete_dir_recursive($upload_dir);
}
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
unset($_SESSION["listofpaths".$keytoavoidconflict]);
@ -219,15 +229,24 @@ class FormMail extends Form
$listofnames = array();
$listofmimes = array();
if (empty($file)) $file = basename($path);
if (empty($type)) $type = dol_mimetype($file);
if (empty($file)) {
$file = basename($path);
}
if (empty($type)) {
$type = dol_mimetype($file);
}
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!in_array($file, $listofnames))
{
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
if (!in_array($file, $listofnames)) {
$listofpaths[] = $path;
$listofnames[] = $file;
$listofmimes[] = $type;
@ -252,11 +271,16 @@ class FormMail extends Form
$listofmimes = array();
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if ($keytodelete >= 0)
{
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
if ($keytodelete >= 0) {
unset($listofpaths[$keytodelete]);
unset($listofnames[$keytodelete]);
unset($listofmimes[$keytodelete]);
@ -281,9 +305,15 @@ class FormMail extends Form
$listofmimes = array();
$keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) {
$listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofnames".$keytoavoidconflict])) {
$listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
}
if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) {
$listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
}
return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
}

View File

@ -4810,7 +4810,7 @@ function price($amount, $form = 0, $outlangs = '', $trunc = 1, $rounding = -1, $
* 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT)
* 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT)
* 'MS'=Round to Max for stock quantity (MAIN_MAX_DECIMALS_STOCK)
* 'CR'=Currency rate
* 'CR'=Foreign currency accurancy
* Numeric = Nb of digits for rounding
* @param int $option Put 1 if you know that content is already universal format number (so no correction on decimal will be done)
* Put 2 if you know that number is a user input (so we know we don't have to fix decimal separator).
@ -4871,10 +4871,18 @@ function price2num($amount, $rounding = '', $option = 0)
if ($rounding)
{
$nbofdectoround = '';
if ($rounding == 'MU') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
elseif ($rounding == 'MT') $nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
elseif ($rounding == 'MS') $nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
elseif ($rounding == 'CR') $nbofdectoround = 8;
if ($rounding == 'MU') {
$nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_UNIT;
}
elseif ($rounding == 'MT') {
$nbofdectoround = $conf->global->MAIN_MAX_DECIMALS_TOT;
}
elseif ($rounding == 'MS') {
$nbofdectoround = empty($conf->global->MAIN_MAX_DECIMALS_STOCK) ? 5 : $conf->global->MAIN_MAX_DECIMALS_STOCK;
}
elseif ($rounding == 'CR') {
$nbofdectoround = max($conf->global->MAIN_MAX_DECIMALS_TOT, 8);
}
elseif (is_numeric($rounding)) $nbofdectoround = $rounding;
//print "RR".$amount.' - '.$nbofdectoround.'<br>';
if (dol_strlen($nbofdectoround)) $amount = round(is_string($amount) ? (float) $amount : $amount, $nbofdectoround); // $nbofdectoround can be 0.

View File

@ -1332,10 +1332,6 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
// Closure
if (!empty($conf->global->MAIN_FEATURES_LEVEL) && $conf->global->MAIN_FEATURES_LEVEL >= 2) {
$newmenu->add("/accountancy/closure/index.php?mainmenu=accountancy&amp;leftmenu=accountancy_closure", $langs->trans("MenuAccountancyClosure"), 1, $user->rights->accounting->fiscalyear->write, '', $mainmenu, 'closure');
if ($usemenuhider || empty($leftmenu) || preg_match('/accountancy_closure/', $leftmenu)) {
$newmenu->add("/accountancy/closure/validate.php?leftmenu=accountancy_closure", $langs->trans("MenuAccountancyValidationMovements"), 2, $user->rights->accounting->fiscalyear->write);
}
}
// Reports

View File

@ -491,7 +491,9 @@ class FichinterRec extends Fichinter
if (!$info_bits) $info_bits = 0;
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
if ($price_base_type == 'HT') {
$pu = $pu_ht;
@ -499,7 +501,6 @@ class FichinterRec extends Fichinter
$pu = $pu_ttc;
}
// Calcul du total TTC et de la TVA pour la ligne a partir de
// qty, pu, remise_percent et txtva
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker

View File

@ -2546,9 +2546,12 @@ class CommandeFournisseur extends CommonOrder
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
if (!$qty) $qty = 1;
$pu = price2num($pu);
$pu_ht_devise = price2num($pu_ht_devise);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);

View File

@ -356,24 +356,24 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -1175,7 +1175,7 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
@ -1183,17 +1183,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -35,6 +35,16 @@
delete from llx_c_tva;
-- ALGERIA (id country=13)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1);
-- ANGOLA (id country=35)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1);
-- ARGENTINA (id country=23)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (231, 23, '0','0','IVA Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (232, 23,'10.5','0','IVA reduced rate',1);
@ -202,6 +212,13 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 1
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 173, 17, '19','0','Algemeen BTW tarief',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 174, 17, '21','0','Algemeen BTW tarief (vanaf 1 oktober 2012)',0);
-- NEW CALEDONIA (id country=165)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1651, 165, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1652, 165, '3','0','VAT standard 3', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1653, 165, '6','0','VAT standard 6', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1654, 165, '11','0','VAT standard rate', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1655, 165, '22','0','VAT standard high', 1);
-- NEW ZEALAND (id country=166)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1661, 166, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (1662, 166, '15','0','VAT standard rate', 1);
@ -361,16 +378,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1);
-- ALGERIA(id country=13)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1);
-- ANGOLA (id country=35)
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 351, 35, '0','0','VAT Rate 0', 1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 352, 35, '7','0','VAT reduced rate',1);
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 353, 35, '14','0','VAT standard rate',1);
-- Example of code to insert a vat rate 0 for each country
--delete from llx_c_tva where rowid = 1181; -- to delete a record that does not follow rules for rowid (fk_pays+'1')
--insert into llx_c_tva(rowid, fk_pays, taux, recuperableonly, note, active) SELECT CONCAT(c.rowid, '1'), c.rowid, 0, 0, 'No VAT', 1 from llx_c_country as c where c.rowid not in (select fk_pays from llx_c_tva);

View File

@ -387,9 +387,6 @@ ALTER TABLE llx_bank ADD COLUMN origin_id integer;
ALTER TABLE llx_bank ADD COLUMN origin_type varchar(64) NULL;
ALTER TABLE llx_bank ADD COLUMN import_key varchar(14);
ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;
ALTER TABLE llx_menu MODIFY COLUMN enabled text;
CREATE TABLE llx_ecm_files_extrafields

View File

@ -39,3 +39,5 @@ UPDATE llx_adherent SET ref = rowid WHERE ref = '' or ref IS NULL;
ALTER TABLE llx_adherent MODIFY COLUMN ref varchar(30) NOT NULL;
ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_ref (ref, entity);
ALTER TABLE llx_bank_account ADD COLUMN ics varchar(32) NULL;
ALTER TABLE llx_bank_account ADD COLUMN ics_transfer varchar(32) NULL;

View File

@ -475,7 +475,7 @@ UPDATE llx_chargesociales SET date_creation = tms WHERE date_creation IS NULL;
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- VMYSQL4.1 update llx_inventory set date_cre = null where DATE(STR_TO_DATE(date_cre, '%Y-%m-%d')) IS NULL;
-- Note that you can manually set the default value of a date to CURRENT_TIMESTAMP with:
-- Note that you can manually set the default value of a date or datetime to CURRENT_TIMESTAMP with:
--ALTER TABLE llx_table modify column columnname datetime DEFAULT CURRENT_TIMESTAMP;

View File

@ -274,11 +274,13 @@ DescVentilExpenseReport=Consult here the list of expense report lines bound (or
DescVentilExpenseReportMore=If you setup accounting account on type of expense report lines, the application will be able to make all the binding between your expense report lines and the accounting account of your chart of accounts, just in one click with the button <strong>"%s"</strong>. If account was not set on fees dictionary or if you still have some lines not bound to any account, you will have to make a manual binding from the menu "<strong>%s</strong>".
DescVentilDoneExpenseReport=Consult here the list of the lines of expenses reports and their fees accounting account
Closure=Annual closure
DescClosure=Consult here the number of movements by month who are not validated & fiscal years already open
OverviewOfMovementsNotValidated=Step 1/ Overview of movements not validated. (Necessary to close a fiscal year)
AllMovementsWereRecordedAsValidated=All movements were recorded as validated
NotAllMovementsCouldBeRecordedAsValidated=Not all movements could be recorded as validated
ValidateMovements=Validate movements
DescValidateMovements=Any modification or deletion of writing, lettering and deletes will be prohibited. All entries for an exercise must be validated otherwise closing will not be possible
SelectMonthAndValidate=Select month and validate movements
ValidateHistory=Bind Automatically
AutomaticBindingDone=Automatic binding done

View File

@ -92,7 +92,7 @@ MailingModuleDescEmailsFromUser=Emails input by user
MailingModuleDescDolibarrUsers=Users with Emails
MailingModuleDescThirdPartiesByCategories=Third parties (by categories)
SendingFromWebInterfaceIsNotAllowed=Sending from web interface is not allowed.
EmailCollectorFilterDesc=All filters must match to have an email being collected
EmailCollectorFilterDesc=All filters must match to have an email being collected
# Libelle des modules de liste de destinataires mailing
LineInFile=Line %s in file
@ -174,4 +174,4 @@ Unanswered=Unanswered
Answered=Answered
IsNotAnAnswer=Is not answer (initial email)
IsAnAnswer=Is an answer of an initial email
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s
RecordCreatedByEmailCollector=Record created by the Email Collector %s from email %s

View File

@ -540,24 +540,24 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$ref_supplier = GETPOST('fourn_ref', 'alpha');
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') {
$idprod = 0;
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = GETPOST('price_ht');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$tva_tx = '';
}
$qty = GETPOST('qty'.$predef);
$qty = price2num(GETPOST('qty'.$predef), 'alpha');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = GETPOST('multicurrency_price_ht');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CR');
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -416,10 +416,12 @@ class SupplierProposal extends CommonObject
$qty = price2num($qty);
$pu_ht = price2num($pu_ht);
$pu_ttc = price2num($pu_ttc);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);
$pa_ht = price2num($pa_ht);
if ($price_base_type == 'HT')
{
$pu = $pu_ht;
@ -673,7 +675,9 @@ class SupplierProposal extends CommonObject
$remise_percent = price2num($remise_percent);
$qty = price2num($qty);
$pu = price2num($pu);
$txtva = price2num($txtva);
if (!preg_match('/\((.*)\)/', $txtva)) {
$txtva = price2num($txtva); // $txtva can have format '5.0(XXX)' or '5'
}
$txlocaltax1 = price2num($txlocaltax1);
$txlocaltax2 = price2num($txlocaltax2);
$pa_ht = price2num($pa_ht);

View File

@ -167,6 +167,7 @@ var pageactions=0;
var place="<?php echo $place; ?>";
var editaction="qty";
var editnumber="";
var invoiceid=0;
/*
var app = this;
@ -483,8 +484,8 @@ function TakeposOrderNotes() {
}
function Refresh() {
console.log("Refresh by reloading place="+place);
$("#poslines").load("invoice.php?place="+place, function() {
console.log("Refresh by reloading place="+place+" invoiceid="+invoiceid);
$("#poslines").load("invoice.php?place="+place+"&invoiceid="+invoiceid, function() {
//$('#poslines').scrollTop($('#poslines')[0].scrollHeight);
});
}

View File

@ -1000,7 +1000,7 @@ function CreditNote() {
$( document ).ready(function() {
console.log("Set customer info and sales in header");
console.log("Set customer info and sales in header placeid=<?php echo $placeid; ?> status=<?php echo $invoice->statut; ?>");
<?php
$s = $langs->trans("Customer");
@ -1015,7 +1015,16 @@ $( document ).ready(function() {
<?php
$sql = "SELECT rowid, datec, ref FROM ".MAIN_DB_PREFIX."facture";
$sql .= " WHERE ref LIKE '(PROV-POS".$_SESSION["takeposterminal"]."-0%' AND entity IN (".getEntity('invoice').")";
if (empty($conf->global->TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED)) {
// By default, only invoices with a ref not already defined can in list of open invoice we can edit.
$sql .= " WHERE ref LIKE '(PROV-POS".$db->escape($_SESSION["takeposterminal"])."-0%' AND entity IN (".getEntity('invoice').")";
} else {
// If TAKEPOS_CAN_EDIT_IF_ALREADY_VALIDATED set, we show also draft invoice that already has a reference defined
$sql .= " WHERE pos_source = '".$db->escape($_SESSION["takeposterminal"])."'";
$sql .= " AND module_source = 'takepos'";
$sql .= " AND entity IN (".getEntity('invoice').")";
}
$sql .= $db->order('datec', 'ASC');
$resql = $db->query($sql);
if ($resql) {
@ -1025,7 +1034,9 @@ $( document ).ready(function() {
$num_sale = str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $obj->ref));
echo $num_sale;
if (str_replace("-", "", $num_sale) > $max_sale) $max_sale = str_replace("-", "", $num_sale);
echo '\\\';Refresh();">';
echo '\\\'; invoiceid=\\\'';
echo $obj->rowid;
echo '\\\'; Refresh();">';
if ($placeid == $obj->rowid) echo "<b>";
echo dol_print_date($db->jdate($obj->datec), '%H:%M', 'tzuser');
if ($placeid == $obj->rowid) echo "</b>";
@ -1033,7 +1044,7 @@ $( document ).ready(function() {
}
echo '$("#customerandsales").append(\'<a onclick="place=\\\'0-';
echo $max_sale + 1;
echo '\\\';Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
echo '\\\'; invoiceid=0; Refresh();"><span class="fa fa-plus-square" title="'.dol_escape_htmltag($langs->trans("StartAParallelSale")).'"></a>\');';
} else {
dol_print_error($db);
}

View File

@ -329,8 +329,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
'supplier_code' => $thirdparty->code_fournisseur,
'customer_code_accountancy' => $thirdparty->code_compta,
'supplier_code_accountancy' => $thirdparty->code_compta_fournisseur,
'fk_user_author' => $thirdparty->fk_user_author,
'user_creation' => $thirdparty->user_creation,
'date_creation' => dol_print_date($thirdparty->date_creation, 'dayhourrfc'),
'user_modification' => $thirdparty->user_modification,
'date_modification' => dol_print_date($thirdparty->date_modification, 'dayhourrfc'),
'address' => $thirdparty->address,
'zip' => $thirdparty->zip,
@ -369,7 +370,9 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key]));
if (isset($thirdparty->array_options['options_'.$key])) {
$thirdparty_result_fields = array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key]));
}
}
}
@ -622,7 +625,9 @@ function updateThirdParty($authentication, $thirdparty)
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$key = 'options_'.$key;
$object->array_options[$key] = $thirdparty[$key];
if (isset($thirdparty[$key])) {
$object->array_options[$key] = $thirdparty[$key];
}
}
}
@ -727,7 +732,9 @@ function getListOfThirdParties($authentication, $filterthirdparty)
{
foreach ($extrafields->attributes[$elementtype]['label'] as $key => $label)
{
$extrafieldsOptions['options_'.$key] = $obj->{$key};
if (isset($obj->{$key})) {
$extrafieldsOptions['options_'.$key] = $obj->{$key};
}
}
}