2
0
forked from Wavyzz/dolibarr

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

This commit is contained in:
ldestailleur
2025-03-19 13:47:25 +01:00
15 changed files with 172 additions and 159 deletions

View File

@@ -2457,7 +2457,7 @@ if ($id > 0) {
} elseif ($valuetoshow == 2) { } elseif ($valuetoshow == 2) {
$valuetoshow = $langs->trans('CurrentNext'); $valuetoshow = $langs->trans('CurrentNext');
} }
$class = "center"; $class = "center tdoverflowmax125";
} elseif ($value == 'price' || preg_match('/^amount/i', $value)) { } elseif ($value == 'price' || preg_match('/^amount/i', $value)) {
$valuetoshow = price($valuetoshow); $valuetoshow = price($valuetoshow);
} }
@@ -2469,6 +2469,8 @@ if ($id > 0) {
$key = $langs->trans("PaymentCondition".strtoupper($obj->code)); $key = $langs->trans("PaymentCondition".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = ($obj->code && $key != "PaymentCondition".strtoupper($obj->code) ? $key : $obj->$value);
$valuetoshow = nl2br($valuetoshow); $valuetoshow = nl2br($valuetoshow);
$titletoshow = $valuetoshow;
$class = 'small tdoverflowmax200';
} elseif ($value == 'label' && $tabname[$id] == 'c_country') { } elseif ($value == 'label' && $tabname[$id] == 'c_country') {
$key = $langs->trans("Country".strtoupper($obj->code)); $key = $langs->trans("Country".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = ($obj->code && $key != "Country".strtoupper($obj->code) ? $key : $obj->$value);
@@ -2496,6 +2498,8 @@ if ($id > 0) {
} elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') { } elseif ($value == 'libelle' && $tabname[$id] == 'c_payment_term') {
$key = $langs->trans("PaymentConditionShort".strtoupper($obj->code)); $key = $langs->trans("PaymentConditionShort".strtoupper($obj->code));
$valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value); $valuetoshow = ($obj->code && $key != "PaymentConditionShort".strtoupper($obj->code) ? $key : $obj->$value);
$titletoshow = $key;
$class = "tdoverflowmax150";
} elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') { } elseif ($value == 'libelle' && $tabname[$id] == 'c_paiement') {
$transavailableforcode = $langs->tab_translate["PaymentType".strtoupper($obj->code)]; $transavailableforcode = $langs->tab_translate["PaymentType".strtoupper($obj->code)];
$key = $langs->trans("PaymentType".strtoupper($obj->code)); $key = $langs->trans("PaymentType".strtoupper($obj->code));
@@ -2641,7 +2645,7 @@ if ($id > 0) {
// Favorite, EEC & Sepa // Favorite, EEC & Sepa
// Only for country dictionary // Only for country dictionary
if ($id == DICT_COUNTRY) { if ($id == DICT_COUNTRY) {
print '<td class="nowrap center">'; print '<td class="nowraponall center">';
// Is in EEC // Is in EEC
if ($iserasable) { if ($iserasable) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->eec].'_eec&token='.newToken().'">'.$actl[$obj->eec].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[$obj->eec].'_eec&token='.newToken().'">'.$actl[$obj->eec].'</a>';
@@ -2649,7 +2653,7 @@ if ($id > 0) {
print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>'; print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
} }
print '</td>'; print '</td>';
print '<td class="nowrap center">'; print '<td class="nowraponall center">';
// Is in Sepa // Is in Sepa
if ($iserasable) { if ($iserasable) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->sepa].'_sepa&token='.newToken().'">'.$actl[$obj->sepa].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[$obj->sepa].'_sepa&token='.newToken().'">'.$actl[$obj->sepa].'</a>';
@@ -2657,7 +2661,7 @@ if ($id > 0) {
print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>'; print '<span class="opacitymedium">'.$langs->trans("AlwaysActive").'</span>';
} }
print '</td>'; print '</td>';
print '<td class="nowrap center">'; print '<td class="nowraponall center">';
// Favorite // Favorite
if ($iserasable) { if ($iserasable) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite&token='.newToken().'">'.$actl[$obj->favorite].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[$obj->favorite].'_favorite&token='.newToken().'">'.$actl[$obj->favorite].'</a>';
@@ -2669,7 +2673,7 @@ if ($id > 0) {
} }
// Active // Active
print '<td class="nowrap center">'; print '<td class="nowraponall center">';
if ($canbedisabled) { if ($canbedisabled) {
print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>'; print '<a class="reposition" href="'.$url.'action='.$acts[$obj->active].'&token='.newToken().'">'.$actl[$obj->active].'</a>';
} else { } else {

View File

@@ -70,6 +70,7 @@ $massaction = GETPOST('massaction', 'alpha');
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$mode = GETPOST('mode', 'aZ09'); $mode = GETPOST('mode', 'aZ09');
$optioncss = GETPOST('optioncss', 'alpha'); $optioncss = GETPOST('optioncss', 'alpha');
$backtopage = GETPOST('backtopage');
$contextpage = GETPOST('contextpage', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ09');
$id = $rowid = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid')); $id = $rowid = (GETPOSTINT('id') ? GETPOSTINT('id') : GETPOSTINT('rowid'));
@@ -290,15 +291,21 @@ if ($rowid > 0) {
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { if (GETPOST('cancel', 'alpha') || GETPOST('actioncancel', 'alpha')) {
$action = 'list'; $action = 'list';
$massaction = ''; $massaction = '';
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit(1);
}
} }
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = ''; $massaction = '';
} }
$parameters = array(); $parameters = array();
$object = null;
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) { if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
@@ -442,6 +449,11 @@ if (empty($reshook)) {
if ($result) { // Add is ok if ($result) { // Add is ok
setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
$_POST = array('id' => 25); // Clean $_POST array, we keep only id $_POST = array('id' => 25); // Clean $_POST array, we keep only id
if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit(1);
}
} else { } else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors'); setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
@@ -743,6 +755,7 @@ if ($action == 'create') {
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">'; print '<input type="hidden" name="from" value="'.dol_escape_htmltag(GETPOST('from', 'alpha')).'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';

View File

@@ -2106,7 +2106,7 @@ if ($action == 'create') {
print '</td></tr>'; print '</td></tr>';
// Validaty duration // Validaty duration
print '<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">'.$langs->trans("ValidityDuration").'</td><td class="valuefieldcreate">'.img_picto('', 'clock', 'class="pictofixedwidth"').'<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : $conf->global->PROPALE_VALIDITY_DURATION).'"> '.$langs->trans("days").'</td></tr>'; print '<tr class="field_duree_validitee"><td class="titlefieldcreate fieldrequired">'.$langs->trans("ValidityDuration").'</td><td class="valuefieldcreate">'.img_picto('', 'clock', 'class="pictofixedwidth"').'<input name="duree_validite" class="width50" value="'.(GETPOSTISSET('duree_validite') ? GETPOST('duree_validite', 'alphanohtml') : getDolGlobalString('PROPALE_VALIDITY_DURATION')).'"> '.$langs->trans("days").'</td></tr>';
// Terms of payment // Terms of payment
print '<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>'; print '<tr class="field_cond_reglement_id"><td class="nowrap">'.$langs->trans('PaymentConditionsShort').'</td><td>';

View File

@@ -3422,9 +3422,14 @@ class Facture extends CommonInvoice
$num = $this->ref; $num = $this->ref;
} }
$this->newref = dol_sanitizeFileName($num); if (!$num) {
$error++;
} else {
$this->oldref = $this->ref;
$this->newref = dol_sanitizeFileName($num);
}
if ($num) { if (!$error) {
$this->update_price(1); $this->update_price(1);
// Validate // Validate
@@ -3442,132 +3447,125 @@ class Facture extends CommonInvoice
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
$error++; $error++;
} }
}
// We check if the invoice was provisional if (!$error) {
/* // Define third party as a customer
if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref))) { $result = $this->thirdparty->setAsCustomer();
// La verif qu'une remise n'est pas utilisee 2 fois est faite au moment de l'insertion de ligne
}
*/
if (!$error) { // If active (STOCK_CALCULATE_ON_BILL), we decrement the main product and its components at invoice validation
// Define third party as a customer if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $idwarehouse > 0) {
$result = $this->thirdparty->setAsCustomer(); require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
$langs->load("agenda");
// If active (STOCK_CALCULATE_ON_BILL), we decrement the main product and its components at invoice validation // Loop on each line
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && isModEnabled('stock') && getDolGlobalString('STOCK_CALCULATE_ON_BILL') && $idwarehouse > 0) { $cpt = count($this->lines);
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; for ($i = 0; $i < $cpt; $i++) {
$langs->load("agenda"); if ($this->lines[$i]->fk_product > 0) {
$mouvP = new MouvementStock($this->db);
$mouvP->origin = &$this; // deprecated
$mouvP->setOrigin($this->element, $this->id);
// Loop on each line // We decrease stock for product
$cpt = count($this->lines); if ($this->type == self::TYPE_CREDIT_NOTE) {
for ($i = 0; $i < $cpt; $i++) { // TODO If warehouseid has been set into invoice line, we should use this value in priority
if ($this->lines[$i]->fk_product > 0) { // $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse;
$mouvP = new MouvementStock($this->db); $result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num), '', '', $this->lines[$i]->batch);
$mouvP->origin = &$this; // deprecated if ($result < 0) {
$mouvP->setOrigin($this->element, $this->id); $error++;
$this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
} else {
// TODO If warehouseid has been set into invoice line, we should use this value in priority
// $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse;
// We decrease stock for product $is_batch_line = false;
if ($this->type == self::TYPE_CREDIT_NOTE) { if ($batch_rule > 0) {
// TODO If warehouseid has been set into invoice line, we should use this value in priority $productStatic->fetch($this->lines[$i]->fk_product);
// $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse; if ($productStatic->hasbatch() && is_object($productbatch)) {
$result = $mouvP->reception($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, 0, $langs->trans("InvoiceValidatedInDolibarr", $num), '', '', $this->lines[$i]->batch); $is_batch_line = true;
if ($result < 0) { $product_qty_remain = $this->lines[$i]->qty;
$error++;
$this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
} else {
// TODO If warehouseid has been set into invoice line, we should use this value in priority
// $newidwarehouse = $this->lines[$i]->fk_warehouse ? $this->lines[$i]->fk_warehouse : $idwarehouse;
$is_batch_line = false; $sortfield = '';
if ($batch_rule > 0) { $sortorder = '';
$productStatic->fetch($this->lines[$i]->fk_product); // find lot/serial by sellby (DLC) and eatby dates (DLUO) first
if ($productStatic->hasbatch() && is_object($productbatch)) { if ($batch_rule == Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST) {
$is_batch_line = true; $sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid';
$product_qty_remain = $this->lines[$i]->qty; $sortorder = 'ASC,ASC,ASC,ASC';
}
$sortfield = ''; $resBatchList = $productbatch->findAllForProduct($productStatic->id, $idwarehouse, (getDolGlobalInt('STOCK_DISALLOW_NEGATIVE_TRANSFER') ? 0 : null), $sortfield, $sortorder);
$sortorder = ''; if (!is_array($resBatchList)) {
// find lot/serial by sellby (DLC) and eatby dates (DLUO) first $error++;
if ($batch_rule == Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST) { $this->error = $this->db->lasterror();
$sortfield = 'pl.sellby,pl.eatby,pb.qty,pl.rowid'; }
$sortorder = 'ASC,ASC,ASC,ASC';
}
$resBatchList = $productbatch->findAllForProduct($productStatic->id, $idwarehouse, (getDolGlobalInt('STOCK_DISALLOW_NEGATIVE_TRANSFER') ? 0 : null), $sortfield, $sortorder); if (!$error) {
if (!is_array($resBatchList)) { $batchList = $resBatchList;
if (empty($batchList)) {
$error++; $error++;
$this->error = $this->db->lasterror(); $langs->load('errors');
$warehouseStatic->fetch($idwarehouse);
$this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
} }
if (!$error) { foreach ($batchList as $batch) {
$batchList = $resBatchList; if ($batch->qty <= 0) {
if (empty($batchList)) { continue; // try to decrement only batches have positive quantity first
}
// enough quantity in this batch
if ($batch->qty >= $product_qty_remain) {
$product_batch_qty = $product_qty_remain;
} else {
// not enough (take all in batch)
$product_batch_qty = $batch->qty;
}
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors);
break;
}
$product_qty_remain -= $product_batch_qty;
// all product quantity was decremented
if ($product_qty_remain <= 0) {
break;
}
}
if (!$error && $product_qty_remain > 0) {
if (getDolGlobalInt('STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
$error++; $error++;
$langs->load('errors'); $langs->load('errors');
$warehouseStatic->fetch($idwarehouse); $warehouseStatic->fetch($idwarehouse);
$this->error = $langs->trans('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref); $this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR); dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
} } else {
// take in the first batch
foreach ($batchList as $batch) { $batch = $batchList[0];
if ($batch->qty <= 0) { $result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
continue; // try to decrement only batches have positive quantity first
}
// enough quantity in this batch
if ($batch->qty >= $product_qty_remain) {
$product_batch_qty = $product_qty_remain;
} else {
// not enough (take all in batch)
$product_batch_qty = $batch->qty;
}
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_batch_qty, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->error = $mouvP->error; $this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors); $this->errors = array_merge($this->errors, $mouvP->errors);
break;
}
$product_qty_remain -= $product_batch_qty;
// all product quantity was decremented
if ($product_qty_remain <= 0) {
break;
}
}
if (!$error && $product_qty_remain > 0) {
if (getDolGlobalInt('STOCK_DISALLOW_NEGATIVE_TRANSFER')) {
$error++;
$langs->load('errors');
$warehouseStatic->fetch($idwarehouse);
$this->error = $langs->trans('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref);
dol_syslog(__METHOD__.' Error: '.$langs->transnoentitiesnoconv('ErrorBatchNoFoundEnoughQuantityForProductInWarehouse', $productStatic->label, $warehouseStatic->ref), LOG_ERR);
} else {
// take in the first batch
$batch = $batchList[0];
$result = $mouvP->livraison($user, $productStatic->id, $idwarehouse, $product_qty_remain, $this->lines[$i]->subprice, $langs->trans('InvoiceValidatedInDolibarr', $num), '', '', '', $batch->batch);
if ($result < 0) {
$error++;
$this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors);
}
} }
} }
} }
} }
} }
}
if (!$is_batch_line) { // If stock move not yet processed if (!$is_batch_line) { // If stock move not yet processed
$result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num)); $result = $mouvP->livraison($user, $this->lines[$i]->fk_product, $idwarehouse, $this->lines[$i]->qty, $this->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarr", $num));
if ($result < 0) { if ($result < 0) {
$error++; $error++;
$this->error = $mouvP->error; $this->error = $mouvP->error;
$this->errors = array_merge($this->errors, $mouvP->errors); $this->errors = array_merge($this->errors, $mouvP->errors);
}
} }
} }
} }
@@ -3605,8 +3603,6 @@ class Facture extends CommonInvoice
} }
if (!$error) { if (!$error) {
$this->oldref = $this->ref;
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) { if (preg_match('/^[\(]?PROV/i', $this->ref)) {
// Now we rename also files into index // Now we rename also files into index
@@ -3624,28 +3620,6 @@ class Facture extends CommonInvoice
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();
} }
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output.'/'.$oldref;
$dirdest = $conf->facture->dir_output.'/'.$newref;
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
$dirdest = $fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
} }
} }
@@ -3689,8 +3663,31 @@ class Facture extends CommonInvoice
$this->setFinal($user); $this->setFinal($user);
} }
} }
} else { }
$error++;
// Rename directory if dir was a temporary ref
if (!$error && preg_match('/^[\(]?PROV/i', $this->oldref)) {
// We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
$oldref = dol_sanitizeFileName($this->oldref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->facture->dir_output.'/'.$oldref;
$dirdest = $conf->facture->dir_output.'/'.$newref;
if (!$error && file_exists($dirsource)) {
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
if (@rename($dirsource, $dirdest)) {
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles = dol_dir_list($conf->facture->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
foreach ($listoffiles as $fileentry) {
$dirsource = $fileentry['name'];
$dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
$dirsource = $fileentry['path'].'/'.$dirsource;
$dirdest = $fileentry['path'].'/'.$dirdest;
@rename($dirsource, $dirdest);
}
}
}
} }
if (!$error) { if (!$error) {

View File

@@ -229,7 +229,7 @@ class box_factures_fourn_imp extends ModeleBoxes
'text' => "&nbsp;", 'text' => "&nbsp;",
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="right liste_total" ', 'td' => 'class="nowraponall right liste_total"',
'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency), 'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency),
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(

View File

@@ -235,7 +235,7 @@ class box_factures_imp extends ModeleBoxes
// Add the sum à the bottom of the boxes // Add the sum à the bottom of the boxes
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'tr' => 'class="liste_total_wrap"', 'tr' => 'class="liste_total"',
'td' => 'class="liste_total"', 'td' => 'class="liste_total"',
'text' => $langs->trans("Total"), 'text' => $langs->trans("Total"),
); );
@@ -244,7 +244,7 @@ class box_factures_imp extends ModeleBoxes
'text' => "&nbsp;", 'text' => "&nbsp;",
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(
'td' => 'class="right liste_total" ', 'td' => 'class="nowraponall right liste_total" ',
'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency), 'text' => price($totalamount, 0, $langs, 0, -1, -1, $conf->currency),
); );
$this->info_box_contents[$line][] = array( $this->info_box_contents[$line][] = array(

View File

@@ -957,6 +957,7 @@ class Notify
} }
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object);
// Note the substitution array should contains __REF__, __NEWREF__ ....
$subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs); $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
$message = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs); $message = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
} else { } else {

View File

@@ -1906,6 +1906,8 @@ function form_constantes($tableau, $strictw3c = 2, $helptext = '', $text = 'Valu
//var_dump($arraydefaultmessage); //var_dump($arraydefaultmessage);
//var_dump($arrayofmessagename); //var_dump($arrayofmessagename);
print $form->selectarray('constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')), $arrayofmessagename, $obj->value.':'.$tmp[1], 'None', 0, 0, '', 0, 0, 0, '', '', 1); print $form->selectarray('constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')), $arrayofmessagename, $obj->value.':'.$tmp[1], 'None', 0, 0, '', 0, 0, 0, '', '', 1);
print '<a href="'.DOL_URL_ROOT.'/admin/mails_templates.php?action=create&type_template='.urlencode($tmp[1]).'&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">'.img_picto('', 'add').'</a>';
} elseif (preg_match('/MAIL_FROM$/i', $const)) { } elseif (preg_match('/MAIL_FROM$/i', $const)) {
print img_picto('', 'email', 'class="pictofixedwidth"').'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')).'" value="'.dol_escape_htmltag($obj->value).'">'; print img_picto('', 'email', 'class="pictofixedwidth"').'<input type="text" class="flat minwidth300" name="constvalue'.(empty($strictw3c) ? '' : ($strictw3c == 3 ? '_'.$const : '[]')).'" value="'.dol_escape_htmltag($obj->value).'">';
} else { // type = 'string' ou 'chaine' } else { // type = 'string' ou 'chaine'

View File

@@ -927,9 +927,9 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0)
$filename = dol_sanitizeFileName($obj->ref); $filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename; $filedir = $conf->propal->multidir_output[$obj->entity].'/'.$filename;
$result .= '<tr class="nowrap">'; $result .= '<tr class="oddeven">';
$result .= '<td class="oddeven">'; $result .= '<td class="nowrap">';
$result .= '<table class="nobordernopadding">'; $result .= '<table class="nobordernopadding">';
$result .= '<tr class="nocellnopadd">'; $result .= '<tr class="nocellnopadd">';
@@ -942,7 +942,7 @@ function getCustomerInvoiceLatestEditTable($maxCount = 5, $socid = 0)
$result .= '</td>'; $result .= '</td>';
$result .= '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>'; $result .= '<td class="tdoverflowmax150">'.$companystatic->getNomUrl(1, 'customer').'</td>';
$result .= '<td>'.dol_print_date($db->jdate($obj->datec), 'day').'</td>'; $result .= '<td title="'.dol_print_date($db->jdate($obj->datec), 'day').'">'.dol_print_date($db->jdate($obj->datec), 'day').'</td>';
$result .= '<td class="right amount">'.price($obj->total_ttc).'</td>'; $result .= '<td class="right amount">'.price($obj->total_ttc).'</td>';
// Load amount of existing payment of invoice (needed for complete status) // Load amount of existing payment of invoice (needed for complete status)
@@ -1207,7 +1207,7 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
print '<td class="nowrap tdoverflowmax100">'; print '<td class="nowrap tdoverflowmax100">';
print $societestatic->getNomUrl(1, 'customer'); print $societestatic->getNomUrl(1, 'customer');
print '</td>'; print '</td>';
print '<td class="right">'; print '<td class="right" title="'.dol_print_date($db->jdate($obj->datelimite), 'day').'">';
print dol_print_date($db->jdate($obj->datelimite), 'day'); print dol_print_date($db->jdate($obj->datelimite), 'day');
if ($tmpinvoice->hasDelay()) { if ($tmpinvoice->hasDelay()) {
print img_warning($langs->trans("Late")); print img_warning($langs->trans("Late"));

View File

@@ -99,7 +99,7 @@ class InterfaceNotification extends DolibarrTriggers
$notify = new Notify($this->db); $notify = new Notify($this->db);
$resultSend = $notify->send($action, $object); $resultSend = $notify->send($action, $object);
if ($resultSend < 0) { if ($resultSend < 0) {
$this->errors = array_merge($this->errors, $notify->errors); $this->errors = array_merge(empty($this->errors) ? array() : $this->errors, $notify->errors);
return $resultSend; return $resultSend;
} }

View File

@@ -132,7 +132,7 @@ $result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture',
// Common permissions // Common permissions
$usercanread = ($user->hasRight("fournisseur", "facture", "lire") || $user->hasRight("supplier_invoice", "lire")); $usercanread = ($user->hasRight("fournisseur", "facture", "lire") || $user->hasRight("supplier_invoice", "lire"));
$usercancreate = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer")); $usercancreate = ($user->hasRight("fournisseur", "facture", "creer") || $user->hasRight("supplier_invoice", "creer"));
$usercandelete = ($user->hasRight("fournisseur", "facture", "supprimer") || $user->hasRight("supplier_invoice", "supprimer")); $usercandelete = (($user->hasRight("fournisseur", "facture", "supprimer") || $user->hasRight("supplier_invoice", "supprimer")) || ($usercancreate && $object->is_erasable() == 1));
$usercancreatecontract = $user->hasRight("contrat", "creer"); $usercancreatecontract = $user->hasRight("contrat", "creer");
// Advanced permissions // Advanced permissions
@@ -279,7 +279,7 @@ if (empty($reshook)) {
$isErasable = $object->is_erasable(); $isErasable = $object->is_erasable();
if (($usercandelete && $isErasable > 0) || ($usercancreate && $isErasable == 1)) { if ($usercandelete && $isErasable > 0) {
$revertstock = GETPOST('revertstock'); $revertstock = GETPOST('revertstock');
if ($revertstock) { if ($revertstock) {
@@ -4175,8 +4175,9 @@ if ($action == 'create') {
} }
// Delete // Delete
$isErasable = $object->is_erasable(); if ($action != 'confirm_edit' && $usercandelete) {
if ($action != 'confirm_edit' && ($usercandelete || ($usercancreate && $isErasable == 1))) { // isErasable = 1 means draft with temporary ref (draft can always be deleted with no need of permissions) $isErasable = $object->is_erasable();
$enableDelete = false; $enableDelete = false;
$htmltooltip = ''; $htmltooltip = '';
$params = (empty($conf->use_javascript_ajax) ? array() : array('attr' => array('class' => 'reposition'))); $params = (empty($conf->use_javascript_ajax) ? array() : array('attr' => array('class' => 'reposition')));

View File

@@ -249,7 +249,7 @@ if ($result > 0) {
// Add notification form // Add notification form
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.urlencode((string) ($id)).'" method="POST">'; print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.urlencode((string) $socid).'" method="POST">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="page_y" value="">'; print '<input type="hidden" name="page_y" value="">';
if ($action == 'create') { if ($action == 'create') {
@@ -276,7 +276,7 @@ if ($result > 0) {
dol_print_error($db); dol_print_error($db);
} }
$param = ''; $param = "&socid=".$socid;
$newcardbutton = ''; $newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->hasRight("societe", "creer")); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER["PHP_SELF"].'?socid='.$object->id.'&action=create&backtopage='.urlencode($_SERVER['PHP_SELF']), '', $user->hasRight("societe", "creer"));
@@ -290,12 +290,6 @@ if ($result > 0) {
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition, PhanPluginSuspiciousParamOrder // @phan-suppress-next-line PhanPluginSuspiciousParamPosition, PhanPluginSuspiciousParamOrder
print_barre_liste($titlelist, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords), 'email', 0, $newcardbutton, '', $limitforsubscription, 0, 0, 1); print_barre_liste($titlelist, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, (empty($nbtotalofrecords) ? -1 : $nbtotalofrecords), 'email', 0, $newcardbutton, '', $limitforsubscription, 0, 0, 1);
print '<form action="'.$_SERVER["PHP_SELF"].'?socid='.$socid.'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
$param = "&socid=".$socid;
// Line with titles // Line with titles
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';

View File

@@ -319,7 +319,7 @@ th.liste_titre a div div:hover, th.liste_titre_sel a div div:hover { text-decora
tr.liste_titre th.liste_titre_sel:not(.maxwidthsearch), tr.liste_titre td.liste_titre_sel:not(.maxwidthsearch), tr.liste_titre th.liste_titre_sel:not(.maxwidthsearch), tr.liste_titre td.liste_titre_sel:not(.maxwidthsearch),
tr.liste_titre th.liste_titre:not(.maxwidthsearch), tr.liste_titre td.liste_titre:not(.maxwidthsearch) { opacity: 0.8; } tr.liste_titre th.liste_titre:not(.maxwidthsearch), tr.liste_titre td.liste_titre:not(.maxwidthsearch) { opacity: 0.8; }
/* th.liste_titre_sel a, th.liste_titre a, td.liste_titre_sel a, td.liste_titre a { color: #766; } */ /* th.liste_titre_sel a, th.liste_titre a, td.liste_titre_sel a, td.liste_titre a { color: #766; } */
tr.liste_titre_filter th.liste_titre { text-align: unset; } tr.liste_titre_filter th.liste_titre:not(.center) { text-align: unset; }
.liste_titre.trheight5em { .liste_titre.trheight5em {
height: 4em !important; height: 4em !important;
} }

View File

@@ -4984,7 +4984,7 @@ tr.liste_titre:last-child th.liste_titre, tr.liste_titre:last-child th.liste_tit
/* border-bottom: 1px solid var(--colortopbordertitle1); */ /* border-bottom: 1px solid var(--colortopbordertitle1); */
border-bottom: none; border-bottom: none;
} }
tr.liste_titre_filter th.liste_titre { text-align: unset; } tr.liste_titre_filter th.liste_titre:not(.center) { text-align: unset; }
/* /*
div.liste_titre { div.liste_titre {

View File

@@ -299,6 +299,7 @@ if (is_array($object->lines) && (count($object->lines) > 0)) {
} else { } else {
$nbofjobslaunchedok++; $nbofjobslaunchedok++;
$resultstring = 'OK'; $resultstring = 'OK';
echo " - ";
} }
echo "Result of run_jobs ".$resultstring." result = ".$result; echo "Result of run_jobs ".$resultstring." result = ".$result;