Merge branch '11.0' into 11.0_FIX_11858_do_not_allow_lines_to_overlap_infotot

This commit is contained in:
Florian Mortgat 2020-08-28 10:05:00 +02:00
commit 7ddf85cd33
52 changed files with 416 additions and 333 deletions

View File

@ -8,6 +8,7 @@ ALL:
Check "@CHANGE" Check "@CHANGE"
PrestaShopWebservice: PrestaShopWebservice:
--------------------- ---------------------
Replace Replace
@ -27,6 +28,19 @@ With
DEBUGBAR:
---------
Move
this.options = {
bodyMarginBottom: true,
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')),
};
few line lower in the
initialize: function() {
ESCPOS: ESCPOS:
------- -------
Replace Replace

View File

@ -254,6 +254,8 @@ if ($result) {
} else { } else {
$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60); $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
} }
// Load of url links to the line into llx_bank
$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
//var_dump($i); //var_dump($i);
@ -320,6 +322,7 @@ if ($result) {
$chargestatic->ref = $links[$key]['url_id']; $chargestatic->ref = $links[$key]['url_id'];
$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2); $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
$reg = array();
if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) { if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
if ($reg[1] == 'socialcontribution') if ($reg[1] == 'socialcontribution')
$reg[1] = 'SocialContribution'; $reg[1] = 'SocialContribution';
@ -331,11 +334,13 @@ if ($result) {
$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30); $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id; $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
// Retreive the accounting code of the social contribution of the payment from link of payment.
// Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
$sqlmid = 'SELECT cchgsoc.accountancy_code'; $sqlmid = 'SELECT cchgsoc.accountancy_code';
$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc"; $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
$sqlmid .= " INNER JOIN " . MAIN_DB_PREFIX . "bank_url as bkurl ON bkurl.url_id=paycharg.rowid"; $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'";
$sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid; $sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG); dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=" . $sqlmid, LOG_DEBUG);

View File

@ -41,9 +41,28 @@ $action = GETPOST('action', 'alpha');
/* /*
* Action * Action
*/ */
$reg = array();
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
{ {
$code=$reg[1]; $code=$reg[1];
// If constant is for a unique choice, delete other choices
if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
}
if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
}
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{ {
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
@ -114,7 +133,7 @@ print '<td class="right">';
if (! empty($conf->facture->enabled)) if (! empty($conf->facture->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_BILL'); print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL); print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
@ -134,7 +153,7 @@ print '<td class="right">';
if (! empty($conf->commande->enabled)) if (! empty($conf->commande->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER'); print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
@ -156,7 +175,7 @@ print '<td class="right">';
if (! empty($conf->expedition->enabled)) if (! empty($conf->expedition->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT'); print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
@ -176,7 +195,7 @@ print '<td class="right">';
if (! empty($conf->expedition->enabled)) if (! empty($conf->expedition->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE'); print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE); print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
@ -189,18 +208,12 @@ else
print "</td>\n</tr>\n"; print "</td>\n</tr>\n";
$found++; $found++;
/*if (! $found)
{
print '<tr class="oddeven">';
print '<td colspan="2">'.$langs->trans("NoModuleToManageStockDecrease").'</td>';
print "</tr>\n";
}*/
print '</table>'; print '</table>';
print '<br>'; print '<br>';
// Title rule for stock increase // Title rule for stock increase
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
@ -216,7 +229,7 @@ print '<td class="right">';
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL'); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
@ -237,7 +250,7 @@ print '<td class="right">';
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER'); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
@ -257,7 +270,7 @@ if (!empty($conf->reception->enabled))
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION'); print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
@ -272,7 +285,7 @@ if (!empty($conf->reception->enabled))
print '<td class="right">'; print '<td class="right">';
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE'); print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE); print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
@ -288,7 +301,7 @@ else
if (! empty($conf->fournisseur->enabled)) if (! empty($conf->fournisseur->enabled))
{ {
if ($conf->use_javascript_ajax) { if ($conf->use_javascript_ajax) {
print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'); print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 1);
} else { } else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER); print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);

View File

@ -302,7 +302,7 @@ if (in_array($type, array('mysql', 'mysqli'))) {
print '<br>'; print '<br>';
print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>'; print '<fieldset><legend>'.$langs->trans('ExportStructure').'</legend>';
print '<input type="checkbox" name="nobin_drop"'.((! isset($_GET["nobin_drop"]) && ! isset($_POST["nobin_drop"])) || GETPOST('nobin_drop'))?' checked':''.' id="checkbox_dump_drop" />'; print '<input type="checkbox" name="nobin_drop"'.(((! isset($_GET["nobin_drop"]) && ! isset($_POST["nobin_drop"])) || GETPOST('nobin_drop'))?' checked':'').' id="checkbox_dump_drop" />';
print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>'; print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
print '<br>'; print '<br>';
print '</fieldset>'; print '</fieldset>';

View File

@ -781,8 +781,8 @@ class Categorie extends CommonObject
$objs = array(); $objs = array();
$tmpclass = $this->MAP_OBJ_CLASS[$type]; $classnameforobj = $this->MAP_OBJ_CLASS[$type];
$obj = new $tmpclass($this->db); $obj = new $classnameforobj($this->db);
$sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type]; $sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c";
@ -810,8 +810,11 @@ class Categorie extends CommonObject
} }
else else
{ {
$obj = new $this->MAP_OBJ_CLASS[$type]($this->db); $classnameforobj = $this->MAP_OBJ_CLASS[$type];
$obj = new $classnameforobj($this->db);
$obj->fetch($rec['fk_' . $this->MAP_CAT_FK[$type]]); $obj->fetch($rec['fk_' . $this->MAP_CAT_FK[$type]]);
$objs[] = $obj; $objs[] = $obj;
} }
} }

View File

@ -1014,7 +1014,7 @@ class Commande extends CommonOrder
// Complete vat rate with code // Complete vat rate with code
$vatrate = $line->tva_tx; $vatrate = $line->tva_tx;
if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')'; if ($line->vat_src_code && !preg_match('/\(.*\)/', $vatrate)) $vatrate .= ' ('.$line->vat_src_code.')';
$origin = (!empty($line->origin) ? $line->origin : $this->element);
$result = $this->addline( $result = $this->addline(
$line->desc, $line->desc,
$line->subprice, $line->subprice,
@ -1039,7 +1039,7 @@ class Commande extends CommonOrder
$line->label, $line->label,
$line->array_options, $line->array_options,
$line->fk_unit, $line->fk_unit,
$this->element, $origin,
$line->id $line->id
); );
if ($result < 0) if ($result < 0)

View File

@ -1442,7 +1442,7 @@ if (empty($reshook))
if ($_POST['type'] == Facture::TYPE_DEPOSIT) if ($_POST['type'] == Facture::TYPE_DEPOSIT)
{ {
$typeamount = GETPOST('typedeposit', 'alpha'); $typeamount = GETPOST('typedeposit', 'alpha');
$valuedeposit = GETPOST('valuedeposit', 'int'); $valuedeposit = price2num(GETPOST('valuedeposit', 'alpha'), 'MU');
$amountdeposit = array(); $amountdeposit = array();
if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA)) if (!empty($conf->global->MAIN_DEPOSIT_MULTI_TVA))

View File

@ -416,7 +416,7 @@ class Facture extends CommonInvoice
$this->brouillon = 1; $this->brouillon = 1;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency)) if (empty($this->fk_multicurrency))
{ {

View File

@ -53,6 +53,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inv
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$socid = GETPOST('socid', 'int');
// Security check // Security check
$id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int')); $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
$lineid = GETPOST('lineid', 'int'); $lineid = GETPOST('lineid', 'int');
@ -151,6 +153,11 @@ if ($socid > 0) {
} }
if ($socid > 0) {
$tmpthirdparty = new Societe($db);
$res = $tmpthirdparty->fetch($socid);
if ($res > 0) $search_societe = $tmpthirdparty->name;
}
/* /*
* Actions * Actions

View File

@ -180,6 +180,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
$limit=5; $limit=5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut"; $sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
$sql.= " WHERE entity IN (" . getEntity('prelevement') . ")";
$sql.= " ORDER BY datec DESC"; $sql.= " ORDER BY datec DESC";
$sql.= $db->plimit($limit); $sql.= $db->plimit($limit);

View File

@ -499,7 +499,7 @@ elseif ($modecompta == "BOOKKEEPING")
} }
/* /*
* Charges sociales non deductibles * Social contributions
*/ */
$subtotal_ht = 0; $subtotal_ht = 0;
@ -512,7 +512,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c"; $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs"; $sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id"; $sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end)) if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'"; $sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
} }
@ -524,7 +523,6 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p"; $sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid"; $sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id"; $sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 0";
if (!empty($date_start) && !empty($date_end)) if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'"; $sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
} }
@ -532,69 +530,7 @@ if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecom
$sql .= " AND cs.entity = ".$conf->entity; $sql .= " AND cs.entity = ".$conf->entity;
$sql .= " GROUP BY c.libelle, dm"; $sql .= " GROUP BY c.libelle, dm";
dol_syslog("get social contributions deductible=0 ", LOG_DEBUG); dol_syslog("get social contributions", LOG_DEBUG);
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($result);
if (!isset($decaiss[$obj->dm])) $decaiss[$obj->dm] = 0;
$decaiss[$obj->dm] += $obj->amount;
if (!isset($decaiss_ttc[$obj->dm])) $decaiss_ttc[$obj->dm] = 0;
$decaiss_ttc[$obj->dm] += $obj->amount;
$i++;
}
}
} else {
dol_print_error($db);
}
}
elseif ($modecompta == "BOOKKEEPING")
{
// Nothing from this table
}
/*
* Charges sociales deductibles
*/
$subtotal_ht = 0;
$subtotal_ttc = 0;
if (!empty($conf->tax->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))
{
if ($modecompta == 'CREANCES-DETTES')
{
$sql = "SELECT c.libelle as nom, date_format(cs.date_ech,'%Y-%m') as dm, sum(cs.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= " WHERE cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND cs.date_ech >= '".$db->idate($date_start)."' AND cs.date_ech <= '".$db->idate($date_end)."'";
}
elseif ($modecompta == "RECETTES-DEPENSES")
{
$sql = "SELECT c.libelle as nom, date_format(p.datep,'%Y-%m') as dm, sum(p.amount) as amount";
$sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
$sql .= ", ".MAIN_DB_PREFIX."chargesociales as cs";
$sql .= ", ".MAIN_DB_PREFIX."paiementcharge as p";
$sql .= " WHERE p.fk_charge = cs.rowid";
$sql .= " AND cs.fk_type = c.id";
$sql .= " AND c.deductible = 1";
if (!empty($date_start) && !empty($date_end))
$sql .= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
}
$sql .= " AND cs.entity = ".$conf->entity;
$sql .= " GROUP BY c.libelle, dm";
dol_syslog("get social contributions paid deductible=1", LOG_DEBUG);
$result = $db->query($sql); $result = $db->query($sql);
if ($result) { if ($result) {
$num = $db->num_rows($result); $num = $db->num_rows($result);
@ -734,7 +670,7 @@ elseif ($modecompta == 'BOOKKEEPING') {
/* /*
* Donation get dunning paiement * Donation get dunning payments
*/ */
if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) if (!empty($conf->don->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES"))

View File

@ -410,8 +410,8 @@ else
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{ {
$result = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{ {
$page = 0; $page = 0;
@ -421,14 +421,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$result = $db->query($sql); $resql = $db->query($sql);
if (!$result) if (! $resql)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$num = $db->num_rows($result); $num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
@ -784,7 +784,7 @@ $i = 0;
$totalarray = array(); $totalarray = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit))
{ {
$obj = $db->fetch_object($result); $obj = $db->fetch_object($resql);
$arraysocialnetworks = (array) json_decode($obj->socialnetworks, true); $arraysocialnetworks = (array) json_decode($obj->socialnetworks, true);
$contactstatic->lastname = $obj->lastname; $contactstatic->lastname = $obj->lastname;
@ -984,7 +984,7 @@ while ($i < min($num, $limit))
$i++; $i++;
} }
$db->free($result); $db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql); $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook

View File

@ -94,7 +94,7 @@ class box_contacts extends ModeleBoxes
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")"; $sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid; if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid;
$sql .= " ORDER BY sp.tms DESC"; $sql .= " ORDER BY sp.tms DESC";
$sql .= $this->db->plimit($max, 0); $sql .= $this->db->plimit($max, 0);

View File

@ -513,7 +513,7 @@ abstract class CommonDocGenerator
// Retrieve extrafields // Retrieve extrafields
if (is_array($object->array_options) && count($object->array_options)) if (is_array($object->array_options) && count($object->array_options))
{ {
$extrafieldkey = $object->element; $extrafieldkey = $object->table_element;
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
$extrafields = new ExtraFields($this->db); $extrafields = new ExtraFields($this->db);

View File

@ -7543,18 +7543,17 @@ abstract class CommonObject
$now = dol_now(); $now = dol_now();
$fieldvalues = $this->setSaveQuery(); $fieldvalues = $this->setSaveQuery();
if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now); if (array_key_exists('date_creation', $fieldvalues) && empty($fieldvalues['date_creation'])) $fieldvalues['date_creation'] = $this->db->idate($now);
if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id; if (array_key_exists('fk_user_creat', $fieldvalues) && !($fieldvalues['fk_user_creat'] > 0)) $fieldvalues['fk_user_creat'] = $user->id;
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert. unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into insert.
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
$keys = array(); $keys = array();
$values = array(); $values = array(); // Array to store string forged for SQL syntax
foreach ($fieldvalues as $k => $v) { foreach ($fieldvalues as $k => $v) {
$keys[$k] = $k; $keys[$k] = $k;
$value = $this->fields[$k]; $value = $this->fields[$k];
$values[$k] = $this->quote($v, $value); $values[$k] = $this->quote($v, $value); // May return string 'NULL' if $value is null
} }
// Clean and check mandatory // Clean and check mandatory
@ -7564,8 +7563,7 @@ abstract class CommonObject
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = '';
if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = ''; if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = '';
//var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && (!isset($values[$key]) || $values[$key] === 'NULL') && is_null($this->fields[$key]['default']))
if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($this->fields[$key]['default']))
{ {
$error++; $error++;
$this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); $this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);

View File

@ -5842,7 +5842,7 @@ class Form
} }
elseif ($typehour == 'text' || $typehour == 'textselect') elseif ($typehour == 'text' || $typehour == 'textselect')
{ {
$retstring .= '<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" size="1" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">'; $retstring .= '<input placeholder="'.$langs->trans('HourShort').'" type="number" min="0" name="'.$prefix.'hour"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputhour" value="'.(($hourSelected != '') ? ((int) $hourSelected) : '').'">';
} }
else return 'BadValueForParameterTypeHour'; else return 'BadValueForParameterTypeHour';
@ -5866,7 +5866,7 @@ class Form
} }
elseif ($typehour == 'text') elseif ($typehour == 'text')
{ {
$retstring .= '<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" size="1" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">'; $retstring .= '<input placeholder="'.$langs->trans('MinuteShort').'" type="number" min="0" name="'.$prefix.'min"'.($disabled ? ' disabled' : '').' class="flat maxwidth50 inputminute" value="'.(($minSelected != '') ? ((int) $minSelected) : '').'">';
} }
if ($typehour != 'text') $retstring .= ' '.$langs->trans('MinuteShort'); if ($typehour != 'text') $retstring .= ' '.$langs->trans('MinuteShort');
@ -5953,7 +5953,7 @@ class Form
$urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php'; $urlforajaxcall = DOL_URL_ROOT.'/core/ajax/selectobject.php';
// No immediate load of all database // No immediate load of all database
$urloption = 'htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.'&filter='.urlencode($objecttmp->filter).($moreparams ? $moreparams : ''); $urloption = 'htmlname='.$htmlname.'&outjson=1&objectdesc='.$objectdesc.'&filter='.urlencode($objecttmp->filter);
// Activate the auto complete using ajax call. // Activate the auto complete using ajax call.
$out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array()); $out .= ajax_autocompleter($preselectedvalue, $htmlname, $urlforajaxcall, $urloption, $conf->global->$confkeyforautocompletemode, 0, array());
$out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>'; $out .= '<style type="text/css">.ui-autocomplete { z-index: 250; }</style>';

View File

@ -354,7 +354,7 @@ class FormFile
// Add entity in $param if not already exists // Add entity in $param if not already exists
if (!preg_match('/entity\=[0-9]+/', $param)) { if (!preg_match('/entity\=[0-9]+/', $param)) {
$param .= 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity); $param .= ($param ? '&' : '').'entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
} }
$printer = 0; $printer = 0;

View File

@ -428,7 +428,7 @@ class SMTPs
$host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@ssl://@i', '', $host); // Remove prefix
$host=preg_replace('@tls://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix
if ($usetls) $host='tls://'.$host; if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host;
$hosth = $host; $hosth = $host;
@ -568,6 +568,8 @@ class SMTPs
$host=preg_replace('@ssl://@i', '', $host); // Remove prefix $host=preg_replace('@ssl://@i', '', $host); // Remove prefix
$host=preg_replace('@tls://@i', '', $host); // Remove prefix $host=preg_replace('@tls://@i', '', $host); // Remove prefix
if ($usetls && ! empty($conf->global->MAIN_SMTPS_ADD_TLS_TO_HOST_FOR_HELO)) $host = 'tls://'.$host;
$hosth = $host; $hosth = $host;
if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO))

View File

@ -41,9 +41,10 @@
* - Ex: array('show'=> ) * - Ex: array('show'=> )
* - Ex: array('update_textarea'=> ) * - Ex: array('update_textarea'=> )
* - Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax) * - Ex: array('option_disabled'=> id to disable and warning to show if we select a disabled value (this is possible when using autocomplete ajax)
* @param string $moreparams More params provided to ajax call
* @return string Script * @return string Script
*/ */
function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array()) function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '')
{ {
if (empty($minLength)) $minLength=1; if (empty($minLength)) $minLength=1;
@ -55,7 +56,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
// Input search_htmlname is original field // Input search_htmlname is original field
// Input htmlname is a second input field used when using ajax autocomplete. // Input htmlname is a second input field used when using ajax autocomplete.
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />'; $script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" '.($moreparams ? $moreparams : '').' />';
$script.= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n"; $script.= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
$script.= '<script>'."\n"; $script.= '<script>'."\n";
@ -478,16 +479,17 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @param int $entity Entity to set * @param int $entity Entity to set
* @param int $revertonoff Revert on/off * @param int $revertonoff Revert on/off
* @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant * @param int $strict Use only "disabled" with delConstant and "enabled" with setConstant
* @param int $forcenoajax 1=Force to use a ahref link instead of ajax code.
* @return string * @return string
*/ */
function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0) function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcenoajax = 0)
{ {
global $conf, $langs; global $conf, $langs;
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
if (empty($conf->use_javascript_ajax)) if (empty($conf->use_javascript_ajax) || $forcenoajax)
{ {
if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>'; if (empty($conf->global->$code)) print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>'; else print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_'.$code.'&entity='.$entity.'">'.img_picto($langs->trans("Enabled"), 'on').'</a>';

View File

@ -8507,7 +8507,7 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
$attr['class'] .= ' classfortooltip'; $attr['class'] .= ' classfortooltip';
} }
if (empty($id)) { if (!empty($id)) {
$attr['id'] = $id; $attr['id'] = $id;
} }

View File

@ -24,26 +24,38 @@
/** /**
* Function to return number in text. * Function to return a number into a text.
* May use module NUMBERWORDS if found.
* *
* * @param float $num Number to convert (must be a numeric value, like reported by price2num())
* @param float $num Number to convert
* @param Translate $langs Language * @param Translate $langs Language
* @param boolean $currency 0=number to translate | 1=currency to translate * @param boolean $currency 0=number to translate | 1=currency to translate
* @param boolean $centimes 0=no centimes | 1=centimes to translate * @param boolean $centimes 0=no cents/centimes | 1=there is cents/centimes to translate
* @return string|false Text of the number * @return string|false Text of the number
*/ */
function dol_convertToWord($num, $langs, $currency = false, $centimes = false) function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
{ {
global $conf; global $conf;
$num = str_replace(array(',', ' '), '', trim($num)); //$num = str_replace(array(',', ' '), '', trim($num)); This should be useless since $num MUST be a php numeric value
if (!$num) { if (!$num) {
return false; return false;
} }
if ($centimes && strlen($num) == 1) { if ($centimes && strlen($num) == 1) {
$num = $num * 10; $num = $num * 10;
} }
if (!empty($conf->global->MAIN_MODULE_NUMBERWORDS)) {
if ($currency) {
$type = 1;
} else {
$type = 0;
}
$concatWords = $langs->getLabelFromNumber($num, $type);
return $concatWords;
} else {
$TNum = explode('.', $num); $TNum = explode('.', $num);
$num = (int) $TNum[0]; $num = (int) $TNum[0];
$words = array(); $words = array();
@ -126,13 +138,18 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
} }
// If we need to write cents call again this function for cents // If we need to write cents call again this function for cents
if(!empty($TNum[1])) { $decimalpart = $TNum[1];
$decimalpart = preg_replace('/0+$/', '', $decimalpart);
if ($decimalpart) {
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and'); if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
$concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
$concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true);
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes'); if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
} }
return $concatWords; return $concatWords;
} }
}
/** /**
@ -146,10 +163,12 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
*/ */
function dolNumberToWord($numero, $langs, $numorcurrency = 'number') function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
{ {
// If the number is negative convert to positive and return -1 if is too long // If the number is negative convert to positive and return -1 if it is too long
if ($numero < 0) $numero *= -1; if ($numero < 0) $numero *= -1;
if ($numero >= 1000000000001) if ($numero >= 1000000000001) {
return -1; return -1;
}
// Get 2 decimals to cents, another functions round or truncate // Get 2 decimals to cents, another functions round or truncate
$strnumber = number_format($numero, 10); $strnumber = number_format($numero, 10);
$len = strlen($strnumber); $len = strlen($strnumber);

View File

@ -1859,7 +1859,6 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
} }
if (empty($reshook)) if (empty($reshook))
{ {
if ($object->lines[$i]->special_code == 3) return '';
if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short')); if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
} }
return $result; return $result;
@ -2108,7 +2107,7 @@ function pdf_getTotalQty($object, $type, $outputlangs)
*/ */
function pdf_getLinkedObjects($object, $outputlangs) function pdf_getLinkedObjects($object, $outputlangs)
{ {
global $hookmanager; global $db, $hookmanager;
$linkedobjects = array(); $linkedobjects = array();
@ -2175,8 +2174,13 @@ function pdf_getLinkedObjects($object, $outputlangs)
// We concat this record info into fields xxx_value. title is overwrote. // We concat this record info into fields xxx_value. title is overwrote.
if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order
{ {
$elementobject->fetchObjectLinked(); $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']); if (! empty($elementobject->linkedObjectsIds['commande'])){
include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
$order = new Commande($db);
$ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
if ($ret < 1) { $order=null; }
}
} }
if (!is_object($order)) if (!is_object($order))
{ {

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2017 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2008-2017 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2020 Ferran Marcet <fmarcet@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -309,6 +310,10 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
elseif ($feature == 'cheque') elseif ($feature == 'cheque')
{ {
if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; } if (!$user->rights->banque->cheque) { $createok = 0; $nbko++; }
} elseif ($feature == 'import') {
if (!$user->rights->import->run) { $createok = 0; $nbko++; }
} elseif ($feature == 'ecm') {
if (!$user->rights->ecm->upload) { $createok = 0; $nbko++; }
} }
elseif (!empty($feature2)) // This is for permissions on one level elseif (!empty($feature2)) // This is for permissions on one level
{ {
@ -571,6 +576,18 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; $sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")"; $sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
} }
if ($feature == 'agenda')// Also check myactions rights
{
if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
$action = new ActionComm($db);
$action->fetch($objectid);
if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
return false;
}
}
}
} }
elseif (in_array($feature, $checkproject)) elseif (in_array($feature, $checkproject))
{ {

View File

@ -239,7 +239,9 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
!empty($user->rights->supplier_proposal->lire) || !empty($user->rights->supplier_proposal->lire) ||
!empty($user->rights->supplier_order->lire) || !empty($user->rights->supplier_order->lire) ||
!empty($user->rights->contrat->lire) || !empty($user->rights->contrat->lire) ||
!empty($user->rights->ficheinter->lire) !empty($user->rights->ficheinter->lire) ||
!empty($user->rights->supplier_order->lire) ||
!empty($user->rights->fournisseur->commande->lire)
), ),
'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter' 'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter'
); );
@ -1704,7 +1706,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (empty($conf->global->PROJECT_HIDE_TASKS)) if (empty($conf->global->PROJECT_HIDE_TASKS))
{ {
// Project affected to user // Project affected to user
$newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire); $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks');
$newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
$newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire); $newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);

View File

@ -777,7 +777,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client=pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object); $usecontact = 0;
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact))?$object->contact:null), $usecontact, 'target', $object);
// Show recipient // Show recipient
$widthrecbox=90; $widthrecbox=90;

View File

@ -131,6 +131,21 @@ if ($action == 'presend')
{ {
$formmail->fromid = $user->id; $formmail->fromid = $user->id;
} }
if ($object->element === 'facture' && !empty($conf->global->INVOICE_EMAIL_SENDER)) {
$formmail->frommail = $conf->global->INVOICE_EMAIL_SENDER;
$formmail->fromname = '';
$formmail->fromtype = 'special';
}
if ($object->element === 'shipping' && !empty($conf->global->SHIPPING_EMAIL_SENDER)) {
$formmail->frommail = $conf->global->SHIPPING_EMAIL_SENDER;
$formmail->fromname = '';
$formmail->fromtype = 'special';
}
if ($object->element === 'commande' && !empty($conf->global->COMMANDE_EMAIL_SENDER)) {
$formmail->frommail = $conf->global->COMMANDE_EMAIL_SENDER;
$formmail->fromname = '';
$formmail->fromtype = 'special';
}
$formmail->trackid=$trackid; $formmail->trackid=$trackid;
if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID) && ($conf->global->MAIN_EMAIL_ADD_TRACK_ID & 2)) // If bit 2 is set
{ {

View File

@ -60,7 +60,7 @@ if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_e
// we keep position for the first line // we keep position for the first line
$totalarray['totalizable'][$key]['pos'] = $totalarray['nbfield']; $totalarray['totalizable'][$key]['pos'] = $totalarray['nbfield'];
} }
$totalarray['totalizable'][$key]['total'] += $obj->$tmpkey; if (is_numeric($obj->$tmpkey)) $totalarray['totalizable'][$key]['total'] += $obj->$tmpkey;
} }
if (!empty($val['isameasure'])) if (!empty($val['isameasure']))
{ {

View File

@ -1524,13 +1524,19 @@ if ($action == 'create')
} }
if ($subj == 0) // Line not shown yet, we show it if ($subj == 0) // Line not shown yet, we show it
{ {
$warehouse_selected_id = GETPOST('entrepot_id', 'int');
print '<!-- line not shown yet, we show it -->'; print '<!-- line not shown yet, we show it -->';
print '<tr class="oddeven"><td colspan="3"></td><td class="center">'; print '<tr class="oddeven"><td colspan="3"></td><td class="center">';
if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$disabled = ''; $disabled = '';
if (!empty($conf->productbatch->enabled) && $product->hasbatch()) if (!empty($conf->productbatch->enabled) && $product->hasbatch())
{ {
$disabled = 'disabled="disabled"';
}
if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty.
$disabled = 'disabled="disabled"'; $disabled = 'disabled="disabled"';
} }
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> '; print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> ';
@ -1544,7 +1550,6 @@ if ($action == 'create')
print '<td class="left">'; print '<td class="left">';
if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
{ {
$warehouse_selected_id = GETPOST('entrepot_id', 'int');
if ($warehouse_selected_id > 0) if ($warehouse_selected_id > 0)
{ {
$warehouseObject = new Entrepot($db); $warehouseObject = new Entrepot($db);

View File

@ -323,10 +323,10 @@ class Expedition extends CommonObject
$sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null");
$sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null");
$sql.= ", '".$this->db->escape($this->tracking_number)."'"; $sql.= ", '".$this->db->escape($this->tracking_number)."'";
$sql.= ", ".$this->weight; $sql.= ", ".(is_numeric($this->weight)?$this->weight:'NULL');
$sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth $sql.= ", ".(is_numeric($this->sizeS)?$this->sizeS:'NULL'); // TODO Should use this->trueDepth
$sql.= ", ".$this->sizeW; // TODO Should use this->trueWidth $sql.= ", ".(is_numeric($this->sizeW)?$this->sizeW:'NULL'); // TODO Should use this->trueWidth
$sql.= ", ".$this->sizeH; // TODO Should use this->trueHeight $sql.= ", ".(is_numeric($this->sizeH)?$this->sizeH:'NULL'); // TODO Should use this->trueHeight
$sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL'); $sql.= ", ".($this->weight_units != '' ? (int) $this->weight_units : 'NULL');
$sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL'); $sql.= ", ".($this->size_units != '' ? (int) $this->size_units : 'NULL');
$sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null"); $sql.= ", ".(!empty($this->note_private)?"'".$this->db->escape($this->note_private)."'":"null");

View File

@ -330,9 +330,11 @@ class CommandeFournisseur extends CommonOrder
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method";
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid';
$sql .= " WHERE c.entity = ".$conf->entity;
if (empty($id)) $sql .= " WHERE c.entity IN (".getEntity('supplier_order').")";
else $sql .= " WHERE c.rowid=".$id;
if ($ref) $sql .= " AND c.ref='".$this->db->escape($ref)."'"; if ($ref) $sql .= " AND c.ref='".$this->db->escape($ref)."'";
else $sql .= " AND c.rowid=".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
@ -892,6 +894,7 @@ class CommandeFournisseur extends CommonOrder
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1'; $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande_fournisseur SET billed = 1';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT;
if ($this->db->query($sql)) if ($this->db->query($sql))
{ {
if (!$error) if (!$error)
@ -1270,11 +1273,15 @@ class CommandeFournisseur extends CommonOrder
$error = 0; $error = 0;
$now = dol_now(); $now = dol_now();
// $date_commande is deprecated
$date = ($this->date_commande ? $this->date_commande : $this->date); // in case of date is set
if(empty($date)) $date = $now;
// Clean parameters // Clean parameters
if (empty($this->source)) $this->source = 0; if (empty($this->source)) $this->source = 0;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $date);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency)) if (empty($this->fk_multicurrency))
{ {

View File

@ -359,7 +359,7 @@ class FactureFournisseur extends CommonInvoice
$remise = $this->remise; $remise = $this->remise;
// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate) // Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code); else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
if (empty($this->fk_multicurrency)) if (empty($this->fk_multicurrency))
{ {

View File

@ -1008,7 +1008,7 @@ class ProductFournisseur extends Product
//$out .= '<td class="liste_titre right">'.$langs->trans("QtyMin").'</td>'; //$out .= '<td class="liste_titre right">'.$langs->trans("QtyMin").'</td>';
$out .= '<td class="liste_titre">'.$langs->trans("User").'</td></tr>'; $out .= '<td class="liste_titre">'.$langs->trans("User").'</td></tr>';
foreach ($productFournLogList as $productFournLog) { foreach ($productFournLogList as $productFournLog) {
$out .= '<tr><td class="right">'.dol_print_date($this->db->jdate($productFournLog['datec']), 'dayhour', 'tzuser').'</td>'; $out .= '<tr><td class="right">'.dol_print_date($productFournLog['datec'], 'dayhour', 'tzuser').'</td>';
$out .= '<td class="right">'.price($productFournLog['price']).'</td>'; $out .= '<td class="right">'.price($productFournLog['price']).'</td>';
//$out.= '<td class="right">'.$productFournLog['quantity'].'</td>'; //$out.= '<td class="right">'.$productFournLog['quantity'].'</td>';
$out .= '<td>'.$productFournLog['lastname'].'</td></tr>'; $out .= '<td>'.$productFournLog['lastname'].'</td></tr>';

View File

@ -460,11 +460,26 @@ if (empty($reshook))
if ($idprod > 0) if ($idprod > 0)
{ {
$label = $productsupplier->label; $label = $productsupplier->label;
// Define output language
if (!empty($conf->global->MAIN_MULTILANGS) && !empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
$outputlangs = $langs;
$newlang = '';
if (empty($newlang) && GETPOST('lang_id', 'aZ09'))
$newlang = GETPOST('lang_id', 'aZ09');
if (empty($newlang))
$newlang = $object->thirdparty->default_lang;
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$desc = (!empty($productsupplier->multilangs [$outputlangs->defaultlang] ["description"])) ? $productsupplier->multilangs [$outputlangs->defaultlang] ["description"] : $productsupplier->description;
} else {
$desc = $productsupplier->description;
}
// if we use supplier description of the products // if we use supplier description of the products
if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) { if (!empty($productsupplier->desc_supplier) && !empty($conf->global->PRODUIT_FOURN_TEXTS)) {
$desc = $productsupplier->desc_supplier; $desc = $productsupplier->desc_supplier;
} else $desc = $productsupplier->description; }
if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION)); if (trim($product_desc) != trim($desc)) $desc = dol_concatdesc($desc, $product_desc, '', !empty($conf->global->MAIN_CHANGE_ORDER_CONCAT_DESCRIPTION));

View File

@ -27,10 +27,10 @@
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
require DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
require DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
$langs->loadLangs(array('bills', 'banks', 'companies', 'suppliers')); $langs->loadLangs(array('bills', 'banks', 'companies', 'suppliers'));
@ -210,7 +210,7 @@ if ($result > 0)
*/ */
// Amount // Amount
print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>'; print '<tr><td colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->amount, '', $langs, 0, 0, -1, $conf->currency).'</td></tr>';
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
{ {

View File

@ -409,12 +409,11 @@ if (typeof(PhpDebugBar) == 'undefined') {
className: "phpdebugbar " + csscls('minimized'), className: "phpdebugbar " + csscls('minimized'),
options: {
bodyMarginBottom: true,
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom'))
},
initialize: function() { initialize: function() {
this.options = {
bodyMarginBottom: true,
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')),
};
this.controls = {}; this.controls = {};
this.dataMap = {}; this.dataMap = {};
this.datasets = {}; this.datasets = {};

View File

@ -242,7 +242,7 @@ class DoliStorage implements TokenStorageInterface
$sql.= " WHERE service='".$this->db->escape($service)."'"; $sql.= " WHERE service='".$this->db->escape($service)."'";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
$result = $this->db->fetch_array($resql); $result = $this->db->fetch_array($resql);
$states[$service] = $result[state]; $states[$service] = $result['state'];
$this->states[$service] = $states[$service]; $this->states[$service] = $states[$service];
return is_array($states) return is_array($states)

View File

@ -98,7 +98,7 @@ ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0;
ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0; ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0;
ALTER TABLE llx_bom_bomline DROP COLUMN rank; ALTER TABLE llx_bom_bomline DROP COLUMN `rank`;
create table llx_categorie_warehouse create table llx_categorie_warehouse
( (

View File

@ -353,8 +353,8 @@ PriceUTTC=U.P. (inc. tax)
Amount=Amount Amount=Amount
AmountInvoice=Invoice amount AmountInvoice=Invoice amount
AmountInvoiced=Amount invoiced AmountInvoiced=Amount invoiced
AmountInvoicedHT=Amount invoiced (incl. tax) AmountInvoicedHT=Amount invoiced (excl. tax)
AmountInvoicedTTC=Amount invoiced (excl. tax) AmountInvoicedTTC=Amount invoiced (inc. tax)
AmountPayment=Payment amount AmountPayment=Payment amount
AmountHTShort=Amount (excl.) AmountHTShort=Amount (excl.)
AmountTTCShort=Amount (inc. tax) AmountTTCShort=Amount (inc. tax)

View File

@ -353,8 +353,8 @@ PriceUTTC=P.U TTC
Amount=Montant Amount=Montant
AmountInvoice=Montant facture AmountInvoice=Montant facture
AmountInvoiced=Montant facturé AmountInvoiced=Montant facturé
AmountInvoicedHT=Montant facturé (TTC) AmountInvoicedHT=Montant facturé (HT)
AmountInvoicedTTC=Montant facturé (HT) AmountInvoicedTTC=Montant facturé (TTC)
AmountPayment=Montant paiement AmountPayment=Montant paiement
AmountHTShort=Montant HT AmountHTShort=Montant HT
AmountTTCShort=Montant TTC AmountTTCShort=Montant TTC

View File

@ -530,7 +530,7 @@ class MultiCurrency extends CommonObject
$sql1.= " AND m.entity IN (".getEntity('multicurrency').")"; $sql1.= " AND m.entity IN (".getEntity('multicurrency').")";
$sql2= ''; $sql2= '';
if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) $sql2.= ' AND DATE_FORMAT(mc.date_sync, "%Y-%m-%d") = "'.date('Y-m-d', $date_document).'"'; if (!empty($conf->global->MULTICURRENCY_USE_RATE_ON_DOCUMENT_DATE) && !empty($date_document)) $sql2.= ' AND DATE_FORMAT(mc.date_sync, "%Y-%m-%d") = "'.date('Y-m-d', $date_document).'"';
$sql3.= ' ORDER BY mc.date_sync DESC LIMIT 1'; $sql3 = ' ORDER BY mc.date_sync DESC LIMIT 1';
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$resql = $db->query($sql1.$sql2.$sql3); $resql = $db->query($sql1.$sql2.$sql3);

View File

@ -66,12 +66,13 @@ if ($id > 0 || ! empty($ref))
if ($cancel) $action =''; if ($cancel) $action ='';
// Action association d'un sousproduit // Add subproduct to product
if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer)) if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->service->creer))
{ {
$error=0; $error=0;
for ($i=0; $i < GETPOST("max_prod", 'int'); $i++) $maxprod = GETPOST("max_prod", 'int');
for ($i=0; $i < $maxprod; $i++)
{ {
$qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS'); $qty = price2num(GETPOST("prod_qty_".$i, 'alpha'), 'MS');
if ($qty > 0) if ($qty > 0)

View File

@ -225,7 +225,7 @@ if ($id > 0 || ! empty($ref))
print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("CustomerCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder);
print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";

View File

@ -208,7 +208,7 @@ if ($id > 0 || !empty($ref))
print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", $option, '', $sortfield, $sortorder);
print_liste_field_titre("DatePropal", $_SERVER["PHP_SELF"], "p.datep", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("DatePropal", $_SERVER["PHP_SELF"], "p.datep", "", $option, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder);
print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "p.total", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder);
print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder);
print "</tr>\n"; print "</tr>\n";

View File

@ -104,6 +104,7 @@ class Entrepot extends CommonObject
*/ */
public $fields=array( public $fields=array(
'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10), 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>15),
'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25), 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25),
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30),
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35),
@ -441,6 +442,7 @@ class Entrepot extends CommonObject
} }
$sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id";
$sql .= " , entity";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id) if ($id)
{ {
@ -460,6 +462,7 @@ class Entrepot extends CommonObject
$obj=$this->db->fetch_object($result); $obj=$this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->fk_parent = $obj->fk_parent; $this->fk_parent = $obj->fk_parent;
$this->ref = $obj->label; $this->ref = $obj->label;
$this->label = $obj->label; $this->label = $obj->label;

View File

@ -209,13 +209,13 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as ccount ON ccount.rowid = t.fk
$sql .= " WHERE t.entity IN (".getEntity('stock').")"; $sql .= " WHERE t.entity IN (".getEntity('stock').")";
foreach ($search as $key => $val) foreach ($search as $key => $val)
{ {
if ($key == 'status' && $search[$key] == -1) continue; if (($key == 'status' && $search[$key] == -1) || $key=='entity') continue;
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) { if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
if ($search[$key] == '-1') $search[$key] = ''; if ($search[$key] == '-1') $search[$key] = '';
$mode_search = 2; $mode_search = 2;
} }
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); if ($search[$key] != '') $sql .= natural_search((($key == 'ref') ? 't.ref' : $key), $search[$key], (($key == 'status') ? 2 : $mode_search));
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields // Add where from extra fields

View File

@ -78,6 +78,7 @@ $cancel != $langs->trans("Cancel") &&
$object->label = $_POST["libelle"]; $object->label = $_POST["libelle"];
$object->description = dol_htmlcleanlastbr($_POST["desc"]); $object->description = dol_htmlcleanlastbr($_POST["desc"]);
$object->other = dol_htmlcleanlastbr($_POST["other"]); $object->other = dol_htmlcleanlastbr($_POST["other"]);
$object->update($object->id, $user);
} }
else else
{ {

View File

@ -63,7 +63,7 @@ $search_agenda_label = GETPOST('search_agenda_label');
$id = GETPOST("id", 'int'); $id = GETPOST("id", 'int');
$socid = 0; $socid = 0;
//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement.
$result = restrictedArea($user, 'projet', $id, ''); $result = restrictedArea($user, 'projet', $id, 'projet&project');
if (!$user->rights->projet->lire) accessforbidden(); if (!$user->rights->projet->lire) accessforbidden();

View File

@ -58,6 +58,7 @@ $search_task_label = GETPOST('search_task_label');
$search_task_description = GETPOST('search_task_description'); $search_task_description = GETPOST('search_task_description');
$search_project_user = GETPOST('search_project_user'); $search_project_user = GETPOST('search_project_user');
$search_task_user = GETPOST('search_task_user'); $search_task_user = GETPOST('search_task_user');
$search_societe = GETPOST('search_societe');
$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; $mine = $_REQUEST['mode'] == 'mine' ? 1 : 0;
if ($mine) { $search_task_user = $user->id; $mine = 0; } if ($mine) { $search_task_user = $user->id; $mine = 0; }

View File

@ -552,7 +552,7 @@ if (empty($reshook))
// Links with users // Links with users
$salesreps = GETPOST('commercial', 'array'); $salesreps = GETPOST('commercial', 'array');
$result = $object->setSalesRep($salesreps); $result = $object->setSalesRep($salesreps, true);
if ($result < 0) if ($result < 0)
{ {
$error++; $error++;
@ -861,6 +861,11 @@ if (empty($reshook))
$id = $socid; $id = $socid;
$object->fetch($socid); $object->fetch($socid);
// Selection of new fields
if (!empty($conf->global->MAIN_DUPLICATE_CONTACTS_TAB_ON_MAIN_CARD) && (empty($conf->global->SOCIETE_DISABLE_CONTACTS) || !empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))) {
include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
}
// Actions to send emails // Actions to send emails
$triggersendname = 'COMPANY_SENTBYMAIL'; $triggersendname = 'COMPANY_SENTBYMAIL';
$paramname = 'socid'; $paramname = 'socid';

View File

@ -4270,9 +4270,10 @@ class Societe extends CommonObject
* Sets sales representatives of the thirdparty * Sets sales representatives of the thirdparty
* *
* @param int[]|int $salesrep User ID or array of user IDs * @param int[]|int $salesrep User ID or array of user IDs
* @param bool $onlyAdd Only add (no delete before)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
public function setSalesRep($salesrep) public function setSalesRep($salesrep, $onlyAdd = false)
{ {
global $user; global $user;
@ -4281,6 +4282,10 @@ class Societe extends CommonObject
$salesrep = array($salesrep); $salesrep = array($salesrep);
} }
$to_del = array(); // Nothing to delete
$to_add = $salesrep;
if ($onlyAdd === false) {
// Get current users // Get current users
$existing = $this->getSalesRepresentatives($user, 1); $existing = $this->getSalesRepresentatives($user, 1);
@ -4288,9 +4293,7 @@ class Societe extends CommonObject
if (is_array($existing)) { if (is_array($existing)) {
$to_del = array_diff($existing, $salesrep); $to_del = array_diff($existing, $salesrep);
$to_add = array_diff($salesrep, $existing); $to_add = array_diff($salesrep, $existing);
} else { }
$to_del = array(); // Nothing to delete
$to_add = $salesrep;
} }
$error = 0; $error = 0;

View File

@ -891,7 +891,7 @@ class SupplierProposal extends CommonObject
} }
// Multicurrency // Multicurrency
if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $now);
if (empty($this->fk_multicurrency)) if (empty($this->fk_multicurrency))
{ {
$this->multicurrency_code = $conf->currency; $this->multicurrency_code = $conf->currency;

View File

@ -158,6 +158,9 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase
print 'Check sql file '.$file."\n"; print 'Check sql file '.$file."\n";
$filecontent = file_get_contents($dir.'/'.$file); $filecontent = file_get_contents($dir.'/'.$file);
// Allow ` for 'rank' column name
$filecontent = str_replace('`rank`', '_rank_', $filecontent);
$result=strpos($filecontent, '`'); $result=strpos($filecontent, '`');
print __METHOD__." Result for checking we don't have back quote = ".$result."\n"; print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
$this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.'); $this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');