mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-12 02:42:33 +01:00
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -285,6 +285,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||
|
||||
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
|
||||
$sql .= " a.gender, a.email, a.photo, a.morphy,";
|
||||
$sql .= " a.tms as datem, datefin as date_end_subscription,";
|
||||
$sql .= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
|
||||
@@ -307,8 +308,13 @@ if ($resql) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
print '<tr class="oddeven">';
|
||||
$staticmember->id = $obj->rowid;
|
||||
$staticmember->ref = $obj->rowid;
|
||||
$staticmember->lastname = $obj->lastname;
|
||||
$staticmember->firstname = $obj->firstname;
|
||||
$staticmember->gender = $obj->gender;
|
||||
$staticmember->email = $obj->email;
|
||||
$staticmember->photo = $obj->photo;
|
||||
$staticmember->morphy = $obj->morphy;
|
||||
if (!empty($obj->fk_soc)) {
|
||||
$staticmember->fk_soc = $obj->fk_soc;
|
||||
$staticmember->fetch_thirdparty();
|
||||
@@ -316,10 +322,9 @@ if ($resql) {
|
||||
} else {
|
||||
$staticmember->name = $obj->company;
|
||||
}
|
||||
$staticmember->ref = $staticmember->getFullName($langs);
|
||||
$statictype->id = $obj->typeid;
|
||||
$statictype->label = $obj->label;
|
||||
print '<td class="nowraponall">'.$staticmember->getNomUrl(1, 32).'</td>';
|
||||
print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32).'</td>';
|
||||
print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
|
||||
print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
|
||||
print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription == 'yes' ? 1 : 0), $db->jdate($obj->date_end_subscription), 3).'</td>';
|
||||
@@ -340,7 +345,8 @@ if ($resql) {
|
||||
$max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
|
||||
|
||||
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
|
||||
$sql .= " datefin as date_end_subscription,";
|
||||
$sql .= " a.gender, a.email, a.photo, a.morphy,";
|
||||
$sql .= " a.datefin as date_end_subscription,";
|
||||
$sql .= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c";
|
||||
$sql .= " WHERE a.entity IN (".getEntity('adherent').")";
|
||||
@@ -364,8 +370,13 @@ if ($resql) {
|
||||
$subscriptionstatic->id = $obj->cid;
|
||||
$subscriptionstatic->ref = $obj->cid;
|
||||
$staticmember->id = $obj->rowid;
|
||||
$staticmember->ref = $obj->rowid;
|
||||
$staticmember->lastname = $obj->lastname;
|
||||
$staticmember->firstname = $obj->firstname;
|
||||
$staticmember->gender = $obj->gender;
|
||||
$staticmember->email = $obj->email;
|
||||
$staticmember->photo = $obj->photo;
|
||||
$staticmember->morphy = $obj->morphy;
|
||||
if (!empty($obj->fk_soc)) {
|
||||
$staticmember->fk_soc = $obj->fk_soc;
|
||||
$staticmember->fetch_thirdparty();
|
||||
@@ -373,9 +384,8 @@ if ($resql) {
|
||||
} else {
|
||||
$staticmember->name = $obj->company;
|
||||
}
|
||||
$staticmember->ref = $staticmember->getFullName($langs);
|
||||
print '<td class="nowraponall">'.$subscriptionstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="nowraponall">'.$staticmember->getNomUrl(1, 32, 'subscription').'</td>';
|
||||
print '<td class="nowraponall">'.$staticmember->getNomUrl(-1, 32, 'subscription').'</td>';
|
||||
print '<td class="nowraponall">'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';
|
||||
print '<td class="right">'.price($obj->subscription).'</td>';
|
||||
//print '<td class="right">'.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';
|
||||
|
||||
@@ -656,6 +656,7 @@ while ($i < min($num, $limit)) {
|
||||
$memberstatic->datefin = $datefin;
|
||||
$memberstatic->socid = $obj->fk_soc;
|
||||
$memberstatic->photo = $obj->photo;
|
||||
$memberstatic->email = $obj->email;
|
||||
$memberstatic->morphy = $obj->morphy;
|
||||
$memberstatic->note_public = $obj->note_public;
|
||||
$memberstatic->note_private = $obj->note_private;
|
||||
@@ -725,12 +726,10 @@ while ($i < min($num, $limit)) {
|
||||
if (!empty($arrayfields['d.morphy']['checked'])) {
|
||||
print '<td class="center">';
|
||||
$s = '';
|
||||
if ($obj->morphy == 'phy')
|
||||
{
|
||||
if ($obj->morphy == 'phy') {
|
||||
$s .= '<span class="customer-back" title="'.$langs->trans("Physical").'">'.dol_substr($langs->trans("Physical"), 0, 1).'</span>';
|
||||
}
|
||||
if ($obj->morphy == 'mor')
|
||||
{
|
||||
if ($obj->morphy == 'mor') {
|
||||
$s .= '<span class="vendor-back" title="'.$langs->trans("Moral").'">'.dol_substr($langs->trans("Moral"), 0, 1).'</span>';
|
||||
}
|
||||
print $s;
|
||||
|
||||
@@ -142,6 +142,7 @@ $now = dol_now();
|
||||
|
||||
// List of subscriptions
|
||||
$sql = "SELECT d.rowid, d.login, d.firstname, d.lastname, d.societe, d.photo, d.statut,";
|
||||
$sql .= " d.gender, d.email, d.morphy,";
|
||||
$sql .= " c.rowid as crowid, c.fk_type, c.subscription,";
|
||||
$sql .= " c.dateadh, c.datef, c.datec as date_creation, c.tms as date_update,";
|
||||
$sql .= " c.fk_bank as bank, c.note,";
|
||||
@@ -151,8 +152,7 @@ $sql .= " JOIN ".MAIN_DB_PREFIX."subscription as c on d.rowid = c.fk_adherent";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_extrafields as ef on (d.rowid = ef.fk_object)";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON c.fk_bank=b.rowid";
|
||||
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
||||
if (isset($date_select) && $date_select != '')
|
||||
{
|
||||
if (isset($date_select) && $date_select != '') {
|
||||
$sql .= " AND c.dateadh >= '".((int) $date_select)."-01-01 00:00:00'";
|
||||
$sql .= " AND c.dateadh < '".((int) $date_select + 1)."-01-01 00:00:00'";
|
||||
}
|
||||
@@ -403,6 +403,9 @@ while ($i < min($num, $limit)) {
|
||||
$adherent->statut = $obj->statut;
|
||||
$adherent->login = $obj->login;
|
||||
$adherent->photo = $obj->photo;
|
||||
$adherent->gender = $obj->gender;
|
||||
$adherent->morphy = $obj->morphy;
|
||||
$adherent->email = $obj->email;
|
||||
$adherent->typeid = $obj->type;
|
||||
|
||||
$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);
|
||||
|
||||
@@ -227,12 +227,12 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_creation))
|
||||
{
|
||||
if ($object->user_creation->id) print $object->user_creation->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_creation->id) print $object->user_creation->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_creation_id ? $object->user_creation_id : $object->user_creation);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
if ($usetable) print '</td></tr>';
|
||||
@@ -261,12 +261,12 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_modification))
|
||||
{
|
||||
if ($object->user_modification->id) print $object->user_modification->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_modification->id) print $object->user_modification->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_modification_id ? $object->user_modification_id : $object->user_modification);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
if ($usetable) print '</td></tr>';
|
||||
@@ -295,12 +295,12 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_validation))
|
||||
{
|
||||
if ($object->user_validation->id) print $object->user_validation->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_validation->id) print $object->user_validation->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_validation_id ? $object->user_validation_id : $object->user_validation);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
if ($usetable) print '</td></tr>';
|
||||
@@ -329,12 +329,12 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_approve))
|
||||
{
|
||||
if ($object->user_approve->id) print $object->user_approve->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_approve->id) print $object->user_approve->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_approve_id ? $object->user_approve_id : $object->user_approve);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
if ($usetable) print '</td></tr>';
|
||||
@@ -363,7 +363,7 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_approve_id2);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
if ($usetable) print '</td></tr>';
|
||||
else print '<br>';
|
||||
@@ -392,12 +392,12 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_closing))
|
||||
{
|
||||
if ($object->user_closing->id) print $object->user_closing->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_closing->id) print $object->user_closing->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
$userstatic->fetch($object->user_closing);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($userstatic->id) print $userstatic->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
}
|
||||
if ($usetable) print '</td></tr>';
|
||||
@@ -427,7 +427,7 @@ function dol_print_object_info($object, $usetable = 0)
|
||||
else print ': ';
|
||||
if (is_object($object->user_rappro))
|
||||
{
|
||||
if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(1, '', 0, 0, 0);
|
||||
if ($object->user_rappro->id) print $object->user_rappro->getNomUrl(-1, '', 0, 0, 0);
|
||||
else print $langs->trans("Unknown");
|
||||
} else {
|
||||
$userstatic = new User($db);
|
||||
|
||||
@@ -81,23 +81,20 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
$text .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
|
||||
$desc = "(UserLogged,".$object->login.")";
|
||||
$desc .= (empty($object->trigger_mesg) ? '' : ' - '.$object->trigger_mesg);
|
||||
}
|
||||
if ($action == 'USER_LOGIN_FAILED') {
|
||||
} elseif ($action == 'USER_LOGIN_FAILED') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $object->trigger_mesg; // Message direct
|
||||
$desc = $object->trigger_mesg; // Message direct
|
||||
}
|
||||
if ($action == 'USER_LOGOUT') {
|
||||
} elseif ($action == 'USER_LOGOUT') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = "(UserLogoff,".$object->login.")";
|
||||
$desc = "(UserLogoff,".$object->login.")";
|
||||
}
|
||||
if ($action == 'USER_CREATE') {
|
||||
} elseif ($action == 'USER_CREATE') {
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
|
||||
@@ -136,10 +133,8 @@ class InterfaceLogevents extends DolibarrTriggers
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
$text = $langs->transnoentities("UserDeleted", $object->login);
|
||||
$desc = $langs->transnoentities("UserDeleted", $object->login);
|
||||
}
|
||||
|
||||
// Groupes
|
||||
elseif ($action == 'USERGROUP_CREATE') {
|
||||
} elseif ($action == 'USERGROUP_CREATE') {
|
||||
// Groups
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
$langs->load("users");
|
||||
// Initialisation donnees (date,duree,texte,desc)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017-2019 Frédéric France <frederic.france@netlogic.fr>
|
||||
/* Copyright (C) 2017-2020 Frédéric France <frederic.france@netlogic.fr>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -39,11 +39,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
|
||||
*/
|
||||
class InterfaceZapierTriggers extends DolibarrTriggers
|
||||
{
|
||||
/**
|
||||
* @var DoliDB Database handler
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -888,6 +888,20 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Modal terminal Credit Note -->
|
||||
<div id="ModalCreditNote" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<span class="close" href="#" onclick="document.getElementById('ModalCreditNote').style.display = 'none';">×</span>
|
||||
<h3><?php print $langs->trans("invoiceAvoirWithLines"); ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<button type="button" class="block" onclick="CreditNote(); document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("Yes"); ?></button>
|
||||
<button type="button" class="block" onclick="document.getElementById('ModalCreditNote').style.display = 'none';"><?php print $langs->trans("No"); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row1<?php if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) print 'withhead'; ?>">
|
||||
|
||||
<div id="poslines" class="div1">
|
||||
|
||||
@@ -271,6 +271,154 @@ if ($action == 'valid' && $user->rights->facture->creer)
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'creditnote')
|
||||
{
|
||||
$creditnote = new Facture($db);
|
||||
$creditnote->socid = $invoice->socid;
|
||||
$creditnote->date = dol_now();
|
||||
$creditnote->type = Facture::TYPE_CREDIT_NOTE;
|
||||
$creditnote->fk_facture_source = $placeid;
|
||||
$creditnote->remise_absolue = $invoice->remise_absolue;
|
||||
$creditnote->remise_percent = $invoice->remise_percent;
|
||||
$creditnote->create($user);
|
||||
|
||||
foreach ($invoice->lines as $line)
|
||||
{
|
||||
// Extrafields
|
||||
if (method_exists($line, 'fetch_optionals')) {
|
||||
// load extrafields
|
||||
$line->fetch_optionals();
|
||||
}
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) {
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
if ($invoice->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; // 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($invoice->tab_previous_situation_invoice))
|
||||
{
|
||||
// search the last standard invoice in cycle and the possible credit note between this last and invoice
|
||||
// TODO Move this out of loop of $invoice->lines
|
||||
$tab_jumped_credit_notes = array();
|
||||
$lineIndex = count($invoice->tab_previous_situation_invoice) - 1;
|
||||
$searchPreviousInvoice = true;
|
||||
while ($searchPreviousInvoice)
|
||||
{
|
||||
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_SITUATION || $lineIndex < 1)
|
||||
{
|
||||
$searchPreviousInvoice = false; // find, exit;
|
||||
break;
|
||||
} else {
|
||||
if ($invoice->tab_previous_situation_invoice[$lineIndex]->type == Facture::TYPE_CREDIT_NOTE) {
|
||||
$tab_jumped_credit_notes[$lineIndex] = $invoice->tab_previous_situation_invoice[$lineIndex]->id;
|
||||
}
|
||||
$lineIndex--; // go to previous invoice in cycle
|
||||
}
|
||||
}
|
||||
|
||||
$maxPrevSituationPercent = 0;
|
||||
foreach ($invoice->tab_previous_situation_invoice[$lineIndex]->lines as $prevLine)
|
||||
{
|
||||
if ($prevLine->id == $source_fk_prev_id)
|
||||
{
|
||||
$maxPrevSituationPercent = max($maxPrevSituationPercent, $prevLine->situation_percent);
|
||||
|
||||
//$line->subprice = $line->subprice - $prevLine->subprice;
|
||||
$line->total_ht = $line->total_ht - $prevLine->total_ht;
|
||||
$line->total_tva = $line->total_tva - $prevLine->total_tva;
|
||||
$line->total_ttc = $line->total_ttc - $prevLine->total_ttc;
|
||||
$line->total_localtax1 = $line->total_localtax1 - $prevLine->total_localtax1;
|
||||
$line->total_localtax2 = $line->total_localtax2 - $prevLine->total_localtax2;
|
||||
|
||||
$line->multicurrency_subprice = $line->multicurrency_subprice - $prevLine->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = $line->multicurrency_total_ht - $prevLine->multicurrency_total_ht;
|
||||
$line->multicurrency_total_tva = $line->multicurrency_total_tva - $prevLine->multicurrency_total_tva;
|
||||
$line->multicurrency_total_ttc = $line->multicurrency_total_ttc - $prevLine->multicurrency_total_ttc;
|
||||
}
|
||||
}
|
||||
|
||||
// prorata
|
||||
$line->situation_percent = $maxPrevSituationPercent - $line->situation_percent;
|
||||
|
||||
//print 'New line based on invoice id '.$invoice->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 ($invoice->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 '.$invoice->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>';
|
||||
}
|
||||
}
|
||||
|
||||
$line->fk_facture = $creditnote->id;
|
||||
$line->fk_parent_line = $fk_parent_line;
|
||||
|
||||
$line->subprice = -$line->subprice; // invert price for object
|
||||
$line->pa_ht = $line->pa_ht; // we choosed to have buy/cost price always positive, so no revert of sign here
|
||||
$line->total_ht = -$line->total_ht;
|
||||
$line->total_tva = -$line->total_tva;
|
||||
$line->total_ttc = -$line->total_ttc;
|
||||
$line->total_localtax1 = -$line->total_localtax1;
|
||||
$line->total_localtax2 = -$line->total_localtax2;
|
||||
|
||||
$line->multicurrency_subprice = -$line->multicurrency_subprice;
|
||||
$line->multicurrency_total_ht = -$line->multicurrency_total_ht;
|
||||
$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
|
||||
|
||||
$creditnote->lines[] = $line; // insert new line in current object
|
||||
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $line->product_type == 9) {
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
$creditnote->update_price(1);
|
||||
|
||||
$constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"];
|
||||
if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") {
|
||||
$savconst = $conf->global->STOCK_CALCULATE_ON_BILL;
|
||||
$conf->global->STOCK_CALCULATE_ON_BILL = 1;
|
||||
$constantforkey = 'CASHDESK_ID_WAREHOUSE'.$_SESSION["takeposterminal"];
|
||||
dol_syslog("Validate invoice with stock change into warehouse defined into constant ".$constantforkey." = ".$conf->global->$constantforkey);
|
||||
$batch_rule = 0;
|
||||
if (!empty($conf->productbatch->enabled) && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/productbatch.class.php';
|
||||
$batch_rule = Productbatch::BATCH_RULE_SELLBY_EATBY_DATES_FIRST;
|
||||
}
|
||||
$res = $creditnote->validate($user, '', $conf->global->$constantforkey, 0, $batch_rule);
|
||||
$conf->global->STOCK_CALCULATE_ON_BILL = $savconst;
|
||||
} else {
|
||||
$res = $creditnote->validate($user);
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'history')
|
||||
{
|
||||
$placeid = (int) GETPOST('placeid', 'int');
|
||||
@@ -785,6 +933,11 @@ function DolibarrTakeposPrinting(id) {
|
||||
});
|
||||
}
|
||||
|
||||
function CreditNote() {
|
||||
$("#poslines").load("invoice.php?action=creditnote&invoiceid="+placeid, function() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$( document ).ready(function() {
|
||||
console.log("Set customer info and sales in header");
|
||||
@@ -1162,6 +1315,10 @@ if ($placeid > 0)
|
||||
|
||||
print '</table>';
|
||||
|
||||
if ($action == "valid" || $action == "history"){
|
||||
print '<button id="buttonprint" type="button" onclick="ModalBox(\'ModalCreditNote\')">'.$langs->trans('CreateCreditNote').'</button>';
|
||||
}
|
||||
|
||||
|
||||
if ($action == "search")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user