Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into
develop
This commit is contained in:
commit
623f15711d
@ -2560,9 +2560,10 @@ if (empty($reshook)) {
|
|||||||
setEventMessages($mesg, null, 'warnings');
|
setEventMessages($mesg, null, 'warnings');
|
||||||
$result = -1;
|
$result = -1;
|
||||||
} else {
|
} else {
|
||||||
$object->update_percent($line, GETPOST('all_progress'));
|
$object->update_percent($line, GETPOST('all_progress'), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$object->update_price(1);
|
||||||
}
|
}
|
||||||
} elseif ($action == 'updateline' && $usercancreate && !$cancel) {
|
} elseif ($action == 'updateline' && $usercancreate && !$cancel) {
|
||||||
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page
|
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id); // To show again edited page
|
||||||
|
|||||||
@ -3727,9 +3727,10 @@ class Facture extends CommonInvoice
|
|||||||
*
|
*
|
||||||
* @param FactureLigne $line Invoice line
|
* @param FactureLigne $line Invoice line
|
||||||
* @param int $percent Percentage
|
* @param int $percent Percentage
|
||||||
|
* @param boolean $update_price Update object price
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function update_percent($line, $percent)
|
public function update_percent($line, $percent, $update_price = true)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $mysoc, $user;
|
global $mysoc, $user;
|
||||||
@ -3756,8 +3757,12 @@ class Facture extends CommonInvoice
|
|||||||
$line->multicurrency_total_tva = $tabprice[17];
|
$line->multicurrency_total_tva = $tabprice[17];
|
||||||
$line->multicurrency_total_ttc = $tabprice[18];
|
$line->multicurrency_total_ttc = $tabprice[18];
|
||||||
$line->update($user);
|
$line->update($user);
|
||||||
|
|
||||||
|
// sometimes it is better to not update price for each line, ie when updating situation on all lines
|
||||||
|
if ($update_price) {
|
||||||
$this->update_price(1);
|
$this->update_price(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete line in database
|
* Delete line in database
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
*/
|
*/
|
||||||
abstract class CommonObject
|
abstract class CommonObject
|
||||||
{
|
{
|
||||||
|
const TRIGGER_PREFIX = ''; // to be overriden in child class implementations, i.e. 'BILL', 'TASK', 'PROPAL', etc.
|
||||||
/**
|
/**
|
||||||
* @var DoliDb Database handler (result of a new DoliDB)
|
* @var DoliDb Database handler (result of a new DoliDB)
|
||||||
*/
|
*/
|
||||||
@ -5618,7 +5619,10 @@ abstract class CommonObject
|
|||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
if (!empty(self::TRIGGER_PREFIX) && strpos($triggerName, self::TRIGGER_PREFIX . '_') !== 0) {
|
||||||
|
dol_print_error('', 'The trigger "' . $triggerName . '" does not start with "' . self::TRIGGER_PREFIX . '_" as required.');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers.
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
|
||||||
$langs = new Translate('', $conf);
|
$langs = new Translate('', $conf);
|
||||||
|
|||||||
@ -76,7 +76,7 @@ $lineid = GETPOST('lineid', 'int');
|
|||||||
$projectid = GETPOST('projectid', 'int');
|
$projectid = GETPOST('projectid', 'int');
|
||||||
$origin = GETPOST('origin', 'alpha');
|
$origin = GETPOST('origin', 'alpha');
|
||||||
$originid = GETPOST('originid', 'int');
|
$originid = GETPOST('originid', 'int');
|
||||||
$fac_rec = GETPOST('fac_rec', 'int');
|
$fac_recid = GETPOST('fac_rec', 'int');
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
||||||
@ -882,10 +882,8 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} elseif ($fac_recid > 0 && (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT)) {
|
||||||
|
|
||||||
// Standard invoice or Deposit invoice, created from a Predefined template invoice
|
// Standard invoice or Deposit invoice, created from a Predefined template invoice
|
||||||
if ((GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) {
|
|
||||||
if (empty($dateinvoice)) {
|
if (empty($dateinvoice)) {
|
||||||
$error++;
|
$error++;
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||||
@ -903,7 +901,7 @@ if (empty($reshook)) {
|
|||||||
$object->date = $dateinvoice;
|
$object->date = $dateinvoice;
|
||||||
$object->note_public = trim(GETPOST('note_public', 'restricthtml'));
|
$object->note_public = trim(GETPOST('note_public', 'restricthtml'));
|
||||||
$object->note_private = trim(GETPOST('note_private', 'restricthtml'));
|
$object->note_private = trim(GETPOST('note_private', 'restricthtml'));
|
||||||
$object->ref_client = GETPOST('ref_client');
|
$object->ref_supplier = GETPOST('ref_supplier', 'nohtml');
|
||||||
$object->model_pdf = GETPOST('model');
|
$object->model_pdf = GETPOST('model');
|
||||||
$object->fk_project = GETPOST('projectid', 'int');
|
$object->fk_project = GETPOST('projectid', 'int');
|
||||||
$object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id'));
|
$object->cond_reglement_id = (GETPOST('type') == 3 ? 1 : GETPOST('cond_reglement_id'));
|
||||||
@ -918,7 +916,7 @@ if (empty($reshook)) {
|
|||||||
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
$object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int');
|
||||||
|
|
||||||
// Source facture
|
// Source facture
|
||||||
$object->fac_rec = GETPOST('fac_rec', 'int');
|
$object->fac_rec = $fac_recid;
|
||||||
$fac_rec = new FactureFournisseurRec($db);
|
$fac_rec = new FactureFournisseurRec($db);
|
||||||
$fac_rec->fetch($object->fac_rec);
|
$fac_rec->fetch($object->fac_rec);
|
||||||
$fac_rec->fetch_lines();
|
$fac_rec->fetch_lines();
|
||||||
@ -926,10 +924,8 @@ if (empty($reshook)) {
|
|||||||
|
|
||||||
$id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines
|
$id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines
|
||||||
}
|
}
|
||||||
}
|
} elseif ($fac_recid <= 0 && (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT)) {
|
||||||
|
|
||||||
// Standard invoice or Deposit invoice, not from a Predefined template invoice
|
// Standard invoice or Deposit invoice, not from a Predefined template invoice
|
||||||
if (GETPOST('type') == FactureFournisseur::TYPE_STANDARD || GETPOST('type') == FactureFournisseur::TYPE_DEPOSIT && GETPOST('fac_rec') <= 0) {
|
|
||||||
if (GETPOST('socid', 'int') < 1) {
|
if (GETPOST('socid', 'int') < 1) {
|
||||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors');
|
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentities('Supplier')), null, 'errors');
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
@ -2024,15 +2020,15 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
$exampletemplateinvoice = new FactureFournisseurRec($db);
|
$exampletemplateinvoice = new FactureFournisseurRec($db);
|
||||||
$invoice_predefined = new FactureFournisseurRec($db);
|
$invoice_predefined = new FactureFournisseurRec($db);
|
||||||
if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) {
|
if (empty($origin) && empty($originid) && $fac_recid > 0) {
|
||||||
$invoice_predefined->fetch(GETPOST('fac_rec', 'int'));
|
$invoice_predefined->fetch($fac_recid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third party
|
// Third party
|
||||||
print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>';
|
print '<tr><td class="fieldrequired">'.$langs->trans('Supplier').'</td>';
|
||||||
print '<td>';
|
print '<td>';
|
||||||
|
|
||||||
if ($societe->id > 0 && (!GETPOST('fac_rec', 'int') || !empty($invoice_predefined->frequency))) {
|
if ($societe->id > 0 && ($fac_recid <= 0 || !empty($invoice_predefined->frequency))) {
|
||||||
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
$absolute_discount = $societe->getAvailableDiscounts('', '', 0, 1);
|
||||||
print $societe->getNomUrl(1, 'supplier');
|
print $societe->getNomUrl(1, 'supplier');
|
||||||
print '<input type="hidden" name="socid" value="'.$societe->id.'">';
|
print '<input type="hidden" name="socid" value="'.$societe->id.'">';
|
||||||
@ -2050,15 +2046,15 @@ if ($action == 'create') {
|
|||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
if (!GETPOST('fac_rec', 'int')) {
|
if ($fac_recid <= 0) {
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
|
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=0&fournisseur=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Overwrite some values if creation of invoice is from a predefined invoice
|
// Overwrite some values if creation of invoice is from a predefined invoice
|
||||||
if (empty($origin) && empty($originid) && GETPOST('fac_rec', 'int') > 0) {
|
if (empty($origin) && empty($originid) && $fac_recid > 0) {
|
||||||
$invoice_predefined->fetch(GETPOST('fac_rec', 'int'));
|
$invoice_predefined->fetch($fac_recid);
|
||||||
|
|
||||||
$dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later
|
$dateinvoice = $invoice_predefined->date_when; // To use next gen date by default later
|
||||||
if (empty($projectid)) {
|
if (empty($projectid)) {
|
||||||
@ -2088,15 +2084,15 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
if ($num > 0) {
|
if ($num > 0) {
|
||||||
print '<tr><td>'.$langs->trans('CreateFromRepeatableInvoice').'</td><td>';
|
print '<tr><td>'.$langs->trans('CreateFromRepeatableInvoice').'</td><td>';
|
||||||
//print '<input type="hidden" name="fac_rec" id="fac_rec" value="'.GETPOST('fac_rec', 'int').'">';
|
//print '<input type="hidden" name="fac_rec" id="fac_rec" value="'.$fac_recid.'">';
|
||||||
print '<select class="flat" id="fac_rec" name="fac_rec">'; // We may want to change the template to use
|
print '<select class="flat" id="fac_rec" name="fac_rec">'; // We may want to change the template to use
|
||||||
print '<option value="0" selected></option>';
|
print '<option value="0" selected></option>';
|
||||||
while ($i < $num) {
|
while ($i < $num) {
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
print '<option value="'.$objp->rowid.'"';
|
print '<option value="'.$objp->rowid.'"';
|
||||||
if (GETPOST('fac_rec', 'int') == $objp->rowid) {
|
if ($fac_recid == $objp->rowid) {
|
||||||
print ' selected';
|
print ' selected';
|
||||||
$exampletemplateinvoice->fetch(GETPOST('fac_rec', 'int'));
|
$exampletemplateinvoice->fetch($fac_recid);
|
||||||
}
|
}
|
||||||
print '>'.$objp->title.' ('.price($objp->total_ttc).' '.$langs->trans("TTC").')</option>';
|
print '>'.$objp->title.' ('.price($objp->total_ttc).' '.$langs->trans("TTC").')</option>';
|
||||||
$i++;
|
$i++;
|
||||||
@ -2408,7 +2404,7 @@ if ($action == 'create') {
|
|||||||
$langs->load('projects');
|
$langs->load('projects');
|
||||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||||
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
|
print img_picto('', 'project', 'class="pictofixedwidth"').$formproject->select_projects((empty($conf->global->PROJECT_CAN_ALWAYS_LINK_TO_ALL_SUPPLIERS) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
|
||||||
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id.($fac_rec ? '&fac_rec='.$fac_rec : '')).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
|
print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create&status=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create&socid='.$soc->id.($fac_recid > 0 ? '&fac_rec='.$fac_recid : '')).'"><span class="fa fa-plus-circle valignmiddle" title="'.$langs->trans("AddProject").'"></span></a>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2432,7 +2428,7 @@ if ($action == 'create') {
|
|||||||
|
|
||||||
// Help of substitution key
|
// Help of substitution key
|
||||||
$htmltext = '';
|
$htmltext = '';
|
||||||
if (GETPOST('fac_rec', 'int') > 0) {
|
if ($fac_recid > 0) {
|
||||||
$dateexample = $newdateinvoice ? $newdateinvoice : $dateinvoice;
|
$dateexample = $newdateinvoice ? $newdateinvoice : $dateinvoice;
|
||||||
if (empty($dateexample)) {
|
if (empty($dateexample)) {
|
||||||
$dateexample = dol_now();
|
$dateexample = dol_now();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user