Merge branch '10.0' of https://github.com/dolibarr/dolibarr into 10.0
This commit is contained in:
commit
6851e24c3b
@ -252,6 +252,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
||||
$sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND fd.product_type <= 2";
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
@ -329,6 +330,7 @@ $sql .= " WHERE f.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND fd.product_type <= 2";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
@ -406,6 +408,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND fd.product_type <= 2";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
@ -458,6 +461,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
$sql .= " AND f.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND f.entity IN (" . getEntity('invoice', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND f.fk_statut > 0";
|
||||
$sql .= " AND fd.product_type <= 2";
|
||||
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
|
||||
$sql .= " AND f.type IN (" . Facture::TYPE_STANDARD . "," . Facture::TYPE_REPLACEMENT . "," . Facture::TYPE_CREDIT_NOTE . "," . Facture::TYPE_SITUATION . ")";
|
||||
} else {
|
||||
|
||||
@ -255,7 +255,9 @@ if ($result) {
|
||||
} else {
|
||||
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
|
||||
}
|
||||
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
|
||||
|
||||
// Load of url links to the line into llx_bank
|
||||
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
|
||||
|
||||
//var_dump($i);
|
||||
//var_dump($tabpay);
|
||||
@ -322,7 +324,8 @@ if ($result) {
|
||||
$chargestatic->id = $links[$key]['url_id'];
|
||||
$chargestatic->ref = $links[$key]['url_id'];
|
||||
|
||||
$tabpay[$obj->rowid]["lib"] .= ' ' . $chargestatic->getNomUrl(2);
|
||||
$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
|
||||
$reg = array();
|
||||
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
|
||||
if ($reg[1] == 'socialcontribution')
|
||||
$reg[1] = 'SocialContribution';
|
||||
@ -334,12 +337,14 @@ if ($result) {
|
||||
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
|
||||
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
|
||||
|
||||
// Retreive the accounting code of the social contribution of the payment from link of payment.
|
||||
// Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
|
||||
$sqlmid = 'SELECT cchgsoc.accountancy_code';
|
||||
$sqlmid .= " FROM " . MAIN_DB_PREFIX . "c_chargesociales cchgsoc ";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
|
||||
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
|
||||
$sqlmid .= " WHERE bkurl.fk_bank=" . $obj->rowid;
|
||||
$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
|
||||
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
|
||||
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
|
||||
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'";
|
||||
$sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
|
||||
|
||||
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);
|
||||
$resultmid = $db->query($sqlmid);
|
||||
@ -666,7 +671,7 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
} elseif ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = $k;
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $tabpay[$obj->rowid]["account_various"];
|
||||
$bookkeeping->numero_compte = $tabpay[$key]["account_various"];
|
||||
|
||||
$accountingaccount->fetch(null, $bookkeeping->numero_compte, true);
|
||||
$bookkeeping->label_compte = $accountingaccount->label;
|
||||
@ -1174,7 +1179,12 @@ if (empty($action) || $action == 'view') {
|
||||
//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
|
||||
if (! empty($tabcompany[$key]['code_compta']))
|
||||
{
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
|
||||
if (in_array($tabtype[$key], array('payment_various'))) {
|
||||
// For such case, if subledger is not defined, we won't use subledger accounts.
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>';
|
||||
} else {
|
||||
print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -250,6 +250,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ffd.product_type <= 2";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NULL";
|
||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -321,6 +322,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON aa.rowid
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ffd.product_type <= 2";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
$sql .= " AND aa.account_number IS NOT NULL";
|
||||
$sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
|
||||
@ -392,6 +394,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange.
|
||||
$sql .= " WHERE ff.datef >= '" . $db->idate($search_date_start) . "'";
|
||||
$sql .= " AND ff.datef <= '" . $db->idate($search_date_end) . "'";
|
||||
$sql .= " AND ff.fk_statut > 0";
|
||||
$sql .= " AND ffd.product_type <= 2";
|
||||
$sql .= " AND ff.entity IN (" . getEntity('facture_fourn', 0) . ")"; // We don't share object for accountancy
|
||||
|
||||
dol_syslog('htdocs/accountancy/supplier/index.php');
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Oscss-Shop <support@oscss-shop.fr>.
|
||||
* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modifyion 2.0 (the "License");
|
||||
* it under the terms of the GNU General Public License as published bypliance with the License.
|
||||
@ -17,6 +18,9 @@
|
||||
*/
|
||||
|
||||
if (!defined('REQUIRE_JQUERY_BLOCKUI')) define('REQUIRE_JQUERY_BLOCKUI', 1);
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -99,6 +99,7 @@ $trigger_name=''; // Disable triggers
|
||||
$paramname='id';
|
||||
$mode='emailfortest';
|
||||
$trackid=(($action == 'testhtml')?"testhtml":"test");
|
||||
$sendcontext='';
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
|
||||
|
||||
if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') $action='test';
|
||||
@ -791,8 +792,8 @@ else
|
||||
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$mail = new CMailFile('', '', '', '');
|
||||
$result=$mail->check_server_port($server, $port);
|
||||
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
|
||||
$result = $mail->check_server_port($server, $port);
|
||||
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
|
||||
else
|
||||
{
|
||||
|
||||
@ -536,8 +536,9 @@ else
|
||||
print load_fiche_titre($langs->trans("DoTestServerAvailability"));
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
|
||||
$mail = new CMailFile('', '', '', '');
|
||||
$result=$mail->check_server_port($server, $port);
|
||||
$mail = new CMailFile('', '', '', '', array(), array(), array(), '', '', 0, '', '', '', '', $trackid, $sendcontext);
|
||||
|
||||
$result = $mail->check_server_port($server, $port);
|
||||
if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
|
||||
else
|
||||
{
|
||||
|
||||
@ -166,6 +166,7 @@ if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans(
|
||||
if ($conf->adherent->enabled) $elementList['member']=$langs->trans('MailToMember');
|
||||
if ($conf->contrat->enabled) $elementList['contract']=$langs->trans('MailToSendContract');
|
||||
if ($conf->projet->enabled) $elementList['project']=$langs->trans('MailToProject');
|
||||
if ($conf->ticket->enabled) $elementList['ticket_send']=$langs->trans('MailToTicket');
|
||||
$elementList['user']=$langs->trans('MailToUser');
|
||||
|
||||
$parameters=array('elementList'=>$elementList);
|
||||
|
||||
@ -221,6 +221,7 @@ print '<tr '.$bc[false].'><td style="padding-left: 8px">';
|
||||
<div class="formelementrow"><input type="checkbox"
|
||||
name="use_transaction" value="yes" id="checkbox_use_transaction" /> <label
|
||||
for="checkbox_use_transaction"> <?php echo $langs->trans("UseTransactionnalMode"); ?></label>
|
||||
|
||||
</div>
|
||||
|
||||
<?php if (! empty($conf->global->MYSQL_OLD_OPTION_DISABLE_FK)) { ?>
|
||||
|
||||
@ -603,7 +603,7 @@ class Setup extends DolibarrApi
|
||||
|
||||
$sql = "SELECT rowid AS id, zip, town, fk_county, fk_pays AS fk_country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_ziptown as t";
|
||||
$sql.= " AND t.active = ".$active;
|
||||
$sql.= " WHERE t.active = ".$active;
|
||||
if ($zipcode) $sql.=" AND t.zip LIKE '%" . $this->db->escape($zipcode) . "%'";
|
||||
if ($town) $sql.=" AND t.town LIKE '%" . $this->db->escape($town) . "%'";
|
||||
// Add sql filters
|
||||
|
||||
@ -595,6 +595,7 @@ class ActionComm extends CommonObject
|
||||
|
||||
$sql = "SELECT a.id,";
|
||||
$sql.= " a.id as ref,";
|
||||
$sql.= " a.entity,";
|
||||
$sql.= " a.ref_ext,";
|
||||
$sql.= " a.datep,";
|
||||
$sql.= " a.datep2,";
|
||||
@ -631,6 +632,7 @@ class ActionComm extends CommonObject
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->id;
|
||||
$this->entity = $obj->entity;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_ext = $obj->ref_ext;
|
||||
|
||||
|
||||
@ -1065,7 +1065,7 @@ if ($object->id > 0)
|
||||
print '<table class="noborder centpercent lastrecordtable">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num<=$MAXLIST?"":$MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").' <span class="badge">'.$num.'</span></a></td>';
|
||||
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("LatestCustomerTemplateInvoices", ($num<=$MAXLIST?"":$MAXLIST)).'</td><td class="right"><a class="notasortlink" href="'.DOL_URL_ROOT.'/compta/facture/invoicetemplate_list.php?socid='.$object->id.'">'.$langs->trans("AllCustomerTemplateInvoices").' <span class="badge">'.$num.'</span></a></td>';
|
||||
print '</tr></table></td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
@ -422,7 +422,11 @@ class PaymentVarious extends CommonObject
|
||||
$sign * abs($this->amount),
|
||||
$this->num_payment,
|
||||
($this->category_transaction > 0 ? $this->category_transaction : 0),
|
||||
$user
|
||||
$user,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
$this->datev
|
||||
);
|
||||
|
||||
// Update fk_bank into llx_paiement.
|
||||
|
||||
@ -990,6 +990,11 @@ if (empty($reshook))
|
||||
}
|
||||
$id = $object->create($user);
|
||||
|
||||
// NOTE: Pb with situation invoice
|
||||
// NOTE: fields total on situation invoice are stored as cumulative values on total of lines (bad) but delta on invoice total
|
||||
// NOTE: fields total on credit note are stored as delta both on total of lines and on invoice total (good)
|
||||
// NOTE: fields situation_percent on situation invoice are stored as cumulative values on lines (bad)
|
||||
// NOTE: fields situation_percent on credit note are stored as delta on lines (good)
|
||||
if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0)
|
||||
{
|
||||
if (!empty($facture_source->lines))
|
||||
@ -1010,36 +1015,38 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if($facture_source->type == Facture::TYPE_SITUATION)
|
||||
if ($facture_source->type == Facture::TYPE_SITUATION)
|
||||
{
|
||||
$source_fk_prev_id = $line->fk_prev_id; // temporary storing situation invoice fk_prev_id
|
||||
$line->fk_prev_id = $line->id; // Credit note line need to be linked to the situation invoice it is create from
|
||||
$line->fk_prev_id = $line->id; // The new line of the new credit note we are creating must be linked to the situation invoice line it is created from
|
||||
|
||||
if(!empty($facture_source->tab_previous_situation_invoice))
|
||||
if (!empty($facture_source->tab_previous_situation_invoice))
|
||||
{
|
||||
// search the last invoice in cycle
|
||||
$lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
|
||||
// search the last standard invoice in cycle and the possible credit note between this last and facture_source
|
||||
// TODO Move this out of loop of $facture_source->lines
|
||||
$tab_jumped_credit_notes = array();
|
||||
$lineIndex = count($facture_source->tab_previous_situation_invoice) - 1;
|
||||
$searchPreviousInvoice = true;
|
||||
while( $searchPreviousInvoice )
|
||||
while ($searchPreviousInvoice)
|
||||
{
|
||||
if($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1)
|
||||
if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1)
|
||||
{
|
||||
$searchPreviousInvoice=false; // find, exit;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($facture_source->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
|
||||
$tab_jumped_credit_notes[$lineIndex] = $facture_source->tab_previous_situation_invoice[$lineIndex]->id;
|
||||
}
|
||||
$lineIndex--; // go to previous invoice in cycle
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$maxPrevSituationPercent = 0;
|
||||
foreach($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
|
||||
foreach ($facture_source->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
|
||||
{
|
||||
if($prevLine->id == $source_fk_prev_id)
|
||||
if ($prevLine->id == $source_fk_prev_id)
|
||||
{
|
||||
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
|
||||
|
||||
@ -1059,6 +1066,36 @@ if (empty($reshook))
|
||||
|
||||
// prorata
|
||||
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
|
||||
|
||||
//print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
|
||||
|
||||
// If there is some credit note between last situation invoice and invoice used for credit note generation (note: credit notes are stored as delta)
|
||||
$maxPrevSituationPercent = 0;
|
||||
foreach ($tab_jumped_credit_notes as $index => $creditnoteid) {
|
||||
foreach ($facture_source->tab_previous_situation_invoice[$index]->lines as $prevLine)
|
||||
{
|
||||
if ($prevLine->fk_prev_id == $source_fk_prev_id)
|
||||
{
|
||||
$maxPrevSituationPercent = $prevLine->situation_percent;
|
||||
|
||||
$line->total_ht -= $prevLine->total_ht;
|
||||
$line->total_tva -= $prevLine->total_tva;
|
||||
$line->total_ttc -= $prevLine->total_ttc;
|
||||
$line->total_localtax1 -= $prevLine->total_localtax1;
|
||||
$line->total_localtax2 -= $prevLine->total_localtax2;
|
||||
|
||||
$line->multicurrency_subprice -= $prevLine->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht -= $prevLine->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva -= $prevLine->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc -= $prevLine->multicurrency_total_ttc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// prorata
|
||||
$line->situation_percent += $maxPrevSituationPercent;
|
||||
|
||||
//print 'New line based on invoice id '.$facture_source->tab_previous_situation_invoice[$lineIndex]->id.' fk_prev_id='.$source_fk_prev_id.' will be fk_prev_id='.$line->fk_prev_id.' '.$line->total_ht.' '.$line->situation_percent.'<br>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1078,7 +1115,7 @@ if (empty($reshook))
|
||||
$line->multicurrency_total_tva = -$line->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = -$line->multicurrency_total_ttc;
|
||||
|
||||
$result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount alreayd linked
|
||||
$result = $line->insert(0, 1); // When creating credit note with same lines than source, we must ignore error if discount already linked
|
||||
|
||||
$object->lines[] = $line; // insert new line in current object
|
||||
|
||||
@ -1106,12 +1143,12 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// Add link between credit note and origin
|
||||
if(! empty($object->fk_facture_source)) {
|
||||
if(! empty($object->fk_facture_source) && $id>0) {
|
||||
$facture_source->fetch($object->fk_facture_source);
|
||||
$facture_source->fetchObjectLinked();
|
||||
|
||||
if(! empty($facture_source->linkedObjectsIds)) {
|
||||
foreach($facture_source->linkedObjectsIds as $sourcetype => $TIds) {
|
||||
if (!empty($facture_source->linkedObjectsIds)) {
|
||||
foreach ($facture_source->linkedObjectsIds as $sourcetype => $TIds) {
|
||||
$object->add_object_linked($sourcetype, current($TIds));
|
||||
}
|
||||
}
|
||||
@ -1284,7 +1321,7 @@ if (empty($reshook))
|
||||
if ($_POST['type'] == Facture::TYPE_DEPOSIT)
|
||||
{
|
||||
$typeamount = GETPOST('typedeposit', 'alpha');
|
||||
$valuedeposit = GETPOST('valuedeposit', 'int');
|
||||
$valuedeposit = price2num(GETPOST('valuedeposit', 'alpha'), 'MU');
|
||||
|
||||
$amountdeposit = array();
|
||||
if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA))
|
||||
@ -1590,6 +1627,8 @@ if (empty($reshook))
|
||||
|
||||
if (!empty($origin) && !empty($originid))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
$object->origin = $origin;
|
||||
$object->origin_id = $originid;
|
||||
|
||||
@ -1601,6 +1640,17 @@ if (empty($reshook))
|
||||
$line->fetch_optionals($line->id);
|
||||
$line->situation_percent = $line->get_prev_progress($object->id); // get good progress including credit note
|
||||
|
||||
// The $line->situation_percent has been modified, so we must recalculate all amounts
|
||||
$tabprice = calcul_price_total($line->qty, $line->subprice, $line->remise_percent, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 0, 'HT', 0, $line->product_type, $mysoc, '', $line->situation_percent);
|
||||
$line->total_ht = $tabprice[0];
|
||||
$line->total_tva = $tabprice[1];
|
||||
$line->total_ttc = $tabprice[2];
|
||||
$line->total_localtax1 = $tabprice[9];
|
||||
$line->total_localtax2 = $tabprice[10];
|
||||
$line->multicurrency_total_ht = $tabprice[16];
|
||||
$line->multicurrency_total_tva = $tabprice[17];
|
||||
$line->multicurrency_total_ttc = $tabprice[18];
|
||||
|
||||
// Si fk_remise_except defini on vérifie si la réduction à déjà été appliquée
|
||||
if ($line->fk_remise_except)
|
||||
{
|
||||
@ -1644,6 +1694,7 @@ if (empty($reshook))
|
||||
{
|
||||
$nextSituationInvoice = new Facture($db);
|
||||
$nextSituationInvoice->fetch($id);
|
||||
|
||||
// create extrafields with data from create form
|
||||
$extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element);
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice);
|
||||
@ -4188,7 +4239,7 @@ elseif ($id > 0 || ! empty($ref))
|
||||
|
||||
$current_situation_counter = array();
|
||||
foreach ($object->tab_previous_situation_invoice as $prev_invoice) {
|
||||
$totalpaye = $prev_invoice->getSommePaiement();
|
||||
$tmptotalpaidforthisinvoice = $prev_invoice->getSommePaiement();
|
||||
$total_prev_ht += $prev_invoice->total_ht;
|
||||
$total_prev_ttc += $prev_invoice->total_ttc;
|
||||
$current_situation_counter[] = (($prev_invoice->type == Facture::TYPE_CREDIT_NOTE)?-1:1) * $prev_invoice->situation_counter;
|
||||
@ -4199,7 +4250,7 @@ elseif ($id > 0 || ! empty($ref))
|
||||
if (! empty($conf->banque->enabled)) print '<td class="right"></td>';
|
||||
print '<td class="right">' . price($prev_invoice->total_ht) . '</td>';
|
||||
print '<td class="right">' . price($prev_invoice->total_ttc) . '</td>';
|
||||
print '<td class="right">' . $prev_invoice->getLibStatut(3, $totalpaye) . '</td>';
|
||||
print '<td class="right">' . $prev_invoice->getLibStatut(3, $tmptotalpaidforthisinvoice) . '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
@ -4821,9 +4872,8 @@ elseif ($id > 0 || ! empty($ref))
|
||||
// Create a credit note
|
||||
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_PROFORMA) && $object->statut > 0 && $usercancreate)
|
||||
{
|
||||
if (! $objectidnext)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid .'&fac_avoir=' . $object->id . '&action=create&type=2'.($object->fk_project > 0 ? '&projectid='.$object->fk_project : '').'' . $object->id . '&action=create&type=2'.($object->entity > 0 ? '&originentity='.$object->entity : '').'">' . $langs->trans("CreateCreditNote") . '</a></div>';
|
||||
if (! $objectidnext) {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?socid=' . $object->socid . '&fac_avoir=' . $object->id . '&action=create&type=2' . ($object->fk_project > 0 ? '&projectid=' . $object->fk_project : '') . ($object->entity > 0 ? '&originentity=' . $object->entity : '') . '">' . $langs->trans("CreateCreditNote") . '</a></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1584,7 +1584,8 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch previous and next situations invoices
|
||||
* Fetch previous and next situations invoices.
|
||||
* Return all previous and next invoices (both standard and credit notes).
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -1595,7 +1596,7 @@ class Facture extends CommonInvoice
|
||||
$this->tab_previous_situation_invoice = array();
|
||||
$this->tab_next_situation_invoice = array();
|
||||
|
||||
$sql = 'SELECT rowid, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC';
|
||||
$sql = 'SELECT rowid, type, situation_cycle_ref, situation_counter FROM '.MAIN_DB_PREFIX.'facture WHERE rowid <> '.$this->id.' AND entity = '.$conf->entity.' AND situation_cycle_ref = '.(int) $this->situation_cycle_ref.' ORDER BY situation_counter ASC';
|
||||
|
||||
dol_syslog(get_class($this).'::fetchPreviousNextSituationInvoice ', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
@ -5013,8 +5014,7 @@ class FactureLigne extends CommonInvoiceLine
|
||||
|
||||
$returnPercent = floatval($res['situation_percent']);
|
||||
|
||||
if($include_credit_note) {
|
||||
|
||||
if ($include_credit_note) {
|
||||
$sql = 'SELECT fd.situation_percent FROM ' . MAIN_DB_PREFIX . 'facturedet fd';
|
||||
$sql.= ' JOIN ' . MAIN_DB_PREFIX . 'facture f ON (f.rowid = fd.fk_facture) ';
|
||||
$sql.= ' WHERE fd.fk_prev_id =' . $this->fk_prev_id;
|
||||
@ -5026,6 +5026,8 @@ class FactureLigne extends CommonInvoiceLine
|
||||
while($obj = $this->db->fetch_object($res)) {
|
||||
$returnPercent = $returnPercent + floatval($obj->situation_percent);
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -53,6 +53,8 @@ $cancel = GETPOST('cancel', 'alpha');
|
||||
$toselect = GETPOST('toselect', 'array');
|
||||
$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'invoicetemplatelist'; // To manage different context of search
|
||||
|
||||
$socid = GETPOST('socid', 'int');
|
||||
|
||||
// Security check
|
||||
$id=(GETPOST('facid', 'int')?GETPOST('facid', 'int'):GETPOST('id', 'int'));
|
||||
$lineid=GETPOST('lineid', 'int');
|
||||
@ -141,6 +143,11 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab
|
||||
}
|
||||
}
|
||||
|
||||
if ($socid > 0) {
|
||||
$tmpthirdparty = new Societe($db);
|
||||
$res = $tmpthirdparty->fetch($socid);
|
||||
if ($res > 0) $search_societe = $tmpthirdparty->name;
|
||||
}
|
||||
|
||||
/*
|
||||
* Actions
|
||||
|
||||
@ -342,7 +342,7 @@ if ($resql)
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Bill').'</td>';
|
||||
print '<td>'.$langs->trans('Company').'</td>';
|
||||
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED )print '<td>'.$langs->trans('Entity').'</td>';
|
||||
if (!empty($conf->multicompany->enabled) && $conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ) print '<td>'.$langs->trans('Entity').'</td>';
|
||||
print '<td class="right">'.$langs->trans('ExpectedToPay').'</td>';
|
||||
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||
print '<td class="right">'.$langs->trans('RemainderToPay').'</td>';
|
||||
@ -379,7 +379,7 @@ if ($resql)
|
||||
print '</td>';
|
||||
|
||||
// Expected to pay
|
||||
if($conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){
|
||||
if(!empty($conf->multicompany->enabled) && $conf->global->MULTICOMPANY_INVOICE_SHARING_ENABLED ){
|
||||
print '<td>';
|
||||
$mc->getInfo($objp->entity);
|
||||
print $mc->label;
|
||||
|
||||
@ -36,7 +36,10 @@ $socid = GETPOST('socid', 'int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
||||
|
||||
$urladd = '';
|
||||
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
|
||||
if ($limit != $conf->liste_limit) $urladd .= '&limit=' . $limit;
|
||||
|
||||
$sortfield = GETPOST('sortfield', 'alpha');
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$page = GETPOST('page', 'int');
|
||||
@ -53,6 +56,7 @@ $search_ref = GETPOST('search_ref', 'alpha');
|
||||
$search_amount = GETPOST('search_amount', 'alpha');
|
||||
|
||||
$bon=new BonPrelevement($db, "");
|
||||
$hookmanager->initHooks(array('withdrawalsreceiptslist'));
|
||||
|
||||
|
||||
/*
|
||||
@ -101,7 +105,7 @@ if ($result)
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
$urladd= "&statut=".$statut;
|
||||
$urladd .= "&statut=" . $statut;
|
||||
|
||||
$selectedfields='';
|
||||
|
||||
|
||||
@ -56,6 +56,7 @@ $search_company = GETPOST('search_company', 'alpha');
|
||||
$statut = GETPOST('statut', 'int');
|
||||
|
||||
$bon=new BonPrelevement($db, "");
|
||||
$hookmanager->initHooks(array('withdrawalsreceiptslineslist'));
|
||||
$ligne=new LignePrelevement($db, $user);
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ $result = restrictedArea($user, 'prelevement', '', '', 'bons');
|
||||
|
||||
// Get supervariables
|
||||
$page = GETPOST('page', 'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$sortorder = GETPOST('sortorder', 'alpha');
|
||||
$sortfield = GETPOST('sortfield', 'alpha');
|
||||
|
||||
@ -57,6 +58,7 @@ if ($sortorder == "") $sortorder="DESC";
|
||||
if ($sortfield == "") $sortfield="p.datec";
|
||||
|
||||
$rej = new RejetPrelevement($db, $user);
|
||||
$hookmanager->initHooks(array('withdrawalsreceiptsrejectedlist'));
|
||||
$ligne = new LignePrelevement($db, $user);
|
||||
|
||||
/*
|
||||
@ -85,7 +87,7 @@ if ($result)
|
||||
|
||||
print_barre_liste($langs->trans("WithdrawsRefused"), $page, $_SERVER["PHP_SELF"], $urladd, $sortfield, $sortorder, '', $num);
|
||||
print"\n<!-- debut table -->\n";
|
||||
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<table class="noborder tagtable liste" width="100%" cellspacing="0" cellpadding="4">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Line", $_SERVER["PHP_SELF"], "p.ref", '', $urladd);
|
||||
print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $urladd);
|
||||
|
||||
@ -499,7 +499,7 @@ elseif ($modecompta=="BOOKKEEPING")
|
||||
}
|
||||
|
||||
/*
|
||||
* Charges sociales non deductibles
|
||||
* Social contributions
|
||||
*/
|
||||
|
||||
$subtotal_ht = 0;
|
||||
@ -512,7 +512,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " WHERE cs.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
@ -524,7 +523,6 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
$sql.= " WHERE p.fk_charge = cs.rowid";
|
||||
$sql.= " AND cs.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 0";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
@ -532,69 +530,7 @@ if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modeco
|
||||
$sql.= " AND cs.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle, dm";
|
||||
|
||||
dol_syslog("get social contributions deductible=0 ", LOG_DEBUG);
|
||||
$result=$db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
if ($num) {
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($result);
|
||||
|
||||
if (! isset($decaiss[$obj->dm])) $decaiss[$obj->dm]=0;
|
||||
$decaiss[$obj->dm] += $obj->amount;
|
||||
|
||||
if (! isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm]=0;
|
||||
$decaiss_ttc[$obj->dm] += $obj->amount;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
elseif ($modecompta=="BOOKKEEPING")
|
||||
{
|
||||
// Nothing from this table
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Charges sociales deductibles
|
||||
*/
|
||||
|
||||
$subtotal_ht = 0;
|
||||
$subtotal_ttc = 0;
|
||||
if (! empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
|
||||
{
|
||||
if ($modecompta == 'CREANCES-DETTES')
|
||||
{
|
||||
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= " WHERE cs.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
elseif ($modecompta=="RECETTES-DEPENSES")
|
||||
{
|
||||
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."chargesociales as cs";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."paiementcharge as p";
|
||||
$sql.= " WHERE p.fk_charge = cs.rowid";
|
||||
$sql.= " AND cs.fk_type = c.id";
|
||||
$sql.= " AND c.deductible = 1";
|
||||
if (! empty($date_start) && ! empty($date_end))
|
||||
$sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
|
||||
}
|
||||
|
||||
$sql.= " AND cs.entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY c.libelle, dm";
|
||||
|
||||
dol_syslog("get social contributions paid deductible=1", LOG_DEBUG);
|
||||
dol_syslog("get social contributions", LOG_DEBUG);
|
||||
$result=$db->query($sql);
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
@ -734,7 +670,7 @@ elseif ($modecompta == 'BOOKKEEPING') {
|
||||
|
||||
|
||||
/*
|
||||
* Donation get dunning paiement
|
||||
* Donation get dunning payments
|
||||
*/
|
||||
|
||||
if (! empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta=="RECETTES-DEPENSES"))
|
||||
|
||||
@ -378,8 +378,8 @@ else
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
$resql = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($resql);
|
||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||
{
|
||||
$page = 0;
|
||||
@ -389,14 +389,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
|
||||
$sql.= $db->plimit($limit+1, $offset);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if (! $result)
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_print_error($db);
|
||||
exit;
|
||||
}
|
||||
|
||||
$num = $db->num_rows($result);
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$arrayofselected=is_array($toselect)?$toselect:array();
|
||||
|
||||
@ -763,7 +763,7 @@ $i = 0;
|
||||
$totalarray=array();
|
||||
while ($i < min($num, $limit))
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
@ -980,7 +980,7 @@ while ($i < min($num, $limit))
|
||||
$i++;
|
||||
}
|
||||
|
||||
$db->free($result);
|
||||
$db->free($resql);
|
||||
|
||||
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
|
||||
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
|
||||
|
||||
@ -79,7 +79,7 @@ if ($company->id)
|
||||
if (! $contact->phone_pro) $v->setPhoneNumber($company->phone, "TYPE=WORK;VOICE");
|
||||
if (! $contact->fax) $v->setPhoneNumber($company->fax, "TYPE=WORK;FAX");
|
||||
if (! $contact->zip) $v->setAddress("", "", $company->address, $company->town, "", $company->zip, $company->country, "TYPE=WORK;POSTAL");
|
||||
if ($company->email != $contact->email) $v->setEmail($company->email, 'TYPE=PREF,INTERNET');
|
||||
if (empty($contact->email)) $v->setEmail($company->email, 'TYPE=PREF,INTERNET');
|
||||
// Si contact lie a un tiers non de type "particulier"
|
||||
if ($contact->typent_code != 'TE_PRIVATE') $v->setOrg($company->name);
|
||||
}
|
||||
|
||||
@ -2807,8 +2807,8 @@ abstract class CommonObject
|
||||
|
||||
$sql = 'SELECT rowid, qty, '.$fieldup.' as up, remise_percent, total_ht, '.$fieldtva.' as total_tva, total_ttc, '.$fieldlocaltax1.' as total_localtax1, '.$fieldlocaltax2.' as total_localtax2,';
|
||||
$sql.= ' tva_tx as vatrate, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, info_bits, product_type';
|
||||
if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent';
|
||||
$sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
||||
if ($this->table_element_line == 'facturedet') $sql.= ', situation_percent';
|
||||
$sql.= ', multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line;
|
||||
$sql.= ' WHERE '.$this->fk_element.' = '.$this->id;
|
||||
if ($exclspec)
|
||||
@ -2847,18 +2847,23 @@ abstract class CommonObject
|
||||
|
||||
if (empty($reshook) && $forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
|
||||
{
|
||||
// This part of code is to fix data. We should not call it too often.
|
||||
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
|
||||
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array, (isset($obj->situation_percent) ? $obj->situation_percent : 100), $multicurrency_tx);
|
||||
$diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
|
||||
if ($diff)
|
||||
|
||||
$diff_when_using_price_ht=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1); // If price was set with tax price adn unit price HT has a low number of digits, then we may have a diff on recalculation from unit price HT.
|
||||
$diff_on_current_total=price2num($obj->total_ttc - $obj->total_ht - $obj->total_tva - $obj->total_localtax1 - $obj->total_localtax2, 'MT', 1);
|
||||
//var_dump($obj->total_ht.' '.$obj->total_tva.' '.$obj->total_localtax1.' '.$obj->total_localtax2.' =? '.$obj->total_ttc);
|
||||
//var_dump($diff_when_using_price_ht.' '.$diff_on_current_total);
|
||||
|
||||
if ($diff_when_using_price_ht && $diff_on_current_total)
|
||||
{
|
||||
$sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid;
|
||||
dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
|
||||
$resqlfix=$this->db->query($sqlfix);
|
||||
if (! $resqlfix) dol_print_error($this->db, 'Failed to update line');
|
||||
$obj->total_tva = $tmpcal[1];
|
||||
$obj->total_ttc = $tmpcal[2];
|
||||
//
|
||||
dol_syslog('We found unconsistent data into detailed line (diff_when_using_price_ht = '.$diff_when_using_price_ht.' and diff_on_current_total = '.$diff_on_current_total.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix, LOG_WARNING);
|
||||
$resqlfix=$this->db->query($sqlfix);
|
||||
if (! $resqlfix) dol_print_error($this->db, 'Failed to update line');
|
||||
$obj->total_tva = $tmpcal[1];
|
||||
$obj->total_ttc = $tmpcal[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2103,7 +2103,7 @@ class ExtraFields
|
||||
if (in_array($key_type, array('date','datetime')))
|
||||
{
|
||||
// Clean parameters
|
||||
$value_key=dol_mktime($_POST[$keysuffix."options_".$key.$keyprefix."hour"], $_POST[$keysuffix."options_".$key.$keyprefix."min"], 0, $_POST[$keysuffix."options_".$key.$keyprefix."month"], $_POST[$keysuffix."options_".$key.$keyprefix."day"], $_POST[$keysuffix."options_".$key.$keyprefix."year"]);
|
||||
$value_key=dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
|
||||
}
|
||||
elseif (in_array($key_type, array('checkbox', 'chkbxlst')))
|
||||
{
|
||||
|
||||
@ -3582,10 +3582,11 @@ class Form
|
||||
|
||||
$opt = '<option value ="" selected></option>';
|
||||
$sql = 'SELECT rowid, ref, situation_cycle_ref, situation_counter, situation_final, fk_soc';
|
||||
$sql.= ' FROM ' . MAIN_DB_PREFIX . 'facture';
|
||||
$sql.= ' WHERE entity IN ('.getEntity('invoice').')';
|
||||
$sql.= ' AND situation_counter>=1';
|
||||
$sql.= ' ORDER by situation_cycle_ref, situation_counter desc';
|
||||
$sql .= ' FROM ' . MAIN_DB_PREFIX . 'facture';
|
||||
$sql .= ' WHERE entity IN ('.getEntity('invoice').')';
|
||||
$sql .= ' AND situation_counter>=1';
|
||||
$sql .= ' AND type <> 2';
|
||||
$sql .= ' ORDER by situation_cycle_ref, situation_counter desc';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
// Last seen cycle
|
||||
@ -5648,7 +5649,7 @@ class Form
|
||||
}
|
||||
elseif ($typehour=='text' || $typehour=='textselect')
|
||||
{
|
||||
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
|
||||
$retstring.='<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" name="'.$prefix.'hour"'.($disabled?' disabled':'').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '')?((int) $hourSelected):'').'">';
|
||||
}
|
||||
else return 'BadValueForParameterTypeHour';
|
||||
|
||||
@ -5672,7 +5673,7 @@ class Form
|
||||
}
|
||||
elseif ($typehour=='text' )
|
||||
{
|
||||
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
|
||||
$retstring.='<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" name="'.$prefix.'min"'.($disabled?' disabled':'').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '')?((int) $minSelected):'').'">';
|
||||
}
|
||||
|
||||
if ($typehour!='text') $retstring.=' '.$langs->trans('MinuteShort');
|
||||
@ -6670,7 +6671,8 @@ class Form
|
||||
'order'=>array('enabled'=>$conf->commande->enabled, 'perms'=>1, 'label'=>'LinkToOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande').')'),
|
||||
'invoice'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_client, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
|
||||
'invoice_template'=>array('enabled'=>$conf->facture->enabled, 'perms'=>1, 'label'=>'LinkToTemplateInvoice', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.titre as ref, t.total as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."facture_rec as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('invoice').')'),
|
||||
'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, '' as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
|
||||
'contrat'=>array('enabled'=>$conf->contrat->enabled , 'perms'=>1, 'label'=>'LinkToContract',
|
||||
'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_customer as ref_client, t.ref_supplier, td.total_ht as total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as t, ".MAIN_DB_PREFIX."contratdet as td WHERE t.fk_soc = s.rowid AND td.fk_contrat = t.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('contract').')'),
|
||||
'fichinter'=>array('enabled'=>$conf->ficheinter->enabled, 'perms'=>1, 'label'=>'LinkToIntervention', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."fichinter as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('intervention').')'),
|
||||
'supplier_proposal'=>array('enabled'=>$conf->supplier_proposal->enabled , 'perms'=>1, 'label'=>'LinkToSupplierProposal', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, '' as ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('supplier_proposal').')'),
|
||||
'order_supplier'=>array('enabled'=>$conf->supplier_order->enabled , 'perms'=>1, 'label'=>'LinkToSupplierOrder', 'sql'=>"SELECT s.rowid as socid, s.nom as name, s.client, t.rowid, t.ref, t.ref_supplier, t.total_ht FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande_fournisseur as t WHERE t.fk_soc = s.rowid AND t.fk_soc IN (".$listofidcompanytoscan.') AND t.entity IN ('.getEntity('commande_fournisseur').')'),
|
||||
|
||||
@ -75,7 +75,7 @@ class FormOther
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."export_model";
|
||||
$sql.= " WHERE type = '".$type."'";
|
||||
if (!empty($fk_user)) $sql.=" AND fk_user IN (0, ".$fk_user.")"; // An export model
|
||||
$sql.= " ORDER BY rowid";
|
||||
$sql.= " ORDER BY label";
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
|
||||
@ -991,9 +991,7 @@ class FormTicket
|
||||
|
||||
// MESSAGE
|
||||
$defaultmessage="";
|
||||
if (is_array($arraydefaultmessage) && count($arraydefaultmessage) > 0 && $arraydefaultmessage->content) {
|
||||
$defaultmessage=$arraydefaultmessage->content;
|
||||
}
|
||||
if (is_object($arraydefaultmessage) && $arraydefaultmessage->content) $defaultmessage = $arraydefaultmessage->content;
|
||||
$defaultmessage=str_replace('\n', "\n", $defaultmessage);
|
||||
|
||||
// Deal with format differences between message and signature (text / HTML)
|
||||
|
||||
@ -314,6 +314,7 @@ class Notify
|
||||
global $user,$conf,$langs,$mysoc;
|
||||
global $hookmanager;
|
||||
global $dolibarr_main_url_root;
|
||||
global $action;
|
||||
|
||||
if (! in_array($notifcode, $this->arrayofnotifsupported)) return 0;
|
||||
|
||||
@ -415,34 +416,34 @@ class Notify
|
||||
|
||||
switch ($notifcode) {
|
||||
case 'BILL_VALIDATE':
|
||||
$link='/compta/facture/card.php?facid='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/compta/facture/card.php?facid=' . $object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->facture->dir_output;
|
||||
$object_type = 'facture';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoiceValidated", $link);
|
||||
break;
|
||||
case 'BILL_PAYED':
|
||||
$link='/compta/facture/card.php?facid='.$object->id;
|
||||
$link ='<a href="' . $urlwithroot . '/compta/facture/card.php?facid='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->facture->dir_output;
|
||||
$object_type = 'facture';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInvoicePayed", $link);
|
||||
break;
|
||||
case 'ORDER_VALIDATE':
|
||||
$link='/commande/card.php?id='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->commande->dir_output;
|
||||
$object_type = 'order';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextOrderValidated", $link);
|
||||
break;
|
||||
case 'PROPAL_VALIDATE':
|
||||
$link='/comm/propal/card.php?id='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->propal->multidir_output[$object->entity];
|
||||
$object_type = 'propal';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalValidated", $link);
|
||||
break;
|
||||
case 'PROPAL_CLOSE_SIGNED':
|
||||
$link='/comm/propal/card.php?id='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/comm/propal/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->propal->multidir_output[$object->entity];
|
||||
$object_type = 'propal';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextProposalClosedSigned", $link);
|
||||
break;
|
||||
case 'FICHINTER_ADD_CONTACT':
|
||||
$link='/fichinter/card.php?id='.$object->id;
|
||||
@ -451,17 +452,17 @@ class Notify
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $newref);
|
||||
break;
|
||||
case 'FICHINTER_VALIDATE':
|
||||
$link='/fichinter/card.php?id='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->ficheinter->dir_output;
|
||||
$object_type = 'ficheinter';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextInterventionValidated", $link);
|
||||
break;
|
||||
case 'ORDER_SUPPLIER_VALIDATE':
|
||||
$link='/fourn/commande/card.php?id='.$object->id;
|
||||
$dir_output = $conf->fournisseur->commande->dir_output;
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $newref, $user->getFullName($outputlangs));
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderValidatedBy", $link, $user->getFullName($outputlangs));
|
||||
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'ORDER_SUPPLIER_APPROVE':
|
||||
@ -469,41 +470,46 @@ class Notify
|
||||
$dir_output = $conf->fournisseur->commande->dir_output;
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $newref, $user->getFullName($outputlangs));
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderApprovedBy", $link, $user->getFullName($outputlangs));
|
||||
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'ORDER_SUPPLIER_REFUSE':
|
||||
$link='/fourn/commande/card.php?id='.$object->id;
|
||||
$link = '<a href="' . $urlwithroot . '/fourn/commande/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->fournisseur->commande->dir_output;
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("Hello").",\n\n";
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $newref, $user->getFullName($outputlangs));
|
||||
$mesg.= $outputlangs->transnoentitiesnoconv("EMailTextOrderRefusedBy", $link, $user->getFullName($outputlangs));
|
||||
$mesg.= "\n\n".$outputlangs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'SHIPPING_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expedition->dir_output.'/sending/';
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref);
|
||||
$object_type = 'expedition';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link);
|
||||
break;
|
||||
case 'EXPENSE_REPORT_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expensereport->dir_output;
|
||||
$object_type = 'expensereport';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link);
|
||||
break;
|
||||
case 'EXPENSE_REPORT_APPROVE':
|
||||
$link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expensereport->dir_output;
|
||||
$object_type = 'expensereport';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link);
|
||||
break;
|
||||
case 'HOLIDAY_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->holiday->dir_output;
|
||||
$object_type = 'holiday';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayValidated", $link);
|
||||
break;
|
||||
case 'HOLIDAY_APPROVE':
|
||||
$link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->holiday->dir_output;
|
||||
$object_type = 'holiday';
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved", $newref);
|
||||
$mesg = $outputlangs->transnoentitiesnoconv("EMailTextHolidayApproved", $link);
|
||||
break;
|
||||
}
|
||||
$ref = dol_sanitizeFileName($newref);
|
||||
@ -522,10 +528,11 @@ class Notify
|
||||
$message.= $outputlangs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
|
||||
$message.= "\n";
|
||||
$message.= $mesg;
|
||||
if ($link) $message.= "\n" . $urlwithroot . $link;
|
||||
|
||||
$parameters=array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
|
||||
$reshook=$hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
$parameters = array('notifcode'=>$notifcode, 'sendto'=>$sendto, 'replyto'=>$replyto, 'file'=>$filename_list, 'mimefile'=>$mimetype_list, 'filename'=>$mimefilename_list);
|
||||
if (!isset($action)) $action = '';
|
||||
|
||||
$reshook = $hookmanager->executeHooks('formatNotificationMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{
|
||||
if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject'];
|
||||
@ -592,6 +599,7 @@ class Notify
|
||||
{
|
||||
foreach($conf->global as $key => $val)
|
||||
{
|
||||
$reg = array();
|
||||
if ($val == '' || ! preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifcode.'_THRESHOLD_HIGHER_(.*)$/', $key, $reg)) continue;
|
||||
|
||||
$threshold = (float) $reg[1];
|
||||
@ -646,7 +654,7 @@ class Notify
|
||||
break;
|
||||
case 'FICHINTER_ADD_CONTACT':
|
||||
$link = '<a href="' . $urlwithroot . '/fichinter/card.php?id='.$object->id . '">' . $newref . '</a>';
|
||||
$dir_output = $conf->facture->dir_output;
|
||||
$dir_output = $conf->ficheinter->dir_output;
|
||||
$object_type = 'ficheinter';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextInterventionAddedContact", $link);
|
||||
break;
|
||||
@ -689,29 +697,34 @@ class Notify
|
||||
$mesg.= "\n\n".$langs->transnoentitiesnoconv("Sincerely").".\n\n";
|
||||
break;
|
||||
case 'SHIPPING_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expedition/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expedition->dir_output.'/sending/';
|
||||
$object_type = 'order_supplier';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $newref);
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpeditionValidated", $link);
|
||||
break;
|
||||
case 'EXPENSE_REPORT_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expensereport->dir_output;
|
||||
$object_type = 'expensereport';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $newref);
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportValidated", $link);
|
||||
break;
|
||||
case 'EXPENSE_REPORT_APPROVE':
|
||||
$link = '<a href="'.$urlwithroot.'/expensereport/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->expensereport->dir_output;
|
||||
$object_type = 'expensereport';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $newref);
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextExpenseReportApproved", $link);
|
||||
break;
|
||||
case 'HOLIDAY_VALIDATE':
|
||||
$link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->holiday->dir_output;
|
||||
$object_type = 'holiday';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated", $newref);
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextHolidayValidated", $link);
|
||||
break;
|
||||
case 'HOLIDAY_APPROVE':
|
||||
$link = '<a href="'.$urlwithroot.'/holiday/card.php?id='.$object->id.'">'.$newref.'</a>';
|
||||
$dir_output = $conf->holiday->dir_output;
|
||||
$object_type = 'holiday';
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved", $newref);
|
||||
$mesg = $langs->transnoentitiesnoconv("EMailTextHolidayApproved", $link);
|
||||
break;
|
||||
}
|
||||
$ref = dol_sanitizeFileName($newref);
|
||||
@ -730,7 +743,6 @@ class Notify
|
||||
$message.= $langs->transnoentities("YouReceiveMailBecauseOfNotification2", $application, $mysoc->name)."\n";
|
||||
$message.= "\n";
|
||||
$message.= $mesg;
|
||||
//if ($link) $message.= "\n" . $urlwithroot . $link; // link already added around the ref into the text
|
||||
|
||||
$message = nl2br($message);
|
||||
|
||||
|
||||
@ -428,7 +428,7 @@ class SMTPs
|
||||
$host=preg_replace('@ssl://@i', '', $host); // Remove prefix
|
||||
$host=preg_replace('@tls://@i', '', $host); // Remove prefix
|
||||
|
||||
if ($usetls) $host='tls://'.$host;
|
||||
if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host;
|
||||
|
||||
$hosth = $host;
|
||||
|
||||
@ -555,6 +555,8 @@ class SMTPs
|
||||
$host=preg_replace('@ssl://@i', '', $host); // Remove prefix
|
||||
$host=preg_replace('@tls://@i', '', $host); // Remove prefix
|
||||
|
||||
if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host;
|
||||
|
||||
$hosth = $host;
|
||||
|
||||
if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))
|
||||
|
||||
@ -1349,7 +1349,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
|
||||
$langs->load("mails");
|
||||
|
||||
$sql2 = "SELECT m.rowid as id, m.titre as label, mc.date_envoi as dp, mc.date_envoi as dp2, '100' as percent, 'mailing' as type";
|
||||
$sql2.= ", '' as fk_element, '' as elementtype, '' as contact_id";
|
||||
$sql2.= ", null as fk_element, '' as elementtype, null as contact_id";
|
||||
$sql2.= ", 'AC_EMAILING' as acode, '' as alabel, '' as apicto";
|
||||
$sql2.= ", u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname"; // User that valid action
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql2.= ", '' as lastname, '' as firstname";
|
||||
|
||||
@ -959,18 +959,18 @@ function dol_unescapefile($filename)
|
||||
*/
|
||||
function dolCheckVirus($src_file)
|
||||
{
|
||||
global $conf, $db;
|
||||
global $conf;
|
||||
|
||||
if (! empty($conf->global->MAIN_ANTIVIRUS_COMMAND))
|
||||
{
|
||||
if (! class_exists('AntiVir')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
|
||||
}
|
||||
$antivir = new AntiVir($db);
|
||||
$antivir=new AntiVir($db);
|
||||
$result = $antivir->dol_avscan_file($src_file);
|
||||
if ($result < 0) // If virus or error, we stop here
|
||||
{
|
||||
$reterrors = $antivir->errors;
|
||||
$reterrors=$antivir->errors;
|
||||
return $reterrors;
|
||||
}
|
||||
}
|
||||
@ -1853,15 +1853,16 @@ function dol_convert_file($fileinput, $ext = 'png', $fileoutput = '', $page = ''
|
||||
if (empty($fileoutput)) $fileoutput=$fileinput.".".$ext;
|
||||
|
||||
$count = $image->getNumberImages();
|
||||
|
||||
if (! dol_is_file($fileoutput) || is_writeable($fileoutput))
|
||||
{
|
||||
try {
|
||||
$ret = $image->writeImages($fileoutput, true);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_WARNING);
|
||||
}
|
||||
try {
|
||||
$ret = $image->writeImages($fileoutput, true);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
dol_syslog($e->getMessage(), LOG_WARNING);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -8258,7 +8258,7 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
|
||||
$attr['class'] .= ' classfortooltip';
|
||||
}
|
||||
|
||||
if(empty($id)){
|
||||
if(!empty($id)){
|
||||
$attr['id'] = $id;
|
||||
}
|
||||
|
||||
|
||||
@ -13,125 +13,142 @@
|
||||
* 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/>.
|
||||
* or see http://www.gnu.org/
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
/**
|
||||
* \file htdocs/core/lib/functionsnumbertoword.lib.php
|
||||
* \file htdocs/core/lib/functionsnumtoword.lib.php
|
||||
* \brief A set of functions for Dolibarr
|
||||
* This file contains all frequently used functions.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Function to return number in text.
|
||||
* Function to return a number into a text.
|
||||
* May use module NUMBERWORDS if found.
|
||||
*
|
||||
*
|
||||
* @param float $num Number to convert
|
||||
* @param float $num Number to convert (must be a numeric value, like reported by price2num())
|
||||
* @param Translate $langs Language
|
||||
* @param boolean $currency 0=number to translate | 1=currency to translate
|
||||
* @param boolean $centimes 0=no centimes | 1=centimes to translate
|
||||
* @param boolean $centimes 0=no cents/centimes | 1=there is cents/centimes to translate
|
||||
* @return string|false Text of the number
|
||||
*/
|
||||
function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$num = str_replace(array(',', ' '), '', trim($num));
|
||||
if (! $num) {
|
||||
return false;
|
||||
}
|
||||
//$num = str_replace(array(',', ' '), '', trim($num)); This should be useless since $num MUST be a php numeric value
|
||||
if (!$num) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($centimes && strlen($num) == 1) {
|
||||
$num = $num*10;
|
||||
}
|
||||
$TNum = explode('.', $num);
|
||||
$num = (int) $TNum[0];
|
||||
$words = array();
|
||||
$list1 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('one'),
|
||||
$langs->transnoentitiesnoconv('two'),
|
||||
$langs->transnoentitiesnoconv('three'),
|
||||
$langs->transnoentitiesnoconv('four'),
|
||||
$langs->transnoentitiesnoconv('five'),
|
||||
$langs->transnoentitiesnoconv('six'),
|
||||
$langs->transnoentitiesnoconv('seven'),
|
||||
$langs->transnoentitiesnoconv('eight'),
|
||||
$langs->transnoentitiesnoconv('nine'),
|
||||
$langs->transnoentitiesnoconv('ten'),
|
||||
$langs->transnoentitiesnoconv('eleven'),
|
||||
$langs->transnoentitiesnoconv('twelve'),
|
||||
$langs->transnoentitiesnoconv('thirteen'),
|
||||
$langs->transnoentitiesnoconv('fourteen'),
|
||||
$langs->transnoentitiesnoconv('fifteen'),
|
||||
$langs->transnoentitiesnoconv('sixteen'),
|
||||
$langs->transnoentitiesnoconv('seventeen'),
|
||||
$langs->transnoentitiesnoconv('eighteen'),
|
||||
$langs->transnoentitiesnoconv('nineteen')
|
||||
);
|
||||
$list2 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('ten'),
|
||||
$langs->transnoentitiesnoconv('twenty'),
|
||||
$langs->transnoentitiesnoconv('thirty'),
|
||||
$langs->transnoentitiesnoconv('forty'),
|
||||
$langs->transnoentitiesnoconv('fifty'),
|
||||
$langs->transnoentitiesnoconv('sixty'),
|
||||
$langs->transnoentitiesnoconv('seventy'),
|
||||
$langs->transnoentitiesnoconv('eighty'),
|
||||
$langs->transnoentitiesnoconv('ninety'),
|
||||
$langs->transnoentitiesnoconv('hundred')
|
||||
);
|
||||
$list3 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('thousand'),
|
||||
$langs->transnoentitiesnoconv('million'),
|
||||
$langs->transnoentitiesnoconv('billion'),
|
||||
$langs->transnoentitiesnoconv('trillion'),
|
||||
$langs->transnoentitiesnoconv('quadrillion')
|
||||
);
|
||||
|
||||
$num_length = strlen($num);
|
||||
$levels = (int) (($num_length + 2) / 3);
|
||||
$max_length = $levels * 3;
|
||||
$num = substr('00' . $num, -$max_length);
|
||||
$num_levels = str_split($num, 3);
|
||||
$nboflevels = count($num_levels);
|
||||
for ($i = 0; $i < $nboflevels; $i++) {
|
||||
$levels--;
|
||||
$hundreds = (int) ($num_levels[$i] / 100);
|
||||
$hundreds = ($hundreds ? ' ' . $list1[$hundreds] . ' '.$langs->transnoentities('hundred') . ( $hundreds == 1 ? '' : 's' ) . ' ': '');
|
||||
$tens = (int) ($num_levels[$i] % 100);
|
||||
$singles = '';
|
||||
if ( $tens < 20 ) {
|
||||
$tens = ($tens ? ' ' . $list1[$tens] . ' ' : '' );
|
||||
} else {
|
||||
$tens = (int) ($tens / 10);
|
||||
$tens = ' ' . $list2[$tens] . ' ';
|
||||
$singles = (int) ($num_levels[$i] % 10);
|
||||
$singles = ' ' . $list1[$singles] . ' ';
|
||||
}
|
||||
$words[] = $hundreds . $tens . $singles . ( ( $levels && ( int ) ( $num_levels[$i] ) ) ? ' ' . $list3[$levels] . ' ' : '' );
|
||||
} //end for loop
|
||||
$commas = count($words);
|
||||
if ($commas > 1) {
|
||||
$commas = $commas - 1;
|
||||
}
|
||||
$concatWords = implode(' ', $words);
|
||||
// Delete multi whitespaces
|
||||
$concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
|
||||
|
||||
if(!empty($currency)) {
|
||||
$concatWords .= ' '.$currency;
|
||||
$num = $num * 10;
|
||||
}
|
||||
|
||||
// If we need to write cents call again this function for cents
|
||||
if(!empty($TNum[1])) {
|
||||
if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
|
||||
$concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
|
||||
if(!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
|
||||
if (!empty($conf->global->MAIN_MODULE_NUMBERWORDS)) {
|
||||
if ($currency) {
|
||||
$type = 1;
|
||||
} else {
|
||||
$type = 0;
|
||||
}
|
||||
|
||||
$concatWords = $langs->getLabelFromNumber($num, $type);
|
||||
return $concatWords;
|
||||
} else {
|
||||
$TNum = explode('.', $num);
|
||||
$num = (int) $TNum[0];
|
||||
$words = array();
|
||||
$list1 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('one'),
|
||||
$langs->transnoentitiesnoconv('two'),
|
||||
$langs->transnoentitiesnoconv('three'),
|
||||
$langs->transnoentitiesnoconv('four'),
|
||||
$langs->transnoentitiesnoconv('five'),
|
||||
$langs->transnoentitiesnoconv('six'),
|
||||
$langs->transnoentitiesnoconv('seven'),
|
||||
$langs->transnoentitiesnoconv('eight'),
|
||||
$langs->transnoentitiesnoconv('nine'),
|
||||
$langs->transnoentitiesnoconv('ten'),
|
||||
$langs->transnoentitiesnoconv('eleven'),
|
||||
$langs->transnoentitiesnoconv('twelve'),
|
||||
$langs->transnoentitiesnoconv('thirteen'),
|
||||
$langs->transnoentitiesnoconv('fourteen'),
|
||||
$langs->transnoentitiesnoconv('fifteen'),
|
||||
$langs->transnoentitiesnoconv('sixteen'),
|
||||
$langs->transnoentitiesnoconv('seventeen'),
|
||||
$langs->transnoentitiesnoconv('eighteen'),
|
||||
$langs->transnoentitiesnoconv('nineteen')
|
||||
);
|
||||
$list2 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('ten'),
|
||||
$langs->transnoentitiesnoconv('twenty'),
|
||||
$langs->transnoentitiesnoconv('thirty'),
|
||||
$langs->transnoentitiesnoconv('forty'),
|
||||
$langs->transnoentitiesnoconv('fifty'),
|
||||
$langs->transnoentitiesnoconv('sixty'),
|
||||
$langs->transnoentitiesnoconv('seventy'),
|
||||
$langs->transnoentitiesnoconv('eighty'),
|
||||
$langs->transnoentitiesnoconv('ninety'),
|
||||
$langs->transnoentitiesnoconv('hundred')
|
||||
);
|
||||
$list3 = array(
|
||||
'',
|
||||
$langs->transnoentitiesnoconv('thousand'),
|
||||
$langs->transnoentitiesnoconv('million'),
|
||||
$langs->transnoentitiesnoconv('billion'),
|
||||
$langs->transnoentitiesnoconv('trillion'),
|
||||
$langs->transnoentitiesnoconv('quadrillion')
|
||||
);
|
||||
|
||||
$num_length = strlen($num);
|
||||
$levels = (int) (($num_length + 2) / 3);
|
||||
$max_length = $levels * 3;
|
||||
$num = substr('00'.$num, -$max_length);
|
||||
$num_levels = str_split($num, 3);
|
||||
$nboflevels = count($num_levels);
|
||||
for ($i = 0; $i < $nboflevels; $i++) {
|
||||
$levels--;
|
||||
$hundreds = (int) ($num_levels[$i] / 100);
|
||||
$hundreds = ($hundreds ? ' '.$list1[$hundreds].' '.$langs->transnoentities('hundred').($hundreds == 1 ? '' : 's').' ' : '');
|
||||
$tens = (int) ($num_levels[$i] % 100);
|
||||
$singles = '';
|
||||
if ($tens < 20) {
|
||||
$tens = ($tens ? ' '.$list1[$tens].' ' : '');
|
||||
} else {
|
||||
$tens = (int) ($tens / 10);
|
||||
$tens = ' '.$list2[$tens].' ';
|
||||
$singles = (int) ($num_levels[$i] % 10);
|
||||
$singles = ' '.$list1[$singles].' ';
|
||||
}
|
||||
$words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ? ' '.$list3[$levels].' ' : '');
|
||||
} //end for loop
|
||||
$commas = count($words);
|
||||
if ($commas > 1) {
|
||||
$commas = $commas - 1;
|
||||
}
|
||||
$concatWords = implode(' ', $words);
|
||||
// Delete multi whitespaces
|
||||
$concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
|
||||
|
||||
if (!empty($currency)) {
|
||||
$concatWords .= ' '.$currency;
|
||||
}
|
||||
|
||||
// If we need to write cents call again this function for cents
|
||||
$decimalpart = $TNum[1];
|
||||
$decimalpart = preg_replace('/0+$/', '', $decimalpart);
|
||||
|
||||
if ($decimalpart) {
|
||||
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
|
||||
|
||||
$concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true);
|
||||
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
|
||||
}
|
||||
return $concatWords;
|
||||
}
|
||||
return $concatWords;
|
||||
}
|
||||
|
||||
|
||||
@ -146,41 +163,43 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
|
||||
*/
|
||||
function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
{
|
||||
// If the number is negative convert to positive and return -1 if is too long
|
||||
// If the number is negative convert to positive and return -1 if it is too long
|
||||
if ($numero < 0) $numero *= -1;
|
||||
if ($numero >= 1000000000001)
|
||||
if ($numero >= 1000000000001) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get 2 decimals to cents, another functions round or truncate
|
||||
$strnumber = number_format($numero, 10);
|
||||
$len=strlen($strnumber);
|
||||
for ($i=0; $i<$len; $i++)
|
||||
$len = strlen($strnumber);
|
||||
for ($i = 0; $i < $len; $i++)
|
||||
{
|
||||
if ($strnumber[$i]=='.') {
|
||||
$parte_decimal = $strnumber[$i+1].$strnumber[$i+2];
|
||||
if ($strnumber[$i] == '.') {
|
||||
$parte_decimal = $strnumber[$i + 1].$strnumber[$i + 2];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*In dolibarr 3.6.2 (my current version) doesn't have $langs->default and
|
||||
in case exist why ask $lang like a parameter?*/
|
||||
if (((is_object($langs) && $langs->default == 'es_MX') || (! is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
|
||||
in case exist why ask $lang like a parameter?*/
|
||||
if (((is_object($langs) && $langs->default == 'es_MX') || (!is_object($langs) && $langs == 'es_MX')) && $numorcurrency == 'currency')
|
||||
{
|
||||
if ($numero>=1 && $numero<2) {
|
||||
if ($numero >= 1 && $numero < 2) {
|
||||
return ("UN PESO ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=0 && $numero<1){
|
||||
elseif ($numero >= 0 && $numero < 1) {
|
||||
return ("CERO PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=1000000 && $numero<1000001){
|
||||
elseif ($numero >= 1000000 && $numero < 1000001) {
|
||||
return ("UN MILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
elseif ($numero>=1000000000000 && $numero<1000000000001){
|
||||
elseif ($numero >= 1000000000000 && $numero < 1000000000001) {
|
||||
return ("UN BILLÓN DE PESOS ".$parte_decimal." / 100 M.N.");
|
||||
}
|
||||
else {
|
||||
$entexto ="";
|
||||
$entexto = "";
|
||||
$number = $numero;
|
||||
if ($number >= 1000000000){
|
||||
if ($number >= 1000000000) {
|
||||
$CdMMillon = (int) ($numero / 100000000000);
|
||||
$numero = $numero - $CdMMillon * 100000000000;
|
||||
$DdMMillon = (int) ($numero / 10000000000);
|
||||
@ -190,7 +209,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$entexto .= hundreds2text($CdMMillon, $DdMMillon, $UdMMillon);
|
||||
$entexto .= " MIL ";
|
||||
}
|
||||
if ($number >= 1000000){
|
||||
if ($number >= 1000000) {
|
||||
$CdMILLON = (int) ($numero / 100000000);
|
||||
$numero = $numero - $CdMILLON * 100000000;
|
||||
$DdMILLON = (int) ($numero / 10000000);
|
||||
@ -198,10 +217,10 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$udMILLON = (int) ($numero / 1000000);
|
||||
$numero = $numero - $udMILLON * 1000000;
|
||||
$entexto .= hundreds2text($CdMILLON, $DdMILLON, $udMILLON);
|
||||
if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON==1)
|
||||
if (!$CdMMillon && !$DdMMillon && !$UdMMillon && !$CdMILLON && !$DdMILLON && $udMILLON == 1)
|
||||
$entexto .= " MILLÓN ";
|
||||
else
|
||||
$entexto .= " MILLONES ";
|
||||
else
|
||||
$entexto .= " MILLONES ";
|
||||
}
|
||||
if ($number >= 1000) {
|
||||
$cdm = (int) ($numero / 100000);
|
||||
@ -219,9 +238,9 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
$d = (int) ($numero / 10);
|
||||
$u = (int) $numero - $d * 10;
|
||||
$entexto .= hundreds2text($c, $d, $u);
|
||||
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number>1000000)
|
||||
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000)
|
||||
$entexto .= " DE";
|
||||
$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
|
||||
$entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
|
||||
}
|
||||
return $entexto;
|
||||
}
|
||||
@ -237,40 +256,40 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
|
||||
*/
|
||||
function hundreds2text($hundreds, $tens, $units)
|
||||
{
|
||||
if ($hundreds==1 && $tens==0 && $units==0){
|
||||
if ($hundreds == 1 && $tens == 0 && $units == 0) {
|
||||
return "CIEN";
|
||||
}
|
||||
$centenas = array("CIENTO","DOSCIENTOS","TRESCIENTOS","CUATROCIENTOS","QUINIENTOS","SEISCIENTOS","SETECIENTOS","OCHOCIENTOS","NOVECIENTOS");
|
||||
$decenas = array("","","TREINTA ","CUARENTA ","CINCUENTA ","SESENTA ","SETENTA ","OCHENTA ","NOVENTA ");
|
||||
$veintis = array("VEINTE","VEINTIUN","VEINTIDÓS","VEINTITRÉS","VEINTICUATRO","VEINTICINCO","VEINTISÉIS","VEINTISIETE","VEINTIOCHO","VEINTINUEVE");
|
||||
$diecis = array("DIEZ","ONCE","DOCE","TRECE","CATORCE","QUINCE","DIECISÉIS","DIECISIETE","DIECIOCHO","DIECINUEVE");
|
||||
$unidades = array("UN","DOS","TRES","CUATRO","CINCO","SEIS","SIETE","OCHO","NUEVE");
|
||||
$centenas = array("CIENTO", "DOSCIENTOS", "TRESCIENTOS", "CUATROCIENTOS", "QUINIENTOS", "SEISCIENTOS", "SETECIENTOS", "OCHOCIENTOS", "NOVECIENTOS");
|
||||
$decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
|
||||
$veintis = array("VEINTE", "VEINTIUN", "VEINTIDÓS", "VEINTITRÉS", "VEINTICUATRO", "VEINTICINCO", "VEINTISÉIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
|
||||
$diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECISÉIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
|
||||
$unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
|
||||
$entexto = "";
|
||||
if ($hundreds!=0){
|
||||
$entexto .= $centenas[$hundreds-1];
|
||||
if ($hundreds != 0) {
|
||||
$entexto .= $centenas[$hundreds - 1];
|
||||
}
|
||||
if ($tens>2){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
$entexto .= $decenas[$tens-1];
|
||||
if ($units!=0){
|
||||
if ($tens > 2) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= $decenas[$tens - 1];
|
||||
if ($units != 0) {
|
||||
$entexto .= " Y ";
|
||||
$entexto .= $unidades[$units-1];
|
||||
$entexto .= $unidades[$units - 1];
|
||||
}
|
||||
return $entexto;
|
||||
}
|
||||
elseif ($tens==2){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
elseif ($tens == 2) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= " ".$veintis[$units];
|
||||
return $entexto;
|
||||
}
|
||||
elseif ($tens==1){
|
||||
if ($hundreds!=0) $entexto .= " ";
|
||||
elseif ($tens == 1) {
|
||||
if ($hundreds != 0) $entexto .= " ";
|
||||
$entexto .= $diecis[$units];
|
||||
return $entexto;
|
||||
}
|
||||
if ($units!=0) {
|
||||
if ($hundreds!=0 || $tens!=0) $entexto .= " ";
|
||||
$entexto .= $unidades[$units-1];
|
||||
if ($units != 0) {
|
||||
if ($hundreds != 0 || $tens != 0) $entexto .= " ";
|
||||
$entexto .= $unidades[$units - 1];
|
||||
}
|
||||
return $entexto;
|
||||
}
|
||||
|
||||
@ -1215,7 +1215,7 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0,
|
||||
global $db, $conf, $langs;
|
||||
|
||||
$idprod=(! empty($object->lines[$i]->fk_product)?$object->lines[$i]->fk_product:false);
|
||||
$label=(! empty($object->lines[$i]->label)?$object->lines[$i]->label:(! empty($object->lines[$i]->product_label)?$object->lines[$i]->product_label:''));
|
||||
$label=(!empty($object->lines[$i]->label) ? $object->lines[$i]->label : (!empty($object->lines[$i]->libelle) ? $object->lines[$i]->libelle : (!empty($object->lines[$i]->product_label) ? $object->lines[$i]->product_label : '')));
|
||||
$desc=(! empty($object->lines[$i]->desc)?$object->lines[$i]->desc:(! empty($object->lines[$i]->description)?$object->lines[$i]->description:''));
|
||||
$ref_supplier=(! empty($object->lines[$i]->ref_supplier)?$object->lines[$i]->ref_supplier:(! empty($object->lines[$i]->ref_fourn)?$object->lines[$i]->ref_fourn:'')); // TODO Not yet saved for supplier invoices, only supplier orders
|
||||
$note=(! empty($object->lines[$i]->note)?$object->lines[$i]->note:'');
|
||||
@ -1840,7 +1840,6 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
|
||||
}
|
||||
if (empty($reshook))
|
||||
{
|
||||
if ($object->lines[$i]->special_code == 3) return '';
|
||||
if (empty($hidedetails) || $hidedetails > 1) $result.=$langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
|
||||
}
|
||||
return $result;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2008-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2020 Ferran Marcet <fmarcet@2byte.es>
|
||||
*
|
||||
* 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
|
||||
@ -556,6 +557,18 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
|
||||
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
|
||||
if ($feature == 'agenda')// Also check myactions rights
|
||||
{
|
||||
if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
|
||||
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
|
||||
$action = new ActionComm($db);
|
||||
$action->fetch($objectid);
|
||||
if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (in_array($feature, $checkproject))
|
||||
{
|
||||
|
||||
@ -388,7 +388,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '')
|
||||
//var_dump($expedition->linkedObjects);
|
||||
|
||||
$receiving='';
|
||||
if (count($expedition->linkedObjects['delivery']) > 0) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link
|
||||
if (!empty($expedition->linkedObjects['delivery'])) $receiving=reset($expedition->linkedObjects['delivery']); // Take first link
|
||||
|
||||
if (! empty($receiving))
|
||||
{
|
||||
|
||||
@ -593,7 +593,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
{
|
||||
$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxprogress, $curY);
|
||||
$pdf->MultiCell($this->postotalht-$this->posxprogress-1, 3, $progress, 0, 'R');
|
||||
$pdf->MultiCell($this->postotalht-$this->posxprogress+1, 3, $progress, 0, 'R');
|
||||
}
|
||||
|
||||
// Total HT line
|
||||
|
||||
@ -214,7 +214,7 @@ class modContrat extends DolibarrModules
|
||||
*/
|
||||
public function init($options = '')
|
||||
{
|
||||
global $conf;
|
||||
global $conf, $langs;
|
||||
|
||||
// Nettoyage avant activation
|
||||
$this->remove($options);
|
||||
|
||||
@ -772,7 +772,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
||||
|
||||
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||
|
||||
$carac_client=pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object);
|
||||
$usecontact = 0;
|
||||
|
||||
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object);
|
||||
|
||||
// Show recipient
|
||||
$widthrecbox=90;
|
||||
|
||||
@ -131,6 +131,21 @@ if ($action == 'presend')
|
||||
{
|
||||
$formmail->fromid = $user->id;
|
||||
}
|
||||
if ($object->element === 'facture' && !empty($conf->global->INVOICE_EMAIL_SENDER)) {
|
||||
$formmail->frommail = $conf->global->INVOICE_EMAIL_SENDER;
|
||||
$formmail->fromname = '';
|
||||
$formmail->fromtype = 'special';
|
||||
}
|
||||
if ($object->element === 'shipping' && !empty($conf->global->SHIPPING_EMAIL_SENDER)) {
|
||||
$formmail->frommail = $conf->global->SHIPPING_EMAIL_SENDER;
|
||||
$formmail->fromname = '';
|
||||
$formmail->fromtype = 'special';
|
||||
}
|
||||
if ($object->element === 'commande' && !empty($conf->global->COMMANDE_EMAIL_SENDER)) {
|
||||
$formmail->frommail = $conf->global->COMMANDE_EMAIL_SENDER;
|
||||
$formmail->fromname = '';
|
||||
$formmail->fromtype = 'special';
|
||||
}
|
||||
$formmail->trackid=$trackid;
|
||||
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
|
||||
{
|
||||
|
||||
@ -83,7 +83,7 @@ print '<td class="linecoldiscount right">'.$langs->trans('ReductionShort').'</td
|
||||
// Fields for situation invoice
|
||||
if ($this->situation_cycle_ref) {
|
||||
print '<td class="linecolcycleref right">' . $langs->trans('Progress') . '</td>';
|
||||
print '<td class="linecolcycleref2 right">' . $langs->trans('TotalHT100Short') . '</td>';
|
||||
print '<td class="linecolcycleref2 right">' . $form->textwithpicto($langs->trans('TotalHT100Short'), $langs->trans('UnitPriceXQtyLessDiscount')) . '</td>';
|
||||
}
|
||||
|
||||
if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id))
|
||||
|
||||
@ -321,10 +321,10 @@ class Expedition extends CommonObject
|
||||
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null");
|
||||
$sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null");
|
||||
$sql.= ", '".$this->db->escape($this->tracking_number)."'";
|
||||
$sql.= ", ".$this->weight;
|
||||
$sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth
|
||||
$sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth
|
||||
$sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight
|
||||
$sql.= ", ".(is_numeric($this->weight)?$this->weight:'NULL');
|
||||
$sql.= ", ".(is_numeric($this->sizeS)?$this->sizeS:'NULL'); // TODO Should use this->trueDepth
|
||||
$sql.= ", ".(is_numeric($this->sizeW)?$this->sizeW:'NULL'); // TODO Should use this->trueWidth
|
||||
$sql.= ", ".(is_numeric($this->sizeH)?$this->sizeH:'NULL'); // TODO Should use this->trueHeight
|
||||
$sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL');
|
||||
$sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL');
|
||||
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");
|
||||
@ -529,7 +529,7 @@ class Expedition extends CommonObject
|
||||
// Check parameters
|
||||
if (empty($id) && empty($ref) && empty($ref_ext) && empty($ref_int)) return -1;
|
||||
|
||||
$sql = "SELECT e.rowid, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed";
|
||||
$sql = "SELECT e.rowid, e.entity, e.ref, e.fk_soc as socid, e.date_creation, e.ref_customer, e.ref_ext, e.ref_int, e.fk_user_author, e.fk_statut, e.fk_projet as fk_project, e.billed";
|
||||
$sql.= ", e.date_valid";
|
||||
$sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height";
|
||||
$sql.= ", e.date_expedition as date_expedition, e.model_pdf, e.fk_address, e.date_delivery";
|
||||
@ -558,6 +558,7 @@ class Expedition extends CommonObject
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->entity = $obj->entity;
|
||||
$this->ref = $obj->ref;
|
||||
$this->socid = $obj->socid;
|
||||
$this->ref_customer = $obj->ref_customer;
|
||||
@ -602,7 +603,7 @@ class Expedition extends CommonObject
|
||||
$this->fk_incoterms = $obj->fk_incoterms;
|
||||
$this->location_incoterms = $obj->location_incoterms;
|
||||
$this->libelle_incoterms = $obj->libelle_incoterms;
|
||||
|
||||
|
||||
$this->db->free($result);
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1;
|
||||
|
||||
@ -970,7 +970,7 @@ class ExpenseReport extends CommonObject
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
|
||||
|
||||
$this->lines=array();
|
||||
|
||||
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,';
|
||||
@ -2274,7 +2274,7 @@ class ExpenseReport extends CommonObject
|
||||
public function load_state_board()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf;
|
||||
global $conf, $user;
|
||||
|
||||
$this->nb=array();
|
||||
|
||||
@ -2282,6 +2282,12 @@ class ExpenseReport extends CommonObject
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
|
||||
$sql.= " WHERE ex.fk_statut > 0";
|
||||
$sql.= " AND ex.entity IN (".getEntity('expensereport').")";
|
||||
if(!$user->rights->expensereport->readall)
|
||||
{
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
|
||||
}
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql) {
|
||||
@ -2316,15 +2322,17 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
|
||||
$sql = "SELECT ex.rowid, ex.date_valid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
|
||||
if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2";
|
||||
else $sql.= " WHERE ex.fk_statut = 5";
|
||||
$sql.= " AND ex.entity IN (".getEntity('expensereport').")";
|
||||
$sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
|
||||
if(!$user->rights->expensereport->readall)
|
||||
{
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql.= " AND (ex.fk_user_author IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR ex.fk_user_validator IN (".join(',', $userchildids)."))";
|
||||
}
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -273,7 +273,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
|
||||
$sql.= " WHERE c.entity = ".$conf->entity;
|
||||
$sql.= " WHERE c.entity IN (".getEntity('supplier_order').")";
|
||||
if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'";
|
||||
else $sql.= " AND c.rowid=".$id;
|
||||
|
||||
@ -844,6 +844,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
|
||||
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if (! $error)
|
||||
@ -1815,7 +1816,6 @@ class CommandeFournisseur extends CommonOrder
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
return -1;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
@ -1923,6 +1923,7 @@ class CommandeFournisseur extends CommonOrder
|
||||
{
|
||||
$this->errors[]='ErrorWhenRunningTrigger';
|
||||
dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
@ -1967,7 +1967,7 @@ class FactureFournisseur extends CommonInvoice
|
||||
$this->errors[] = $line->error;
|
||||
} else {
|
||||
// Update total price into invoice record
|
||||
$res = $this->update_price('', 'auto');
|
||||
$res = $this->update_price('', 'auto', 0, $this->thirdparty);
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
@ -27,10 +27,10 @@
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
|
||||
$langs->loadLangs(array('bills', 'banks', 'companies', 'suppliers'));
|
||||
|
||||
@ -210,7 +210,7 @@ if ($result > 0)
|
||||
*/
|
||||
|
||||
// Amount
|
||||
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>';
|
||||
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
|
||||
@ -2182,12 +2182,20 @@ class Holiday extends CommonObject
|
||||
public function load_state_board()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user;
|
||||
|
||||
$this->nb=array();
|
||||
|
||||
$sql = "SELECT count(h.rowid) as nb";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
|
||||
$sql.= " WHERE h.statut > 1";
|
||||
$sql.= " AND h.entity IN (".getEntity('holiday').")";
|
||||
if(!$user->rights->expensereport->read_all)
|
||||
{
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
|
||||
}
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql) {
|
||||
@ -2221,14 +2229,16 @@ class Holiday extends CommonObject
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
|
||||
$sql = "SELECT h.rowid, h.date_debut";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."holiday as h";
|
||||
$sql.= " WHERE h.statut = 2";
|
||||
$sql.= " AND h.entity IN (".getEntity('holiday').")";
|
||||
$sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
|
||||
if(!$user->rights->expensereport->read_all)
|
||||
{
|
||||
$userchildids = $user->getAllChildIds(1);
|
||||
$sql.= " AND (h.fk_user IN (".join(',', $userchildids).")";
|
||||
$sql.= " OR h.fk_validator IN (".join(',', $userchildids)."))";
|
||||
}
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -324,7 +324,7 @@ if (empty($user->societe_id))
|
||||
include_once $includes[$key]; // Loading a class cost around 1Mb
|
||||
|
||||
$board=new $classe($db);
|
||||
$board->load_state_board($user);
|
||||
$board->load_state_board();
|
||||
$boardloaded[$classe]=$board;
|
||||
}
|
||||
else
|
||||
|
||||
@ -337,9 +337,14 @@ UPDATE llx_c_lead_status set code = 'WON' where code = 'WIN';
|
||||
-- To replace amount on all invoice and lines when forgetting to apply a 20% vat
|
||||
-- update llx_facturedet set tva_tx = 20 where tva_tx = 0;
|
||||
-- update llx_facturedet set total_ht = round(total_ttc / 1.2, 5) where total_ht = total_ttc;
|
||||
-- update llx_facturedet set total_tva = total_ttc - total_ht where total_vat = 0;
|
||||
-- update llx_facture set total = round(total_ttc / 1.2, 5) where total_ht = total_ttc;
|
||||
-- update llx_facture set tva = total_ttc - total where tva = 0;
|
||||
|
||||
-- To fix bad total of price excluding tax, vat and price tax including tax.
|
||||
-- select * from llx_facture where tva <> (total_ttc - total - localtax1 - localtax2 - revenuestamp);
|
||||
-- update llx_facture set tva = (total_ttc - total - localtax1 - localtax2 - revenuestamp) where tva <> (total_ttc - total - localtax1 - localtax2 - revenuestamp);
|
||||
-- select * from llx_facturedet where total_tva <> (total_ttc - total_ht - total_localtax1 - total_localtax2);
|
||||
-- update llx_facturedet set total_tva = (total_ttc - total_ht - total_localtax1 - total_localtax2) where total_tva <> (total_ttc - total_ht - total_localtax1 - total_localtax2);
|
||||
|
||||
|
||||
-- To insert elements into a category
|
||||
-- Search idcategory: select rowid from llx_categorie where type=0 and ref like '%xxx%'
|
||||
@ -470,6 +475,11 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS
|
||||
-- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL;
|
||||
|
||||
|
||||
-- Test inconsistency of data into situation invoices: If it differs, it may be the total_ht that is wrong and situation_percent that is good.
|
||||
-- select f.rowid, f.type, fd.qty, fd.subprice, fd.situation_percent, fd.total_ht, fd.total_ttc, fd.total_tva, fd.multicurrency_total_ht, fd.multicurrency_total_tva, fd.multicurrency_total_ttc, (situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100)))
|
||||
-- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5;
|
||||
|
||||
|
||||
|
||||
-- Note to migrate from old counter aquarium to new one
|
||||
-- drop table tmp;
|
||||
|
||||
@ -3605,10 +3605,9 @@ function migrate_mode_reglement($db, $langs, $conf)
|
||||
* @param DoliDB $db Database handler
|
||||
* @param Translate $langs Object langs
|
||||
* @param Conf $conf Object conf
|
||||
* @param string $versionto Version target
|
||||
* @return void
|
||||
*/
|
||||
function migrate_clean_association($db, $langs, $conf, $versionto)
|
||||
function migrate_clean_association($db, $langs, $conf)
|
||||
{
|
||||
$result = $db->DDLDescTable(MAIN_DB_PREFIX."categorie_association");
|
||||
if ($result) // result defined for version 3.2 or -
|
||||
|
||||
@ -218,6 +218,7 @@ ListAccounts=List of the accounting accounts
|
||||
UnknownAccountForThirdparty=Unknown third-party account. We will use %s
|
||||
UnknownAccountForThirdpartyBlocking=Unknown third-party account. Blocking error
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Third-party account not defined or third party unknown. We will use %s
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Third-party unknown and subledger not defined on the payment. We will keep the subledger account value empty.
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Third-party account not defined or third party unknown. Blocking error.
|
||||
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Unknown third-party account and waiting account not defined. Blocking error
|
||||
PaymentsNotLinkedToProduct=Payment not linked to any product / service
|
||||
|
||||
@ -1792,6 +1792,7 @@ MailToThirdparty=Third parties
|
||||
MailToMember=Members
|
||||
MailToUser=Users
|
||||
MailToProject=Projects page
|
||||
MailToTicket=Tickets
|
||||
ByDefaultInList=Show by default on list view
|
||||
YouUseLastStableVersion=You use the latest stable version
|
||||
TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites)
|
||||
@ -1923,4 +1924,4 @@ DeleteEmailCollector=Delete email collector
|
||||
ConfirmDeleteEmailCollector=Are you sure you want to delete this email collector?
|
||||
RecipientEmailsWillBeReplacedWithThisValue=Recipient emails will be always replaced with this value
|
||||
AtLeastOneDefaultBankAccountMandatory=At least 1 default bank account must be defined
|
||||
FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled
|
||||
FeatureNotAvailableWithReceptionModule=Feature not available when module Reception is enabled
|
||||
|
||||
@ -554,4 +554,5 @@ AutoFillDateFromShort=Set start date
|
||||
AutoFillDateTo=Set end date for service line with next invoice date
|
||||
AutoFillDateToShort=Set end date
|
||||
MaxNumberOfGenerationReached=Max number of gen. reached
|
||||
BILL_DELETEInDolibarr=Invoice deleted
|
||||
BILL_DELETEInDolibarr=Invoice deleted
|
||||
UnitPriceXQtyLessDiscount=Unit price x Qty - Discount
|
||||
@ -218,6 +218,7 @@ ListAccounts=Liste des comptes comptables
|
||||
UnknownAccountForThirdparty=Compte de tiers inconnu. %s sera utilisé
|
||||
UnknownAccountForThirdpartyBlocking=Compte de tiers inconnu. Erreur bloquante.
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknown=Code comptable du tiers non défini ou tiers inconnu. On utilisera %s.
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored=Tiers inconnu et code comptable auxiliaire non défini sur le paiement. Nous conserverons la valeur du compte auxiliaire vide.
|
||||
ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking=Compte tiers non défini ou inconnu. Erreur bloquante.
|
||||
UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking=Compte tiers inconnu et compte d'attente non défini. Erreur blocante.
|
||||
PaymentsNotLinkedToProduct=Paiement non lié à un produit / service
|
||||
|
||||
@ -225,7 +225,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -208,7 +208,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("DatePropal", $_SERVER["PHP_SELF"], "p.datep", "", $option, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
@ -78,6 +78,7 @@ $cancel != $langs->trans("Cancel") &&
|
||||
$object->label = $_POST["libelle"];
|
||||
$object->description = dol_htmlcleanlastbr($_POST["desc"]);
|
||||
$object->other = dol_htmlcleanlastbr($_POST["other"]);
|
||||
$object->update($object->id, $user);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -63,7 +63,7 @@ $search_agenda_label=GETPOST('search_agenda_label');
|
||||
$id = GETPOST("id", 'int');
|
||||
$socid=0;
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
|
||||
$result=restrictedArea($user, 'projet', $id, '');
|
||||
$result=restrictedArea($user, 'projet', $id, 'projet&project');
|
||||
|
||||
if (!$user->rights->projet->lire) accessforbidden();
|
||||
|
||||
|
||||
@ -58,6 +58,7 @@ $search_task_label=GETPOST('search_task_label');
|
||||
$search_task_description=GETPOST('search_task_description');
|
||||
$search_project_user=GETPOST('search_project_user');
|
||||
$search_task_user=GETPOST('search_task_user');
|
||||
$search_societe=GETPOST('search_societe');
|
||||
|
||||
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
|
||||
if ($mine) { $search_task_user = $user->id; $mine = 0; }
|
||||
|
||||
@ -846,6 +846,11 @@ if (empty($reshook))
|
||||
$id=$socid;
|
||||
$object->fetch($socid);
|
||||
|
||||
// Selection of new fields
|
||||
if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
|
||||
}
|
||||
|
||||
// Actions to send emails
|
||||
$trigger_name='COMPANY_SENTBYMAIL';
|
||||
$paramname='socid';
|
||||
|
||||
@ -28,9 +28,9 @@ require_once NUSOAP_PATH.'/nusoap.php';
|
||||
$langs->load("companies");
|
||||
|
||||
//http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
|
||||
$WS_DOL_URL='http://ec.europa.eu/taxation_customs/vies/services/checkVatService';
|
||||
$WS_DOL_URL='https://ec.europa.eu/taxation_customs/vies/services/checkVatService';
|
||||
//$WS_DOL_URL_WSDL=$WS_DOL_URL.'?wsdl';
|
||||
$WS_DOL_URL_WSDL='http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
|
||||
$WS_DOL_URL_WSDL='https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
|
||||
$WS_METHOD ='checkVat';
|
||||
|
||||
|
||||
|
||||
@ -74,8 +74,8 @@ if (GETPOST('action', 'alpha') == 'set')
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTERS", GETPOST('TAKEPOS_ORDER_PRINTERS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_ORDER_NOTES", GETPOST('TAKEPOS_ORDER_NOTES', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_AUTO_PRINT_TICKETS", GETPOST('TAKEPOS_AUTO_PRINT_TICKETS', 'int'), 'int', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_NUMPAD", GETPOST('TAKEPOS_NUMPAD', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
$res = dolibarr_set_const($db, "TAKEPOS_NUM_TERMINALS", GETPOST('TAKEPOS_NUM_TERMINALS', 'alpha'), 'chaine', 0, '', $conf->entity);
|
||||
|
||||
|
||||
@ -176,11 +176,12 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
|
||||
// Force reload of setup for the current entity
|
||||
if ((empty($line->entity)?1:$line->entity) != $conf->entity)
|
||||
{
|
||||
dol_syslog("cron_run_jobs.php we work on another entity conf than ".$conf->entity." so we reload user and conf", LOG_DEBUG);
|
||||
echo " -> we change entity so we reload user and conf";
|
||||
dol_syslog("cron_run_jobs.php we work on another entity conf than ".$conf->entity." so we reload mysoc, langs, user and conf", LOG_DEBUG);
|
||||
echo " -> we change entity so we reload mysoc, langs, user and conf";
|
||||
|
||||
$conf->entity = (empty($line->entity)?1:$line->entity);
|
||||
$conf->setValues($db); // This make also the $mc->setValues($conf); that reload $mc->sharings
|
||||
$mysoc->setMysoc($conf);
|
||||
|
||||
// Force recheck that user is ok for the entity to process and reload permission for entity
|
||||
if ($conf->entity != $user->entity && $user->entity != 0)
|
||||
@ -203,6 +204,11 @@ if (is_array($qualifiedjobs) && (count($qualifiedjobs) > 0)) {
|
||||
}
|
||||
$user->getrights();
|
||||
}
|
||||
|
||||
// Reload langs
|
||||
$langcode = (empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT);
|
||||
if (! empty($user->conf->MAIN_LANG_DEFAULT)) $langcode = $user->conf->MAIN_LANG_DEFAULT;
|
||||
if ($langs->getDefaultLang() != $langcode) $langs->setDefaultLang($langcode);
|
||||
}
|
||||
|
||||
//If date_next_jobs is less of current date, execute the program, and store the execution time of the next execution in database
|
||||
|
||||
Loading…
Reference in New Issue
Block a user