Merge remote-tracking branch 'Dolibarr/13.0' into 13

This commit is contained in:
Francis Appels 2021-03-03 11:09:02 +01:00
commit bf7a4a34cf
28 changed files with 166 additions and 107 deletions

View File

@ -50,15 +50,16 @@ if (empty($argv[1])) {
print "Example: ".$script_file." release=6.0.0 includecustom=1 includeconstant=FR:INVOICE_CAN_ALWAYS_BE_REMOVED:0 includeconstant=all:MAILING_NO_USING_PHPMAIL:1\n";
exit -1;
}
parse_str($argv[1]);
$i=0;
while ($i < $argc) {
if (! empty($argv[$i])) parse_str($argv[$i]);
if (preg_match('/includeconstant=/', $argv[$i])) {
$tmp=explode(':', $includeconstant, 3);
$tmp=explode(':', $includeconstant, 3); // $includeconstant has been set with previous parse_str()
if (count($tmp) != 3) {
print "Error: Bad parameter includeconstant ".$includeconstant."\n";
print "Error: Bad parameter includeconstant=".$includeconstant."\n";
exit -1;
}
$includeconstants[$tmp[0]][$tmp[1]] = $tmp[2];
@ -151,7 +152,7 @@ $iterator1 = new RecursiveIteratorIterator($dir_iterator1);
$files = new RegexIterator($iterator1, '#^(?:[A-Z]:)?(?:/(?!(?:'.($includecustom?'':'custom\/|').'documents\/|conf\/|install\/))[^/]+)+/[^/]+\.(?:php|css|html|js|json|tpl|jpg|png|gif|sql|lang)$#i');
*/
$regextoinclude='\.(php|php3|php4|php5|phtml|phps|phar|inc|css|scss|html|xml|js|json|tpl|jpg|jpeg|png|gif|ico|sql|lang|txt|yml|md|mp3|mp4|wav|mkv|z|gz|zip|rar|tar|less|svg|eot|woff|woff2|ttf|manifest)$';
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$regextoexclude='('.($includecustom?'':'custom|').'documents|conf|install|dejavu-fonts-ttf-.*|public\/test|sabre\/sabre\/.*\/tests|Shared\/PCLZip|nusoap\/lib\/Mail|php\/example|php\/test|geoip\/sample.*\.php|ckeditor\/samples|ckeditor\/adapters)$'; // Exclude dirs
$files = dol_dir_list(DOL_DOCUMENT_ROOT, 'files', 1, $regextoinclude, $regextoexclude, 'fullname');
$dir='';

View File

@ -390,6 +390,9 @@ if ($nboftargetok) {
$olddir=getcwd();
chdir("$SOURCE");
print "Clean $SOURCE/htdocs\n";
$ret=`rm -f $SOURCE/htdocs/includes/autoload.php`;
$ret=`git ls-files . --exclude-standard --others`;
if ($ret)
{
@ -613,7 +616,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/parsedown/LICENSE.txt`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/stripe/tests`;
@ -623,7 +625,6 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/freefont-*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/ae_fonts_*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/fonts/utils`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/LICENSE.TXT`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/tecnickcom/tcpdf/tools`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/vendor`;
$ret=`rm -f $BUILDROOT/$PROJECT/htdocs/includes/webmozart`;

View File

@ -796,9 +796,9 @@ if (empty($reshook))
} elseif ($action == 'addline' && $usercancreate) { // Add line
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ?GETPOST('dp_desc', 'restricthtml') : '');
$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', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
@ -1153,10 +1153,11 @@ if (empty($reshook))
{
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', GETPOST('tva_tx')))
if (preg_match('/\*/', GETPOST('tva_tx'))) {
$info_bits |= 0x01;
}
// Clean parameters
// Clean parameters
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
// Define vat_rate
@ -1164,13 +1165,13 @@ if (empty($reshook))
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
// Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
@ -1313,7 +1314,7 @@ if (empty($reshook))
$result = $object->setMulticurrencyCode(GETPOST('multicurrency_code', 'alpha'));
} // Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} // bank account
elseif ($action == 'setbankaccount' && $usercancreate) {
$result = $object->setBankAccount(GETPOST('fk_account', 'int'));

View File

@ -549,7 +549,7 @@ if (empty($reshook))
// Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} elseif ($action == 'setavailability' && $usercancreate) {
$result = $object->availability(GETPOST('availability_id'));
if ($result < 0)
@ -632,8 +632,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free')
{
@ -989,14 +989,15 @@ if (empty($reshook))
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ?GETPOST('tva_tx') : 0);
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
if (preg_match('/\*/', $vat_rate)) {
$info_bits |= 0x01;
}
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);

View File

@ -438,8 +438,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -724,10 +724,10 @@ if (empty($reshook))
//$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
//$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;

View File

@ -377,7 +377,7 @@ if (empty($reshook))
} elseif ($action == 'setinvoicedate' && $usercancreate) {
$object->fetch($id);
$old_date_lim_reglement = $object->date_lim_reglement;
$date = dol_mktime(12, 0, 0, $_POST['invoicedatemonth'], $_POST['invoicedateday'], $_POST['invoicedateyear']);
$date = dol_mktime(12, 0, 0, GETPOST('invoicedatemonth', 'int'), GETPOST('invoicedateday', 'int'), GETPOST('invoicedateyear', 'int'));
if (empty($date))
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
@ -1895,8 +1895,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'));
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'));
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha');
if ($prod_entry_mode == 'free')
{
@ -2216,10 +2216,10 @@ if (empty($reshook))
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
$pu_ht = GETPOST('price_ht');
$pu_ht = price2num(GETPOST('price_ht'), '', 2);
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Define info_bits
$info_bits = 0;

View File

@ -1192,6 +1192,7 @@ class Facture extends CommonInvoice
if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
{
unset($object->lines[$i]);
continue;
}
// Bloc to update dates of service (month by month only if previously filled and similare to start and end of month)
@ -1218,7 +1219,7 @@ class Facture extends CommonInvoice
}
}
$object->lines[$i]->ref_ext = ''; // Do not clone ref_ext
$object->lines[$i]->ref_ext = ''; // Do not clone ref_ext
}
// Create clone

View File

@ -384,8 +384,8 @@ if (empty($reshook))
// Set if we used free entry or predefined product
$predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CU'));
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
if (GETPOST('prod_entry_mode', 'alpha') == 'free')
{
$idprod = 0;
@ -638,8 +638,9 @@ if (empty($reshook))
$vat_rate = GETPOST('eltva_tx');
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
if (preg_match('/\*/', $vat_rate)) {
$info_bits |= 0x01;
}
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);
@ -658,10 +659,12 @@ if (empty($reshook))
}
// ajout prix d'achat
$fk_fournprice = $_POST['fournprice'];
if (!empty($_POST['buying_price']))
$pa_ht = $_POST['buying_price'];
else $pa_ht = null;
$fk_fournprice = GETPOST('fournprice');
if (GETPOST('buying_price')) {
$pa_ht = price2num(GETPOST('buying_price'), '', 2);
} else {
$pa_ht = null;
}
$fk_unit = GETPOST('unit', 'alpha');

View File

@ -5878,6 +5878,7 @@ abstract class CommonObject
$out = '';
$type = '';
$isDependList=0;
$param = array();
$param['options'] = array();
$reg = array();
@ -5916,6 +5917,7 @@ abstract class CommonObject
$type = $this->fields[$key]['type'];
}
$label = $this->fields[$key]['label'];
//$elementtype=$this->fields[$key]['elementtype']; // Seems not used
$default = $this->fields[$key]['default'];
@ -6058,7 +6060,6 @@ abstract class CommonObject
// 4 : where clause filter on column or table extrafield, syntax field='value' or extra.field=value
$keyList = (empty($InfoFieldList[2]) ? 'rowid' : $InfoFieldList[2].' as rowid');
if (count($InfoFieldList) > 4 && !empty($InfoFieldList[4])) {
if (strpos($InfoFieldList[4], 'extra.') !== false) {
$keyList = 'main.'.$InfoFieldList[2].' as rowid';
@ -6172,6 +6173,7 @@ abstract class CommonObject
if (!empty($InfoFieldList[3]) && $parentField)
{
$parent = $parentName.':'.$obj->{$parentField};
$isDependList=1;
}
$out .= '<option value="'.$obj->rowid.'"';
@ -6328,6 +6330,7 @@ abstract class CommonObject
if (!empty($InfoFieldList[3]) && $parentField) {
$parent = $parentName.':'.$obj->{$parentField};
$isDependList=1;
}
$data[$obj->rowid] = $labeltoshow;
@ -6414,6 +6417,10 @@ abstract class CommonObject
if (!empty($hidden)) {
$out = '<input type="hidden" value="'.$value.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'"/>';
}
if ($isDependList==1) {
$out .= $this->getJSListDependancies('_common');
}
/* Add comments
if ($type == 'date') $out.=' (YYYY-MM-DD)';
elseif ($type == 'datetime') $out.=' (YYYY-MM-DD HH:MM:SS)';
@ -6981,10 +6988,28 @@ abstract class CommonObject
$out .= "\n";
// Add code to manage list depending on others
if (!empty($conf->use_javascript_ajax)) {
$out .= '
$out .= $this->getJSListDependancies();
}
$out .= '<!-- /showOptionals --> '."\n";
}
}
$out .= $hookmanager->resPrint;
return $out;
}
/**
* @param string $type Type for prefix
* @return string Javacript code to manage dependency
*/
public function getJSListDependancies($type = '_extra')
{
$out .= '
<script>
jQuery(document).ready(function() {
function showOptions(child_list, parent_list, orig_select)
function showOptions'.$type.'(child_list, parent_list, orig_select)
{
var val = $("select[name=\""+parent_list+"\"]").val();
var parentVal = parent_list + ":" + val;
@ -6998,7 +7023,7 @@ abstract class CommonObject
$("select[name=\""+child_list+"\"]").append(options);
}
}
function setListDependencies() {
function setListDependencies'.$type.'() {
jQuery("select option[parent]").parent().each(function() {
var orig_select = {};
var child_list = $(this).attr("name");
@ -7007,26 +7032,17 @@ abstract class CommonObject
var infos = parent.split(":");
var parent_list = infos[0];
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list, orig_select[child_list]);
showOptions'.$type.'(child_list, parent_list, orig_select[child_list]);
});
});
}
setListDependencies();
setListDependencies'.$type.'();
});
</script>'."\n";
}
$out .= '<!-- /showOptionals --> '."\n";
}
}
$out .= $hookmanager->resPrint;
return $out;
}
/**
* Returns the rights used for this class
* @return stdClass

View File

@ -634,13 +634,13 @@ class dolReceiptPrinter extends Printer
if ($line->fk_product)
{
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
}
else {
$spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
}
}
@ -653,7 +653,7 @@ class dolReceiptPrinter extends Printer
}
foreach ($vatarray as $vatkey => $vatvalue) {
$spacestoadd = $nbcharactbyline - strlen($vatkey) - 12;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($spaces.$vatkey.'% '.str_pad(price($vatvalue), 10, ' ', STR_PAD_LEFT)."\n");
}
break;
@ -680,15 +680,15 @@ class dolReceiptPrinter extends Printer
case 'DOL_PRINT_OBJECT_TOTAL':
$title = $langs->trans('TotalHT');
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($title.$spaces.str_pad(price($object->total_ht), 10, ' ', STR_PAD_LEFT)."\n");
$title = $langs->trans('TotalVAT');
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($title.$spaces.str_pad(price($object->total_tva), 10, ' ', STR_PAD_LEFT)."\n");
$title = $langs->trans('TotalTTC');
$spacestoadd = $nbcharactbyline - strlen($title) - 10;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($title.$spaces.str_pad(price($object->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
break;
case 'DOL_LINE_FEED':
@ -778,7 +778,7 @@ class dolReceiptPrinter extends Printer
if ($line->special_code == $this->orderprinter)
{
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->desc))."\n");
}
@ -799,14 +799,14 @@ class dolReceiptPrinter extends Printer
while ($i < $num) {
$row = $this->db->fetch_object($resql);
$spacestoadd = $nbcharactbyline - strlen($langs->transnoentitiesnoconv("PaymentTypeShort".$row->code)) - 12;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$amount_payment = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount;
if ($row->code == "LIQ") $amount_payment = $amount_payment + $row->pos_change; // Show amount with excess received if is cash payment
$this->printer->text($spaces.$langs->transnoentitiesnoconv("PaymentTypeShort".$row->code).' '.str_pad(price($amount_payment), 10, ' ', STR_PAD_LEFT)."\n");
if ($row->code == "LIQ" && $row->pos_change > 0) // Print change only in cash payments
{
$spacestoadd = $nbcharactbyline - strlen($langs->trans("Change")) - 12;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($spaces.$langs->trans("Change").' '.str_pad(price($row->pos_change), 10, ' ', STR_PAD_LEFT)."\n");
}
$i++;

View File

@ -4892,8 +4892,8 @@ class Form
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="text" class="maxwidth100" name="'.$htmlname.'" value="'.(!empty($rate) ? price(price2num($rate, 'CU')) : 1).'" /> ';
print '<select name="calculation_mode">';
print '<option value="1">'.$currency.' > '.$conf->currency.'</option>';
print '<option value="2">'.$conf->currency.' > '.$currency.'</option>';
print '<option value="1">Change '.$langs->trans("PriceUHT").' of lines</option>';
print '<option value="2">Change '.$langs->trans("PriceUHTCurrency").' of lines</option>';
print '</select> ';
print '<input type="submit" class="button smallpaddingimp valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';

View File

@ -1985,7 +1985,7 @@ function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs =
global $conf, $langs;
if ($tzoutput === 'auto') {
$tzoutput = (empty($conf) ? 'tzserver' : $conf->tzuserinputkey);
$tzoutput = (empty($conf) ? 'tzserver' : (isset($conf->tzuserinputkey) ? $conf->tzuserinputkey : 'tzserver'));
}
// Clean parameters
@ -4871,7 +4871,7 @@ function price2num($amount, $rounding = '', $option = 0)
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
}
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come from input data, so 1.123 is 1123
$amount = str_replace($thousand, '', $amount);
}

View File

@ -51,7 +51,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
}
// Check parameters
if (count($addfieldentry) > 0)
if (is_array($addfieldentry) && count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{

View File

@ -43,8 +43,7 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
$login = '';
// Get identity from user and redirect browser to OpenID Server
if (GETPOSISSET('username'))
{
if (GETPOSTISSET('username')) {
$openid = new SimpleOpenID();
$openid->SetIdentity($_POST['username']);
$protocol = ($conf->file->main_force_https ? 'https://' : 'http://');
@ -61,10 +60,8 @@ function check_user_password_openid($usertotest, $passwordtotest, $entitytotest)
return false;
}
return false;
}
// Perform HTTP Request to OpenID server to validate key
elseif ($_GET['openid_mode'] == 'id_res')
{
} elseif ($_GET['openid_mode'] == 'id_res') {
// Perform HTTP Request to OpenID server to validate key
$openid = new SimpleOpenID();
$openid->SetIdentity($_GET['openid_identity']);
$openid_validation_result = $openid->ValidateWithServer();

View File

@ -273,6 +273,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetAutoPageBreak(1, 0);
$heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
if ($heightforinfotot > 220) {
$heightforinfotot = 220;
}
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;

View File

@ -1090,4 +1090,21 @@ class Don extends CommonObject
return 0;
}
}
/**
* Function used to replace a thirdparty id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old third-party id
* @param int $dest_id New third-party id
* @return bool
*/
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'don'
);
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}

View File

@ -576,14 +576,12 @@ if (empty($reshook))
*/
elseif ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save', 'alpha') == $langs->trans("Save")) {
$objectline = new FichinterLigne($db);
if ($objectline->fetch($lineid) <= 0)
{
if ($objectline->fetch($lineid) <= 0) {
dol_print_error($db);
exit;
}
if ($object->fetch($objectline->fk_fichinter) <= 0)
{
if ($object->fetch($objectline->fk_fichinter) <= 0) {
dol_print_error($db);
exit;
}
@ -603,8 +601,7 @@ if (empty($reshook))
$objectline->array_options = $array_options;
$result = $objectline->update($user);
if ($result < 0)
{
if ($result < 0) {
dol_print_error($db);
exit;
}
@ -614,8 +611,7 @@ if (empty($reshook))
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (!empty($newlang))
{
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}

View File

@ -204,4 +204,21 @@ class Fournisseur extends Societe
}
return $arr;
}
/**
* Function used to replace a thirdparty id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old third-party id
* @param int $dest_id New third-party id
* @return bool
*/
public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id)
{
$tables = array(
'facture_fourn'
);
return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}

View File

@ -1203,7 +1203,7 @@ class FactureFournisseur extends CommonInvoice
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$ref = dol_sanitizeFileName($this->ref);
$dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoive_supplier').$ref;
$dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($this->id, 2, 0, 0, $this, 'invoice_supplier').$ref;
$file = $dir."/".$ref.".pdf";
if (file_exists($file))
{

View File

@ -190,7 +190,7 @@ if (empty($reshook))
// Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
}
// bank account
@ -363,17 +363,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -689,7 +689,7 @@ if (empty($reshook))
if (GETPOST('price_ht') != '')
{
$price_base_type = 'HT';
$ht = price2num(GETPOST('price_ht'));
$ht = price2num(GETPOST('price_ht'), '', 2);
} else {
$vatratecleaned = $vat_rate;
if (preg_match('/^(.*)\s*\((.*)\)$/', $vat_rate, $reg)) // If vat is "xx (yy)"
@ -698,12 +698,12 @@ if (empty($reshook))
$vatratecode = $reg[2];
}
$ttc = price2num(GETPOST('price_ttc'));
$ttc = price2num(GETPOST('price_ttc'), '', 2);
$ht = $ttc / (1 + ($vatratecleaned / 100));
$price_base_type = 'HT';
}
$pu_ht_devise = GETPOST('multicurrency_subprice');
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
// Extrafields Lines
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -462,13 +462,13 @@ if ($action == 'updateline' && $user->rights->fournisseur->commande->receptionne
$qty = $supplierorderdispatch->qty;
$entrepot = $supplierorderdispatch->fk_entrepot;
$product = $supplierorderdispatch->fk_product;
$price = GETPOST('price');
$price = price2num(GETPOST('price'), '', 2);
$comment = $supplierorderdispatch->comment;
$eatby = $supplierorderdispatch->fk_product;
$sellby = $supplierorderdispatch->sellby;
$batch = $supplierorderdispatch->batch;
$supplierorderdispatch->qty = GETPOST('qty', 'int');
$supplierorderdispatch->qty = price2num(GETPOST('qty', 'alpha'), 'MS', 2);
$supplierorderdispatch->fk_entrepot = GETPOST('fk_entrepot');
$result = $supplierorderdispatch->update($user);
}

View File

@ -366,7 +366,7 @@ if (empty($reshook))
// Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha')));
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx', 'alpha')), GETPOST('calculation_mode', 'int'));
}
// bank account
@ -1079,12 +1079,11 @@ if (empty($reshook))
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '')
{
$up = price2num(GETPOST('price_ht'));
if (GETPOST('price_ht') != '' || GETPOST('multicurrency_subprice') != '') {
$up = price2num(GETPOST('price_ht'), '', 2);
$price_base_type = 'HT';
} else {
$up = price2num(GETPOST('price_ttc'));
$up = price2num(GETPOST('price_ttc'), '', 2);
$price_base_type = 'TTC';
}
@ -1183,17 +1182,17 @@ if (empty($reshook))
if ($prod_entry_mode == 'free')
{
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);

View File

@ -361,7 +361,7 @@ UnitPriceHTCurrency=Unit price (excl.) (currency)
UnitPriceTTC=Unit price
PriceU=U.P.
PriceUHT=U.P. (net)
PriceUHTCurrency=U.P (currency)
PriceUHTCurrency=U.P (net) (currency)
PriceUTTC=U.P. (inc. tax)
Amount=Amount
AmountInvoice=Invoice amount

View File

@ -361,7 +361,7 @@ UnitPriceHTCurrency=Prix unitaire (HT) (devise)
UnitPriceTTC=Prix unitaire TTC
PriceU=P.U.
PriceUHT=P.U. HT
PriceUHTCurrency=P.U. (devise)
PriceUHTCurrency=P.U. HT (devise)
PriceUTTC=P.U TTC
Amount=Montant
AmountInvoice=Montant facture

View File

@ -4374,6 +4374,10 @@ class Product extends CommonObject
{
global $alreadyfound;
if (empty($id)) {
return array();
}
$sql = "SELECT p.rowid, p.ref, p.label as label, p.fk_product_type,";
$sql .= " pa.qty as qty, pa.fk_product_fils as id, pa.incdec";
$sql .= " FROM ".MAIN_DB_PREFIX."product as p,";
@ -4387,7 +4391,8 @@ class Product extends CommonObject
if ($level == 1) { $alreadyfound = array($id=>1); // We init array of found object to start of tree, so if we found it later (should not happened), we stop immediatly
}
// Protection against infinite loop
if ($level > 30) { return array();
if ($level > 30) {
return array();
}
$res = $this->db->query($sql);

View File

@ -423,7 +423,6 @@ if ($object->id > 0)
print '</tr>';
// Line to add a new line in inventory
//if ($action == 'addline') {
if ($object->status == $object::STATUS_VALIDATED) {
print '<tr>';
print '<td>';

View File

@ -232,6 +232,7 @@ if (empty($reshook))
// TODO Mutualise the list into object societe.class.php
$objects = array(
'Adherent' => '/adherents/class/adherent.class.php',
'Don' => '/don/class/don.class.php',
'Societe' => '/societe/class/societe.class.php',
//'Categorie' => '/categories/class/categorie.class.php',
'ActionComm' => '/comm/action/class/actioncomm.class.php',
@ -265,6 +266,7 @@ if (empty($reshook))
{
$error++;
setEventMessages($db->lasterror(), null, 'errors');
break;
}
}
}

View File

@ -547,17 +547,17 @@ if (empty($reshook))
$prod_entry_mode = GETPOST('prod_entry_mode');
if ($prod_entry_mode == 'free') {
$idprod = 0;
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
} else {
$idprod = GETPOST('idprod', 'int');
$price_ht = price2num(GETPOST('price_ht'), 'MU');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$tva_tx = '';
}
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = GETPOST('remise_percent'.$predef);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU');
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
// Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -853,7 +853,7 @@ if (empty($reshook))
if (GETPOST('price_ht') != '')
{
$ht = price2num(GETPOST('price_ht'));
$ht = price2num(GETPOST('price_ht'), '', 2);
}
if (GETPOST('price_ttc') != '')
@ -866,7 +866,7 @@ if (empty($reshook))
$vatratecode = $reg[2];
}
$ttc = price2num(GETPOST('price_ttc'));
$ttc = price2num(GETPOST('price_ttc'), '', 2);
$ht = $ttc / (1 + ($vatratecleaned / 100));
}
@ -1037,7 +1037,7 @@ if (empty($reshook))
// Multicurrency rate
elseif ($action == 'setmulticurrencyrate' && $usercancreate) {
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')));
$result = $object->setMulticurrencyRate(price2num(GETPOST('multicurrency_tx')), GETPOST('calculation_mode', 'int'));
} elseif ($action == 'update_extras') {
$object->oldcopy = dol_clone($object);