Merge branch 'NEW/addline_with_position_choice' of github.com:atm-gauthier/dolibarr into NEW/addline_with_position_choice_develop

This commit is contained in:
Gauthier PC portable 024 2021-11-16 14:20:24 +01:00
commit 9d41c1390d
14 changed files with 61 additions and 10 deletions

View File

@ -80,6 +80,7 @@ $confirm = GETPOST('confirm', 'alpha');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -1143,7 +1144,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $price_base_type, $pu_ttc, $info_bits, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $date_start, $date_end, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$db->commit();

View File

@ -734,6 +734,10 @@ class Propal extends CommonObject
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la propale meme

View File

@ -81,6 +81,7 @@ $contactid = GETPOST('contactid', 'int');
$projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -935,7 +936,7 @@ if (empty($reshook)) {
setEventMessages($mesg, null, 'errors');
} else {
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, - 1, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $info_bits, 0, $price_base_type, $pu_ttc, $date_start, $date_end, $type, $rank, 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $fk_unit, '', 0, $pu_ht_devise);
if ($result > 0) {
$ret = $object->fetch($object->id); // Reload to get new records

View File

@ -1648,6 +1648,10 @@ class Commande extends CommonOrder
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la commande meme

View File

@ -92,6 +92,7 @@ $search_montant_ttc = GETPOST('search_montant_ttc', 'alpha');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
$fac_rec = GETPOST('fac_rec', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -2260,7 +2261,7 @@ if (empty($reshook)) {
}
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, - 1, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise);
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idprod, $remise_percent, $date_start, $date_end, 0, $info_bits, '', $price_base_type, $pu_ttc, $type, $rank, $special_code, '', 0, GETPOST('fk_parent_line'), $fournprice, $buyingprice, $label, $array_options, $_POST['progress'], '', $fk_unit, $pu_ht_devise);
if ($result > 0) {
// Define output language and generate document

View File

@ -3355,6 +3355,10 @@ class Facture extends CommonInvoice
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la facture meme

View File

@ -309,6 +309,18 @@ if ($nolinesbefore) {
echo '<input type="hidden" name="pbq" id="pbq" value="">';
echo '</span>';
}
if(!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
$tab = array(-1 => $langs->trans('AtTheEnd'));
if (!empty($object->lines)) {
$langs->load('admin');
foreach ($object->lines as $k => $v) {
$tab[$v->rang] = $langs->trans('OnLine') . '&nbsp;' . ($k + 1);
}
}
echo '<br>'.$langs->trans('Position').' : '.$form->selectarray('rank', $tab);
}
if (is_object($hookmanager) && empty($senderissupplier)) {
$parameters = array('fk_parent_line'=>GETPOST('fk_parent_line', 'int'));
$reshook = $hookmanager->executeHooks('formCreateProductOptions', $parameters, $object, $action);

View File

@ -1683,7 +1683,7 @@ class CommandeFournisseur extends CommonOrder
* @param int $origin_id Id of origin object
* @return int <=0 if KO, >0 if OK
*/
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = false, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0)
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $fk_prod_fourn_price = 0, $ref_supplier = '', $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $type = 0, $info_bits = 0, $notrigger = false, $date_start = null, $date_end = null, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $origin = '', $origin_id = 0, $rang = -1)
{
global $langs, $mysoc, $conf;
@ -1703,6 +1703,9 @@ class CommandeFournisseur extends CommonOrder
if (empty($txtva)) {
$txtva = 0;
}
if (empty($rang)) {
$rang = 0;
}
if (empty($txlocaltax1)) {
$txlocaltax1 = 0;
}
@ -1854,8 +1857,11 @@ class CommandeFournisseur extends CommonOrder
$localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
$localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$rangmax = $this->line_max();
$rang = $rangmax + 1;
if ($rang < 0)
{
$rangmax = $this->line_max();
$rang = $rangmax + 1;
}
// Insert line
$this->line = new CommandeFournisseurLigne($this->db);
@ -1917,6 +1923,10 @@ class CommandeFournisseur extends CommonOrder
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $rang; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la commande meme

View File

@ -2007,6 +2007,10 @@ class FactureFournisseur extends CommonInvoice
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($rang > 0 && $rang <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $rang; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la facture meme

View File

@ -77,6 +77,7 @@ $cancel = GETPOST('cancel', 'alpha');
$lineid = GETPOST('lineid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = (GETPOST('originid', 'int') ? GETPOST('originid', 'int') : GETPOST('origin_id', 'int')); // For backward compatibility
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
//PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -583,7 +584,8 @@ if (empty($reshook)) {
$productsupplier->fk_unit,
$pu_ht_devise,
'',
0
0,
$rank
);
}
if ($idprod == -99 || $idprod == 0) {

View File

@ -76,6 +76,7 @@ $projectid = GETPOST('projectid', 'int');
$origin = GETPOST('origin', 'alpha');
$originid = GETPOST('originid', 'int');
$fac_rec = GETPOST('fac_rec', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -1508,7 +1509,7 @@ if (empty($reshook)) {
$tva_npr,
$price_base_type,
$type,
-1,
$rank,
0,
$array_options,
$productsupplier->fk_unit,

View File

@ -1158,4 +1158,6 @@ Properties=Properties
hasBeenValidated=%s has been validated
ClientTZ=Client Time Zone (user)
NotClosedYet=Not yet closed
ClearSignature=Signature reset
ClearSignature=Signature reset
AtTheEnd=At the end
OnLine=On line

View File

@ -67,6 +67,7 @@ $confirm = GETPOST('confirm', 'alpha');
$projectid = GETPOST('projectid', 'int');
$lineid = GETPOST('lineid', 'int');
$contactid = GETPOST('contactid', 'int');
$rank = (GETPOST('rank', 'int') > 0) ? GETPOST('rank', 'int') : -1;
// PDF
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
@ -672,7 +673,7 @@ if (empty($reshook)) {
$pu_ttc,
$tva_npr,
$type,
-1,
$rank,
0,
GETPOST('fk_parent_line'),
$fournprice,

View File

@ -621,6 +621,10 @@ class SupplierProposal extends CommonObject
// Reorder if child line
if (!empty($fk_parent_line)) {
$this->line_order(true, 'DESC');
} elseif($ranktouse > 0 && $ranktouse <= count($this->lines)) { // Update all rank of all other lines
for ($ii = $ranktouse; $ii <= count($this->lines); $ii++) {
$this->updateRangOfLine($this->lines[$ii - 1]->id, $ii + 1);
}
}
// Mise a jour informations denormalisees au niveau de la propale meme