Merge branch '12.0' of git@github.com:Dolibarr/dolibarr.git into develop
Conflicts: htdocs/compta/prelevement/card.php htdocs/compta/prelevement/line.php htdocs/core/class/commonobject.class.php htdocs/core/lib/functions2.lib.php htdocs/core/tpl/card_presend.tpl.php htdocs/expensereport/class/expensereport.class.php htdocs/fourn/class/fournisseur.commande.class.php
This commit is contained in:
commit
0616b9bc9b
@ -104,12 +104,7 @@ $arrayAvailableType = array(
|
||||
Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation"),
|
||||
Facture::TYPE_STANDARD.'+'.Facture::TYPE_SITUATION => $langs->trans("InvoiceSituation").' + '.$langs->trans("InvoiceStandard"),
|
||||
);
|
||||
$selected = array();
|
||||
$implodeglue = '+';
|
||||
if (!empty($conf->global->{$confkey}) && !is_array($conf->global->{$confkey})) {
|
||||
$selected = explode('+', $conf->global->{$confkey});
|
||||
}
|
||||
|
||||
$selected = $conf->global->$confkey;
|
||||
$curentInput = (empty($inputCount) ? 1 : ($inputCount + 1));
|
||||
$formSelectInvoiceType = $form->selectarray('value'.$curentInput, $arrayAvailableType, $selected, 1);
|
||||
_printInputFormPart($confkey, $langs->trans('AllowedInvoiceForRetainedWarranty'), '', array(), $formSelectInvoiceType);
|
||||
|
||||
@ -3382,7 +3382,7 @@ if ($action == 'create')
|
||||
}
|
||||
});
|
||||
|
||||
$("[name=\'type\']").trigger("change");
|
||||
$("[name=\'type\']:checked").trigger("change");
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ if ($id > 0 || $ref)
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
|
||||
$acc = new Account($db);
|
||||
$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||
$result = $acc->fetch(($object->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT));
|
||||
|
||||
print '<tr><td class="titlefield">';
|
||||
$labelofbankfield = "BankToReceiveWithdraw";
|
||||
@ -404,7 +404,7 @@ if ($id > 0 || $ref)
|
||||
print "<td>";
|
||||
print $ligne->LibStatut($obj->statut, 2);
|
||||
print " ";
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'&type='.$object->type.'">';
|
||||
print sprintf("%06s", $obj->rowid);
|
||||
print '</a></td>';
|
||||
|
||||
@ -428,7 +428,7 @@ if ($id > 0 || $ref)
|
||||
if ($user->rights->prelevement->bons->credit)
|
||||
{
|
||||
//print '<a class="butActionDelete" href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
print '<a href="line.php?action=rejet&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
print '<a href="line.php?action=rejet&type='.$object->type.'&id='.$obj->rowid.'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
} else {
|
||||
//print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ class BonPrelevement extends CommonObject
|
||||
$message = $langs->trans("InfoCreditMessage", $this->ref, dol_print_date($date, 'dayhour'));
|
||||
|
||||
//Add payment of withdrawal into bank
|
||||
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
|
||||
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||
$facs = array();
|
||||
$amounts = array();
|
||||
$amountsperthirdparty = array();
|
||||
@ -1699,7 +1699,7 @@ class BonPrelevement extends CommonObject
|
||||
fputs($this->file, ' <Id>'.$CrLf);
|
||||
fputs($this->file, ' <PrvtId>'.$CrLf);
|
||||
fputs($this->file, ' <Othr>'.$CrLf);
|
||||
fputs($this->file, ' <Id>'.$conf->global->PRELEVEMENT_ICS.'</Id>'.$CrLf);
|
||||
fputs($this->file, ' <Id>'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.'</Id>'.$CrLf);
|
||||
fputs($this->file, ' </Othr>'.$CrLf);
|
||||
fputs($this->file, ' </PrvtId>'.$CrLf);
|
||||
fputs($this->file, ' </Id>'.$CrLf);
|
||||
@ -2114,7 +2114,8 @@ class BonPrelevement extends CommonObject
|
||||
$dateTime_YMDHMS = dol_print_date($ladate, '%Y-%m-%dT%H:%M:%S');
|
||||
|
||||
// Get data of bank account
|
||||
$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT;
|
||||
//$id = $configuration->global->PRELEVEMENT_ID_BANKACCOUNT;
|
||||
$id = ($type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||
$account = new Account($this->db);
|
||||
if ($account->fetch($id) > 0)
|
||||
{
|
||||
|
||||
@ -39,6 +39,8 @@ class RejetPrelevement
|
||||
* @var DoliDB Database handler.
|
||||
*/
|
||||
public $db;
|
||||
|
||||
public $type; //prelevement or bank transfer
|
||||
|
||||
|
||||
/**
|
||||
@ -47,12 +49,13 @@ class RejetPrelevement
|
||||
* @param DoliDb $db Database handler
|
||||
* @param User $user Objet user
|
||||
*/
|
||||
public function __construct($db, $user)
|
||||
public function __construct($db, $user, $type)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$this->db = $db;
|
||||
$this->user = $user;
|
||||
$this->type = $type;
|
||||
|
||||
$this->motifs = array();
|
||||
$this->facturer = array();
|
||||
@ -92,7 +95,7 @@ class RejetPrelevement
|
||||
$now = dol_now();
|
||||
|
||||
dol_syslog("RejetPrelevement::Create id $id");
|
||||
$bankaccount = $conf->global->PRELEVEMENT_ID_BANKACCOUNT;
|
||||
$bankaccount = ($this->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
|
||||
$facs = $this->getListInvoices(1);
|
||||
|
||||
$this->db->begin();
|
||||
@ -137,11 +140,19 @@ class RejetPrelevement
|
||||
$num = count($facs);
|
||||
for ($i = 0; $i < $num; $i++)
|
||||
{
|
||||
$fac = new Facture($this->db);
|
||||
if($this->type == 'bank-transfer'){
|
||||
$fac = new FactureFournisseur($this->db);
|
||||
$pai = new PaiementFourn($this->db);
|
||||
}
|
||||
else{
|
||||
$fac = new Facture($this->db);
|
||||
$pai = new Paiement($this->db);
|
||||
}
|
||||
|
||||
$fac->fetch($facs[$i][0]);
|
||||
|
||||
// Make a negative payment
|
||||
$pai = new Paiement($this->db);
|
||||
//$pai = new Paiement($this->db);
|
||||
|
||||
$pai->amounts = array();
|
||||
|
||||
@ -150,7 +161,7 @@ class RejetPrelevement
|
||||
* PHP installs sends only the part integer negative
|
||||
*/
|
||||
|
||||
$pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * -1);
|
||||
$pai->amounts[$facs[$i][0]] = price2num($facs[$i][1] * ($this->type == 'bank-transfer' ? 1: -1));
|
||||
$pai->datepaye = $date_rejet;
|
||||
$pai->paiementid = 3; // type of payment: withdrawal
|
||||
$pai->num_payment = $fac->ref;
|
||||
@ -211,7 +222,7 @@ class RejetPrelevement
|
||||
$sql = "SELECT fk_user_demande";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd";
|
||||
$sql .= " WHERE pfd.fk_prelevement_bons = ".$this->bon_id;
|
||||
$sql .= " AND pfd.fk_facture = ".$fac->id;
|
||||
$sql .= " AND pfd.fk_facture".($this->type == 'bank-transfer' ? '_fourn=': '=').$fac->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -282,7 +293,10 @@ class RejetPrelevement
|
||||
//Returns all invoices of a withdrawal
|
||||
$sql = "SELECT f.rowid as facid, pl.amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";
|
||||
//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";
|
||||
if ($this->type == 'bank-transfer') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON (pf.fk_facture_fourn = f.rowid)";
|
||||
else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as f ON (pf.fk_facture = f.rowid)";
|
||||
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_lignes as pl ON (pf.fk_prelevement_lignes = pl.rowid)";
|
||||
$sql .= " WHERE pf.fk_prelevement_lignes = ".$this->id;
|
||||
$sql .= " AND f.entity IN (".getEntity('invoice').")";
|
||||
|
||||
@ -95,18 +95,18 @@ if ($action == 'confirm_rejet')
|
||||
if ($lipre->fetch($id) == 0)
|
||||
|
||||
{
|
||||
$rej = new RejetPrelevement($db, $user);
|
||||
$rej = new RejetPrelevement($db, $user,$type);
|
||||
|
||||
$rej->create($user, $id, GETPOST('motif', 'alpha'), $daterej, $lipre->bon_rowid, GETPOST('facturer', 'int'));
|
||||
|
||||
header("Location: line.php?id=".$id);
|
||||
header("Location: line.php?id=".$id.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$action = "rejet";
|
||||
}
|
||||
} else {
|
||||
header("Location: line.php?id=".$id);
|
||||
header("Location: line.php?id=".$id.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -128,7 +128,7 @@ llxHeader('', $title);
|
||||
$head = array();
|
||||
|
||||
$h = 0;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id;
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$id.'&type='.$type;
|
||||
$head[$h][1] = $title;
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
@ -191,11 +191,12 @@ if ($id)
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($lipre->socid);
|
||||
|
||||
$rej = new RejetPrelevement($db, $user);
|
||||
$rej = new RejetPrelevement($db, $user, $type);
|
||||
|
||||
print '<form name="confirm_rejet" method="post" action="line.php?id='.$id.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="confirm_rejet">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
print '<table class="noborder centpercent">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
@ -246,7 +247,7 @@ if ($id)
|
||||
if ($lipre->statut == 2) {
|
||||
if ($user->rights->prelevement->bons->credit)
|
||||
{
|
||||
print '<a class="butActionDelete" href="line.php?action=rejet&id='.$lipre->id.'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
print '<a class="butActionDelete" href="line.php?action=rejet&type='.$type.'&id='.$lipre->id.'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotAllowed").'">'.$langs->trans("StandingOrderReject").'</a>';
|
||||
}
|
||||
|
||||
@ -6888,6 +6888,8 @@ abstract class CommonObject
|
||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||
var infos = parent.split(":");
|
||||
var parent_list = infos[0];
|
||||
showOptions(child_list, parent_list);
|
||||
|
||||
$("select[name=\""+parent_list+"\"]").change(function() {
|
||||
showOptions(child_list, parent_list);
|
||||
});
|
||||
|
||||
@ -1842,7 +1842,14 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
|
||||
$classname = 'CommandeFournisseur';
|
||||
$classpath = 'fourn/class';
|
||||
$module = 'fournisseur';
|
||||
} elseif ($objecttype == 'stock') {
|
||||
}
|
||||
elseif ($objecttype == 'supplier_proposal') {
|
||||
$classfile = 'supplier_proposal';
|
||||
$classname = 'SupplierProposal';
|
||||
$classpath = 'supplier_proposal/class';
|
||||
$module = 'supplier_proposal';
|
||||
}
|
||||
elseif ($objecttype == 'stock') {
|
||||
$classpath = 'product/stock/class';
|
||||
$classfile = 'entrepot';
|
||||
$classname = 'Entrepot';
|
||||
|
||||
@ -167,6 +167,9 @@ if ($action == 'presend')
|
||||
} elseif ($object->element == 'user' || $object->element == 'member') {
|
||||
$liste['thirdparty'] = $object->getFullName($outputlangs)." <".$object->email.">";
|
||||
} else {
|
||||
if (!empty($object->socid) && $object->socid > 0 && !is_object($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
if (is_object($object->thirdparty))
|
||||
{
|
||||
foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key => $value) {
|
||||
|
||||
@ -226,6 +226,9 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
|
||||
var parent = $(this).find("option[parent]:first").attr("parent");
|
||||
var infos = parent.split(":");
|
||||
var parent_list = infos[0];
|
||||
showOptions(child_list, parent_list);
|
||||
|
||||
/* Activate the handler to call showOptions on each future change */
|
||||
$("select[name=\""+parent_list+"\"]").change(function() {
|
||||
showOptions(child_list, parent_list);
|
||||
});
|
||||
|
||||
@ -693,7 +693,7 @@ if (!empty($usemargins) && $user->rights->margins->creer)
|
||||
$("#buying_price").val("").show();
|
||||
|
||||
/* Call post to load content of combo list fournprice_predef */
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val() }, function(data) {
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php?bestpricefirst=1', { 'idprod': $(this).val(), 'token': '<?php echo newToken(); ?>' }, function(data) {
|
||||
if (data && data.length > 0)
|
||||
{
|
||||
var options = ''; var defaultkey = ''; var defaultprice = ''; var bestpricefound = 0;
|
||||
|
||||
@ -434,7 +434,7 @@ jQuery(document).ready(function()
|
||||
});
|
||||
|
||||
/* Init field buying_price and fournprice */
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product ? $line->fk_product : 0; ?>}, function(data) {
|
||||
$.post('<?php echo DOL_URL_ROOT; ?>/fourn/ajax/getSupplierPrices.php', {'idprod': <?php echo $line->fk_product ? $line->fk_product : 0; ?>, 'token': '<?php echo newToken(); ?>'}, function(data) {
|
||||
if (data && data.length > 0) {
|
||||
var options = '';
|
||||
var trouve=false;
|
||||
|
||||
@ -299,6 +299,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers
|
||||
//Build array of quantity ordered by product
|
||||
if (is_array($order->lines) && count($order->lines) > 0) {
|
||||
foreach ($order->lines as $orderline) {
|
||||
if (empty($conf->global->STOCK_SUPPORTS_SERVICES) && $orderline->product_type > 0) continue;
|
||||
$qtyordred[$orderline->fk_product] += $orderline->qty;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2185,20 +2185,22 @@ class ExpenseReport extends CommonObject
|
||||
|
||||
$langs->load("trips");
|
||||
|
||||
if (!dol_strlen($modele)) {
|
||||
$modele = 'standard';
|
||||
if (!dol_strlen($modele)) {
|
||||
if ($this->modelpdf) {
|
||||
$modele = $this->modelpdf;
|
||||
} elseif (!empty($conf->global->EXPENSEREPORT_ADDON_PDF)) {
|
||||
$modele = $conf->global->EXPENSEREPORT_ADDON_PDF;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($modele)) {
|
||||
$modelpath = "core/modules/expensereport/doc/";
|
||||
|
||||
if ($this->modelpdf) {
|
||||
$modele = $this->modelpdf;
|
||||
} elseif (!empty($conf->global->EXPENSEREPORT_ADDON_PDF)) {
|
||||
$modele = $conf->global->EXPENSEREPORT_ADDON_PDF;
|
||||
}
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$modelpath = "core/modules/expensereport/doc/";
|
||||
|
||||
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List of types
|
||||
|
||||
@ -247,8 +247,8 @@ if ($action == 'create' || empty($action))
|
||||
|
||||
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
$datepaid = dol_mktime(12, 0, 0, GETPOST("remonth", 'int'), GETPOST("reday", 'int'), GETPOST("reyear", 'int'));
|
||||
$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaid) : 0;
|
||||
print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
|
||||
$datepayment = ($datepaid == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE) ?-1 : '') : $datepaid);
|
||||
print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
|
||||
@ -2210,10 +2210,9 @@ class CommandeFournisseur extends CommonOrder
|
||||
|
||||
// TODO LDR01 Add a control test to accept only if ALL predefined products are received (same qty).
|
||||
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->begin();
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande_fournisseur";
|
||||
$sql .= " SET fk_statut = ".$statut;
|
||||
@ -2224,17 +2223,17 @@ class CommandeFournisseur extends CommonOrder
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$result = 0;
|
||||
$result = 1;
|
||||
$old_statut = $this->statut;
|
||||
$this->statut = $statut;
|
||||
$this->actionmsg2 = $comment;
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
// Call trigger
|
||||
$result_trigger = $this->call_trigger('ORDER_SUPPLIER_RECEIVE', $user);
|
||||
if ($result_trigger < 0) $error++;
|
||||
// End call triggers
|
||||
|
||||
if (!$error)
|
||||
if (empty($error))
|
||||
{
|
||||
$this->db->commit();
|
||||
} else {
|
||||
|
||||
@ -158,6 +158,7 @@ $head = marges_prepare_head($user);
|
||||
$picto = 'margin';
|
||||
|
||||
print '<form method="post" name="sel" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
dol_fiche_head($head, $langs->trans('checkMargins'), $title, 0, $picto);
|
||||
|
||||
|
||||
@ -351,11 +351,12 @@ if ($id > 0 || !empty($ref))
|
||||
$fourn_remise_percent = (!empty($product_fourn->fourn_remise_percent) ? $product_fourn->fourn_remise_percent : 0);
|
||||
$fourn_remise = (!empty($product_fourn->fourn_remise) ? $product_fourn->fourn_remise : 0);
|
||||
|
||||
$totalline = price2num($value['nb'] * ($fourn_unitprice * (1 - $fourn_remise_percent / 100) - $fourn_remise), 'MT');
|
||||
$unitline = price2num(($fourn_unitprice * (1 - ($fourn_remise_percent / 100)) - $fourn_remise), 'MU');
|
||||
$totalline = price2num($value['nb'] * ($fourn_unitprice * (1 - ($fourn_remise_percent / 100)) - $fourn_remise), 'MT');
|
||||
$total += $totalline;
|
||||
|
||||
print '<td class="right">';
|
||||
print ($notdefined ? '' : ($value['nb'] > 1 ? $value['nb'].'x' : '').price($fourn_unitprice, '', '', 0, 0, -1, $conf->currency));
|
||||
print ($notdefined ? '' : ($value['nb'] > 1 ? $value['nb'].'x' : '').price($unitline, '', '', 0, 0, -1, $conf->currency));
|
||||
print '</td>';
|
||||
|
||||
// Best selling price
|
||||
|
||||
Loading…
Reference in New Issue
Block a user